def collect_settings(project_dir, include_apps=None, settings_file='settings.ini', local_settings_file='local_settings.ini'): apps_dir = os.path.join(project_dir, 'apps') apps = get_apps(apps_dir, None, settings_file=settings_file, local_settings_file=local_settings_file) settings_file = os.path.join(apps_dir, settings_file) local_settings_file = os.path.join(apps_dir, local_settings_file) settings = [] inifile = pkg.resource_filename('uliweb.core', 'default_settings.ini') settings.insert(0, inifile) for p in apps: path = get_app_dir(p) #deal with settings inifile = os.path.join(get_app_dir(p), 'settings.ini') if os.path.exists(inifile): settings.append(inifile) if os.path.exists(settings_file): settings.append(settings_file) if os.path.exists(local_settings_file): settings.append(local_settings_file) return settings
def get_settings(project_dir, include_apps=None, settings_file='settings.ini', local_settings_file='local_settings.ini', default_settings=None): apps_dir = os.path.join(project_dir, 'apps') apps = get_apps(apps_dir, settings_file=settings_file, local_settings_file=local_settings_file) settings = [] inifile = pkg.resource_filename('uliweb.core', 'default_settings.ini') settings.insert(0, inifile) for p in apps: path = get_app_dir(p) #deal with settings inifile =os.path.join(get_app_dir(p), 'settings.ini') if os.path.exists(inifile): settings.append(inifile) set_ini = os.path.join(apps_dir, settings_file) if os.path.exists(set_ini): settings.append(set_ini) local_set_ini = os.path.join(apps_dir, local_settings_file) if os.path.exists(local_set_ini): settings.append(local_set_ini) x = pyini.Ini() for v in settings: x.read(v) x.update(default_settings or {}) #process FILESYSTEM_ENCODING if not x.GLOBAL.FILESYSTEM_ENCODING: x.GLOBAL.FILESYSTEM_ENCODING = sys.getfilesystemencoding() or x.GLOBAL.DEFAULT_ENCODING return x
def collect_modules(self, check_view=True): modules = {} views = set() settings = [] inifile = pkg.resource_filename("uliweb.core", "default_settings.ini") settings.insert(0, inifile) def enum_views(views_path, appname, subfolder=None, pattern=None): if not os.path.exists(views_path): log.error("Can't found the app %s path, please check if the path is right" % appname) return for f in os.listdir(views_path): fname, ext = os.path.splitext(f) if ( os.path.isfile(os.path.join(views_path, f)) and ext in [".py", ".pyc", ".pyo"] and fname != "__init__" ): if pattern: import fnmatch if not fnmatch.fnmatch(f, pattern): continue if subfolder: views.add(".".join([appname, subfolder, fname])) else: views.add(".".join([appname, fname])) for p in self.apps: path = get_app_dir(p) # deal with views if check_view: views_path = os.path.join(path, "views") if os.path.exists(views_path) and os.path.isdir(views_path): enum_views(views_path, p, "views") else: enum_views(path, p, pattern="views*") # deal with settings inifile = os.path.join(get_app_dir(p), "settings.ini") if os.path.exists(inifile): settings.append(inifile) set_ini = os.path.join(self.apps_dir, self.settings_file) if os.path.exists(set_ini): settings.append(set_ini) local_set_ini = os.path.join(self.apps_dir, self.local_settings_file) if os.path.exists(local_set_ini): settings.append(local_set_ini) modules["views"] = list(views) modules["settings"] = settings return modules
def collect_modules(self, check_view=True): modules = {} views = set() settings = [] inifile = pkg.resource_filename('uliweb.core', 'default_settings.ini') settings.insert(0, ('', inifile)) def enum_views(views_path, appname, subfolder=None, pattern=None): if not os.path.exists(views_path): log.error( "Can't found the app %s path, please check if the path is right" % appname) return for f in os.listdir(views_path): fname, ext = os.path.splitext(f) if os.path.isfile(os.path.join(views_path, f)) and ext in [ '.py', '.pyc', '.pyo' ] and fname != '__init__': if pattern: import fnmatch if not fnmatch.fnmatch(f, pattern): continue if subfolder: views.add('.'.join([appname, subfolder, fname])) else: views.add('.'.join([appname, fname])) for p in self.apps: path = get_app_dir(p) #deal with views if check_view: views_path = os.path.join(path, 'views') if os.path.exists(views_path) and os.path.isdir(views_path): enum_views(views_path, p, 'views') else: enum_views(path, p, pattern='views*') #deal with settings inifile = os.path.join(get_app_dir(p), 'settings.ini') if os.path.exists(inifile): settings.append((p, inifile)) set_ini = os.path.join(self.apps_dir, self.settings_file) if os.path.exists(set_ini): settings.append(('', set_ini)) local_set_ini = os.path.join(self.apps_dir, self.local_settings_file) if os.path.exists(local_set_ini): settings.append(('', local_set_ini)) modules['views'] = list(views) modules['settings'] = settings return modules
def collect_modules(self, check_view=True): modules = {} views = [] settings = [] inifile = pkg.resource_filename('uliweb.core', 'default_settings.ini') settings.insert(0, ('', inifile)) def enum_views(views_path, appname, subfolder=None, pattern=None): if not os.path.exists(views_path): log.error("Can't found the app %s path, please check if the path is right" % appname) return for f in os.listdir(views_path): fname, ext = os.path.splitext(f) if os.path.isfile(os.path.join(views_path, f)) and ext in ['.py', '.pyc', '.pyo'] and fname!='__init__': if pattern: import fnmatch if not fnmatch.fnmatch(f, pattern): continue if subfolder: _view = '.'.join([appname, subfolder, fname]) else: _view = '.'.join([appname, fname]) if _view not in views: views.append(_view) for p in self.apps: path = get_app_dir(p) #deal with views if check_view: views_path = os.path.join(path, 'views') if os.path.exists(views_path) and os.path.isdir(views_path): enum_views(views_path, p, 'views') else: enum_views(path, p, pattern='views*') #deal with settings inifile =os.path.join(get_app_dir(p), 'settings.ini') if os.path.exists(inifile): settings.append((p, inifile)) set_ini = os.path.join(self.apps_dir, self.settings_file) if os.path.exists(set_ini): settings.append(('', set_ini)) local_set_ini = os.path.join(self.apps_dir, self.local_settings_file) if os.path.exists(local_set_ini): settings.append(('', local_set_ini)) modules['views'] = views modules['settings'] = settings return modules
def collect_settings(project_dir, include_apps=None, settings_file='settings.ini', local_settings_file='local_settings.ini'): apps_dir = os.path.join(project_dir, 'apps') apps = get_apps(apps_dir, None, settings_file=settings_file, local_settings_file=local_settings_file) settings_file = os.path.join(apps_dir, settings_file) local_settings_file = os.path.join(apps_dir, local_settings_file) settings = [] inifile = pkg.resource_filename('uliweb.core', 'default_settings.ini') settings.insert(0, inifile) for p in apps: path = get_app_dir(p) #deal with settings inifile =os.path.join(get_app_dir(p), 'settings.ini') if os.path.exists(inifile): settings.append(inifile) if os.path.exists(settings_file): settings.append(settings_file) if os.path.exists(local_settings_file): settings.append(local_settings_file) return settings