def __generate_skeleton(self, doc, struct, path=""):
     for key in struct:
         if type(key) is type:
             new_key = "$%s" % key.__name__
         else:
             new_key = key
         new_path = ".".join([path, new_key]).strip('.')
         #
         # Automatique generate the skeleton with NoneType
         #
         if type(key) is not type and key not in doc:
             if isinstance(struct[key], dict):
                 if type(struct[key]) is dict and self.use_dot_notation:
                     if new_path in self._i18n_namespace:
                         doc[key] = i18nDotedDict(doc.get(key, {}), self)
                     else:
                         doc[key] = DotedDict(
                             doc.get(key, {}),
                             warning=self.dot_notation_warning)
                 else:
                     if callable(struct[key]):
                         doc[key] = struct[key]()
                     else:
                         doc[key] = type(struct[key])()
             elif struct[key] is dict:
                 doc[key] = {}
             elif isinstance(struct[key], list):
                 doc[key] = type(struct[key])()
             elif isinstance(struct[key], CustomType):
                 if struct[key].init_type is not None:
                     doc[key] = struct[key].init_type()
                 else:
                     doc[key] = None
             elif struct[key] is list:
                 doc[key] = []
             elif isinstance(struct[key], tuple):
                 doc[key] = [None for _ in range(len(struct[key]))]
             else:
                 doc[key] = None
         #
         # if the value is a dict, we have a another structure to validate
         #
         if isinstance(struct[key], dict) and type(key) is not type:
             self.__generate_skeleton(doc[key], struct[key], new_path)
Example #2
0
 def __generate_skeleton(self, doc, struct, path=""):
     for key in struct:
         if type(key) is type:
             new_key = "$%s" % key.__name__
         else:
             new_key = key
         new_path = ".".join([path, new_key]).strip('.')
         #
         # Automatique generate the skeleton with NoneType
         #
         if type(key) is not type and key not in doc:
             if isinstance(struct[key], dict):
                 if type(struct[key]) is dict and self.use_dot_notation:
                     if new_path in self._i18n_namespace:
                         doc[key] = i18nDotedDict(doc.get(key, {}), self)
                     else:
                         doc[key] = DotedDict(doc.get(key, {}), warning=self.dot_notation_warning)
                 else:
                     if callable(struct[key]):
                         doc[key] = struct[key]()
                     else:
                         doc[key] = type(struct[key])()
             elif struct[key] is dict:
                 doc[key] = {}
             elif isinstance(struct[key], list):
                 doc[key] = type(struct[key])()
             elif isinstance(struct[key], CustomType):
                 if struct[key].init_type is not None:
                     doc[key] = struct[key].init_type()
                 else:
                     doc[key] = None
             elif struct[key] is list:
                 doc[key] = []
             elif isinstance(struct[key], tuple):
                 doc[key] = [None for _ in range(len(struct[key]))]
             else:
                 doc[key] = None
         #
         # if the value is a dict, we have a another structure to validate
         #
         if isinstance(struct[key], dict) and type(key) is not type:
             self.__generate_skeleton(doc[key], struct[key], new_path)
Example #3
0
 def __generate_doted_dict(self, doc, struct, path=""):
     for key in struct:
         #
         # Automatique generate the skeleton with NoneType
         #
         if type(key) is type:
             new_key = "$%s" % key.__name__
         else:
             new_key = key
         new_path = ".".join([path, new_key]).strip('.')
         if type(key) is not type:  # and key not in doc:
             if isinstance(struct[key], dict):
                 if type(struct[key]) is dict:
                     if new_path in self._i18n_namespace:
                         doc[key] = i18nDotedDict(doc.get(key, {}), self)
                     else:
                         doc[key] = DotedDict(doc.get(key, {}), warning=self.dot_notation_warning)
         #
         # if the value is a dict, we have a another structure to validate
         #
         if isinstance(struct[key], dict) and type(key) is not type:
             self.__generate_doted_dict(doc[key], struct[key], new_path)
Example #4
0
 def __generate_doted_dict(self, doc, struct, path=""):
     for key in struct:
         #
         # Automatique generate the skeleton with NoneType
         #
         if type(key) is type:
             new_key = "$%s" % key.__name__
         else:
             new_key = key
         new_path = ".".join([path, new_key]).strip('.')
         if type(key) is not type:  # and key not in doc:
             if isinstance(struct[key], dict):
                 if type(struct[key]) is dict:
                     if new_path in self._i18n_namespace:
                         doc[key] = i18nDotedDict(doc.get(key, {}), self)
                     else:
                         doc[key] = DotedDict(doc.get(key, {}), warning=self.dot_notation_warning)
         #
         # if the value is a dict, we have a another structure to validate
         #
         if isinstance(struct[key], dict) and type(key) is not type:
             self.__generate_doted_dict(doc[key], struct[key], new_path)