models.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:pyfc4 作者: ghukill 项目源码 文件源码
def _handle_object(self, object_input):

        '''
        Method to handle possible values passed for adding, removing, modifying triples.
        Detects type of input and sets appropriate http://www.w3.org/2001/XMLSchema# datatype

        Args:
            object_input (str,int,datetime,): many possible inputs

        Returns:
            (rdflib.term.Literal): with appropriate datatype attribute
        '''

        # if object is string, convert to rdflib.term.Literal with appropriate datatype
        if type(object_input) == str:
            return rdflib.term.Literal(object_input, datatype=rdflib.XSD.string)

        # integer
        elif type(object_input) == int:
            return rdflib.term.Literal(object_input, datatype=rdflib.XSD.int)

        # float
        elif type(object_input) == float:
            return rdflib.term.Literal(object_input, datatype=rdflib.XSD.float)

        # date
        elif type(object_input) == datetime.datetime:
            return rdflib.term.Literal(object_input, datatype=rdflib.XSD.date)

        else:
            return object_input
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号