def load_schemas(self):
schemas = {}
for root, dirnames, filenames in os.walk(self.dir):
for file in filenames:
if file.endswith('.py'):
path = os.path.join(root, file)
module = imp.load_source(root, path)
for each in dir(module):
attr = getattr(module, each)
if isinstance(attr, Schema):
name = path[:-3].replace(self.dir, '').split('/')[1:]
schema_name = '.'.join(name + [each])
schemas[schema_name] = attr
self.schemas = schemas
评论列表
文章目录