Exemplo n.º 1
0
 def __init__(self, keys, **kwargs):
     """
         @param keys is a list containing the keys of the dict
         @param kwargs will contain the necessary arguments to
                construct each descriptor of the dict. These
                arguments start with the name of the key.
     """
     self.delegates = {}
     for item_name in keys:
         kwargs_delegate = dict((item[len(item_name)+1:], kwargs[item])
                                for item in kwargs.keys()
                                if item.startswith(item_name + "_"))
         klass = find_descriptor(kwargs_delegate["type"])
         self.delegates[item_name] = klass(**kwargs_delegate)
Exemplo n.º 2
0
 def __init__(self, length, item_type, **kwargs):
     """
         @length is the length of the list
         @item_type is the type of every item on the list
         @kwargs contains the arguments necessary to construct
                 the delegator for the nested descriptors. These
                 arguments start with "item_"
     """
     if len(item_type) == 0:
         raise RequirementViolated("Requirement of item_type violated.")
     self.length = length
     klass = find_descriptor(item_type)
     kwargs_delegate = dict((item[5:], kwargs[item])
                            for item in kwargs.keys()
                            if item.startswith("item_"))
     self.delegate = klass(**kwargs_delegate)