Пример #1
0
 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
Пример #2
0
 def __get_op_func(self, op_name):
     # Visitor function dispatch using the operator name.
     return getattr(self, '_%s_op' % identifier_from_slug(op_name))
Пример #3
0
 def __get_op_func(self, op_name):
     # Visitor function dispatch using the operator name.
     return getattr(self, '_%s_op' % identifier_from_slug(op_name))
Пример #4
0
 def __prepare_identifier(cls, name):
     return identifier_from_slug(name)
Пример #5
0
 def __prepare_identifier(cls, name):
     return identifier_from_slug(name)
Пример #6
0
 def test_get_identifier_from_slug(self):
     self.assert_equal(identifier_from_slug('a-b'), 'a_b')
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 def test_get_identifier_from_slug(self):
     self.assert_equal(identifier_from_slug('a-b'), 'a_b')
Пример #11
0
 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)
Пример #12
0
 def test_get_identifier_from_slug(self):
     self.assert_equal(identifier_from_slug("a-b"), "a_b")