Beispiel #1
0
 def build_tree(self, tree, path):
     """
     Build tree from schemas
     :param tree: _tree.Tree
     :param path: os.path
     """
     for elem_name in os.listdir(path):
         if elem_name.endswith('.json'):
             with io.open(os.path.join(path, elem_name),
                          encoding='utf-8') as f:
                 schema_json = json.load(f)
                 reg_group = VERSION_RE.search(elem_name).groupdict()
                 self._store[schema_json['id']] = schema_json
                 resolver = RefResolver(schema_json['id'], schema_json)
                 resolver.store = self._store
                 tree.versions[reg_group['version']] = Draft4Validator(
                     schema_json, resolver=resolver)
         else:
             if os.path.isdir(os.path.join(path, elem_name)):
                 child = Tree(index=elem_name)
                 tree.children.append(child)
                 self.build_tree(child, os.path.join(path, elem_name))