def format_types(typ): if isinstance(typ, OneOrMore): return ':class:`{}` (:class:`{}`)'.format(FCN(OneOrMore), FCN(typ.source_type)) elif isinstance(typ, type): return ':class:`{}`'.format(FCN(typ)) else: return ', '.join(':class:`{}`'.format(FCN(x)) for x in typ)
def __repr__(self): return '{}(subj={}, prop={}, obj={}, context={})'.format( FCN(type(self)), repr(self.subject), repr(self.property), repr(self.object), repr(self.context))
def format_types(typ): if isinstance(typ, type): return ':class:`{}`'.format(FCN(typ)) else: return ', '.join(':class:`{}`'.format(FCN(x)) for x in typ)
def __init__(self, runner, mapper=None): self.runner = runner self.mapper = CLIArgMapper() if mapper is None else mapper self.hints = CLI_HINTS.get(FCN(type(runner)))
def __repr__(self): return '{}({})'.format(FCN(type(self)), repr(self.statement))
def __repr__(self): return '{}({})'.format(FCN(type(self)), repr(self.__factory__))
def __repr__(self): fcn = FCN(type(self)) return '{}(owner={})'.format(fcn, repr(self.owner))
def __repr__(self): return FCN(type(self)) + '(' + repr(self.identifier) + ')'
def __repr__(self): return '{}(ident="{}")'.format(FCN(type(self)), getattr(self, 'identifier', '???'))
def __repr__(self): return FCN(type(self)) + '(' + repr(self.source_type) + ')'
def _create_property_class(cls, linkName, property_type, value_type=None, value_rdf_type=None, multiple=False, link=None, lazy=True, inverse_of=None, **kwargs): owner_class = cls owner_class_name = owner_class.__name__ property_class_name = str(owner_class_name + "_" + linkName) _PropertyTypes_key = (cls, linkName) if value_type is This: value_type = owner_class if isinstance(value_type, six.text_type): value_type = owner_class.mapper.load_class(value_type) if value_type is None: value_type = BaseDataObject c = None if _PropertyTypes_key in PropertyTypes: c = PropertyTypes[_PropertyTypes_key] else: klass = None if property_type == 'ObjectProperty': if value_type is not None and value_rdf_type is None: value_rdf_type = value_type.rdf_type klass = SP.ObjectProperty elif property_type == 'DatatypeProperty': value_rdf_type = None klass = SP.DatatypeProperty elif property_type == 'UnionProperty': value_rdf_type = None klass = SP.UnionProperty else: value_rdf_type = None if link is None: if owner_class.rdf_namespace is None: raise Exception("{}.rdf_namespace is None".format( FCN(owner_class))) link = owner_class.rdf_namespace[linkName] classes = [klass] props = dict(linkName=linkName, link=link, property_type=property_type, value_rdf_type=value_rdf_type, value_type=value_type, owner_type=owner_class, rdf_object=PropertyDataObject.contextualize( owner_class.definition_context)(ident=link), lazy=lazy, multiple=multiple, inverse_of=inverse_of, **kwargs) if inverse_of is not None: invc = inverse_of[0] if invc is This: invc = owner_class InverseProperty(owner_class, linkName, invc, inverse_of[1]) c = type(property_class_name, tuple(classes), props) c.__module__ = owner_class.__module__ owner_class.mapper.add_class(c) PropertyTypes[_PropertyTypes_key] = c return c
def __str__(self): s = '''Input type(s): {} Output type(s): {}'''.format(self.input_type, self.output_type) return FCN(type(self)) + ': \n ' + ('\n '.join( x.strip() for x in s.split('\n')))