def __init__(self, parent, table): TemplateBase.__init__(self, parent) self.__table = table self.__columns = [] self.__primaryKey = '' self.__viewSort = None self.__viewSize = None self.__defaultViewSize = 10 self.__inports = SourceImport() if C_NAME not in self.__table: raise MissingAttribute(C_TABLE, C_NAME) if C_COLUMNS not in self.__table: raise MissingAttribute(C_TABLE, C_COLUMNS) for col in self.__table[C_COLUMNS]: column = TemplateColumn(self, self.name, **col) self.__columns.append(column) if column.isPrimaryKey(): self.__primaryKey = column.name if C_VIEW_SORT in table: self.__viewSort = SortInfo(table[C_VIEW_SORT]) if C_VIEW_SIZE in table: if type(table[C_VIEW_SIZE]) in (int, str): self.__viewSize = table[C_VIEW_SIZE] else: raise InvalidViewSize() return
def __init__(self, parent, cfg): TemplateBase.__init__(self, parent) self.__config = [] for i in cfg: self.__config.append(AngularModule(self, **i)) return
def __init__( self, parent, **cfg ): TemplateBase.__init__( self, parent ) self.__config = cfg # if C_CLASS not in self.__config: # raise MissingAttribute( C_TABLE, C_CLASS ) return
def __init__(self, obj): TemplateBase.__init__(self, None) self.__object = obj self.__module = None self.__class = None if obj is not None and '.' in obj: self.__module, self.__class = obj.rsplit('.', 1) return
def __init__(self, default_filename, default_class, default_module=None, **cfg): TemplateBase.__init__(self, None) self.__filename = default_filename self.__class = default_class self.__module = default_module or default_class self.__config = cfg return
def __init__( self, parent, **cfg ): TemplateBase.__init__( self, parent ) self.__components = TypeComponents() self.__cfg = cfg if C_SERVICE in cfg: self.__service = TemplateService( **cfg[ C_SERVICE ] ) else: self.__service = None return
def __init__( self, cfg ): TemplateBase.__init__( self, None ) self.__config = cfg.get( C_REFERENCES, {} ) tmp = self.__config[ C_APP_MODULE ] if C_APP_MODULE in self.__config else { } self.__main = TemplateAngularModule( 'app.module.ts', 'AppModule', **tmp ) tmp = self.__config[ C_APP_ROUTING ] if C_APP_ROUTING in self.__config else { } self.__rout = TemplateAngularModule( 'app.routing.module.ts', 'AppRoutingModule', **tmp ) return
def __init__(self, data): TemplateBase.__init__(self, None) self.__field = data[C_FIELD] self.__direction = C_ASCENDING if C_DIRECTION in data: if data[C_DIRECTION] in C_DIRECTIONS: self.__direction = data[C_DIRECTION] else: raise Exception( "Sorting order must be one of the following: {}".format( ', '.join(C_DIRECTIONS))) return
def __init__(self, key, cfg): TemplateBase.__init__(self, None) self.__config = cfg[key] self.__item = cfg[key] self.__submenu = None if C_CAPTION not in self.__config: raise MissingAttribute(C_MENU, C_CAPTION) if C_ROUTE not in self.__config and C_MENU not in self.__config: raise MissingAttribute(C_MENU, 'route OR menu') if C_MENU in self.__item: self.__submenu = TemplateMenuItem(C_MENU, self.__item) return
def __init__(self, **cfg): TemplateBase.__init__(self, None) self.__config = cfg if C_NAME not in self.__config: raise MissingAttribute(C_SERVICE, C_NAME) if C_VALUE not in self.__config: raise MissingAttribute(C_SERVICE, C_VALUE) if C_LABEL not in self.__config: raise MissingAttribute(C_SERVICE, C_LABEL) if C_CLASS not in self.__config: raise MissingAttribute(C_SERVICE, C_CLASS) return
def __init__(self, parent, objname, cfg): TemplateBase.__init__(self, parent) self.__name = objname self.__actions = [] self.__cfg = cfg for action in cfg: self.__actions.append( TemplateAction(self.parent, objname, **action)) if not self.has(C_NEW): self.__actions.append(DEFAULT_NEW_ACTION.clone(objname)) if not self.has(C_EDIT): self.__actions.append(DEFAULT_EDIT_ACTION.clone(objname)) if not self.has(C_DELETE): self.__actions.append(DEFAULT_DELETE_ACTION.clone(objname)) return
def __init__(self, parent, cfg): TemplateBase.__init__(self, parent) self.__config = cfg if C_NAME not in self.__config: raise MissingAttribute(C_OBJECT, C_NAME) if C_URI not in self.__config: raise MissingAttribute(C_OBJECT, C_URI) if C_TABLE not in self.__config: raise MissingAttribute(C_OBJECT, C_TABLE) self.__menu = TemplateMenuItem(C_MENU, cfg) if C_MENU in cfg else None self.__actions = TemplateActions(self, self.name, self.__config.get(C_ACTIONS, [])) self.__table = TemplateTable(self, self.__config.get(C_TABLE, {})) self.__extra = TemplateExtra(self, self.__config.get(C_EXTRA, {})) self.__mixin = TemplateMixin(self, self.__config.get(C_MIXIN, {})) return
def __init__(self, parent, cfg, source, common=None): TemplateBase.__init__(self, parent) self.__type = source self.__config = cfg.get(self.platform, cfg).get(source, {}) rootPath = os.environ.get('GENCRUD_TEMPLATES', None) if rootPath is None: rootPath = os.environ.get('GENCRUD', None) if rootPath is not None: rootpath = os.path.join(rootPath, 'templates') else: rootpath = os.path.join(os.path.dirname(__file__), '..', source) self.__base = self.__config.get(C_BASE, os.path.abspath(rootpath)) if common is not None: self.__common = LocationTemplateClass(self, self.__config, common) else: self.__common = None return
def __init__(self, cfg) -> None: TemplateBase.__init__(self, None) self.__config = cfg.get(C_OPTIONS, {}) return
def __init__(self, parent, relation): TemplateBase.__init__(self, parent) self.__relation = relation return
def __init__( self, tp, cfg ): TemplateBase.__init__( self, None ) self.__config = cfg self.__key = tp self.__source = self.__config.get( self.platform, self.__config ).get( C_SOURCE, {} ) return
def __init__(self, parent, obj_name, **cfg): TemplateBase.__init__(self, parent) self.__name = obj_name self.__cfg = cfg return
def __init__(self, parent, cfg): TemplateBase.__init__(self, parent) self.__config = cfg return
def __init__(self, parent, table_name, **cfg): """ field: D_ROLE_ID INT AUTO_NUMBER PRIMARY KEY :param cfg: :return: """ TemplateBase.__init__(self, parent) self.__tableName = table_name self.__config = cfg self.__field = '' self.__sqlType = '' self.__length = 0 self.__relationShip = None self.__choice = None self.__attrs = [] self.__ui = None self.__leadIn = [] self.__dbField = '' self.unique = False if C_FIELD not in self.__config: raise MissingAttribute(C_TABLE, C_FIELD) field_data = cfg.get(C_FIELD, '') tokens = [x for x in word_tokenize(field_data)] self.__dbField = self.__field = tokens[0] self.__sqlType = tokens[1] if self.__sqlType not in self.TS_TYPES_FROM_SQL: raise InvalidSetting(C_FIELD, self.__tableName, self.__field, expected=self.TS_TYPES_FROM_SQL) offset = 2 if offset < len(tokens) and tokens[offset] == '(': offset += 1 self.__length = int(tokens[offset]) offset += 2 # attributes # NOT NULL # DEFAULT <value> # PRIMARY KEY # AUTO NUMBER # FOREIGN KEY <reference> while offset < len(tokens): if tokens[offset] == 'NULL': self.__attrs.append('NULL') elif tokens[offset] == 'NOT': offset += 1 if tokens[offset] == 'NULL': self.__attrs.append('NOT NULL') else: raise InvalidSetting(C_FIELD, 'attr: "NOT ' + tokens[offset] + '"', self.__field) elif tokens[offset] == 'DEFAULT': self.__attrs.append('DEFAULT {0}'.format(tokens[offset + 1])) elif tokens[offset] == 'PRIMARY': self.__attrs.append('PRIMARY KEY') elif tokens[offset] == 'AUTO': self.__attrs.append('AUTO NUMBER') elif tokens[offset] == 'FOREIGN': self.__attrs.append('FOREIGN KEY {0}'.format(tokens[offset + 2])) offset += 1 else: raise InvalidSetting(C_FIELD, 'attr: "' + tokens[offset] + '"', self.__field) offset += 2 if C_UI in cfg and type(cfg[C_UI]) is dict: self.__ui = TemplateUi(self, **cfg.get(C_UI, {})) self.__relationShip = TemplateRelation( self, **self.__config.get(C_RELATION_SHIP, {})) self.__listview = TemplateListView( self, **self.__config.get(C_LIST_VIEW, {})) if root.config.options.ignoreCaseDbIds: self.__dbField = self.__dbField.lower() if C_INDEX in cfg: logger.warning( "'index' in the 'field' defintion is OBSOLETE, use 'listview' -> 'index' +" " in the 'field' definition.") return
def __init__(self, parent, cfg): TemplateBase.__init__(self, parent) self.__config = cfg self.__moduleTs = InjectionBlockTemplate( self, self.__config.get('module.ts', None)) return
def __init__(self, field, **cfg): TemplateBase.__init__(self, None) self.__field = field self.__cfg = cfg return
def __init__( self, parent, **cfg ): TemplateBase.__init__( self, parent ) self.__cfg = cfg return