def parse_fields(self, optional=method_info.get('optional', False), help_callback=method_info.get('help_callback', None), callback_args=method_info.get('callback_args', None), callback_options=method_info.get( 'callback_options', None)): facade = False if method_info.get('data', None): facade = model_index.Model(method_info['data']).facade self.parse_fields(facade, method_base_name, optional=optional, help_callback=help_callback, callback_args=callback_args, callback_options=callback_options)
def _create_command_mixin(mixin): schema_info = {} if 'meta' in mixin.spec: for name, info in mixin.spec['meta'].items(): schema_info[name] = {} if 'data' in info and info['data'] is not None: schema_info[name]['data'] = info['data'] schema_info[name]['model'] = model_index.Model(info['data']) if 'provider' in info: schema_info[name]['provider'] = info['provider'] if 'provider_config' in info: schema_info[name]['provider_config'] = info['provider_config'] if 'name_default' in info: schema_info[name]['name_default'] = info['name_default'] if 'default' in info: schema_info[name]['default'] = info['default'] mixin.init({'schema': schema_info}) _get_command_methods(mixin) klass = mixin.create() def __init__(self, *args, **kwargs): super(klass, self).__init__(*args, **kwargs) for name, info in schema_info.items(): if 'model' in info: priority = 50 if 'priority' in mixin.spec['meta'][name]: priority = mixin.spec['meta'][name]['priority'] self.facade_index["{:02d}_{}".format( priority, name)] = self.facade(info['model'].facade) if 'meta' in mixin.spec: klass.__init__ = __init__ return klass
def generate_data_structures(self): logger.info("* Generating data mixins") for name, spec in self.spec.get('data_mixins', {}).items(): logger.info(" > {}".format(name)) self._model_mixins[name] = model_index.ModelMixin(name) logger.info(" - {}".format(self._model_mixins[name])) logger.info(" - {}".format( self._model_mixins[name].facade_class)) logger.info("* Generating base data models") for name, spec in self.spec.get('data_base', {}).items(): logger.info(" > {}".format(name)) self._base_models[name] = model_index.BaseModel(name) logger.info(" - {}".format(self._base_models[name])) logger.info(" - {}".format( self._base_models[name].facade_class)) logger.info("* Generating data models") for name, spec in self.spec.get('data', {}).items(): logger.info(" > {}".format(name)) self._models[name] = model_index.Model(name, True) logger.info(" - {}".format(self._models[name])) logger.info(" - {}".format(self._models[name].facade_class))