def __convert_ref(cls, rf): names = [ identifier_from_slug(token) for token in rf.attribute.split('.') ] config = {} # First, make sure that all parent attributes are configured INLINE. for idx in range(len(names[:-1])): key = tuple(names[:idx + 1]) config[key] = {IGNORE_OPTION: False, WRITE_AS_LINK_OPTION: False} is_off = rf.option == OFF_PAT opts = {IGNORE_OPTION: is_off} if not is_off: opts[WRITE_AS_LINK_OPTION] = rf.option == URL_PAT config[tuple(names)] = opts return config
def __get_op_func(self, op_name): # Visitor function dispatch using the operator name. return getattr(self, '_%s_op' % identifier_from_slug(op_name))
def __get_op_func(self, op_name): # Visitor function dispatch using the operator name. return getattr(self, '_%s_op' % identifier_from_slug(op_name))
def __prepare_identifier(cls, name): return identifier_from_slug(name)
def __prepare_identifier(cls, name): return identifier_from_slug(name)
def test_get_identifier_from_slug(self): self.assert_equal(identifier_from_slug('a-b'), 'a_b')
def __getitem__(self, item): ident = identifier_from_slug(item) attr = get_resource_class_attribute(self.__class__, ident) if attr is None or attr.kind == RESOURCE_ATTRIBUTE_KINDS.TERMINAL: raise KeyError('%s' % ident) return getattr(self, ident)
def __getitem__(self, item): ident = identifier_from_slug(item) attr = get_resource_class_attributes(self.__class__).get(ident) if attr is None or not attr.is_nested: raise KeyError('%s' % ident) return getattr(self, ident)
def __getitem__(self, item): ident = identifier_from_slug(item) attr = get_resource_class_attribute(self.__class__, ident) if attr is None or attr.kind == RESOURCE_ATTRIBUTE_KINDS.TERMINAL: raise KeyError('%s' % ident) return getattr(self, ident)
def test_get_identifier_from_slug(self): self.assert_equal(identifier_from_slug('a-b'), 'a_b')
def __getitem__(self, item): ident = identifier_from_slug(item) attr = get_resource_class_attribute(self.__class__, ident) if attr is None: raise KeyError('%s' % ident) return getattr(self, ident)
def test_get_identifier_from_slug(self): self.assert_equal(identifier_from_slug("a-b"), "a_b")