• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pkg.resource_filename函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中uliweb.utils.common.pkg.resource_filename函数的典型用法代码示例。如果您正苦于以下问题:Python resource_filename函数的具体用法?Python resource_filename怎么用?Python resource_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resource_filename函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: handle

    def handle(self, options, global_options, *args):
        from uliweb.utils.pyini import Ini
        from uliweb.utils.common import pkg
        from uliweb.contrib.template.tags import find
        from uliweb.contrib.staticfiles import url_for_static
        from uliweb import json_dumps

        if not options.dest and not options.app:
            print 'Error: Please use -d to specify output app'
            sys.exit(1)

        app = self.get_application(global_options)

        if options.app:
            settings_file = pkg.resource_filename(options.app, 'settings.ini')
            x = Ini(settings_file)

        else:
            x = app.settings

        if options.dest:
            filename = pkg.resource_filename(options.dest, '/static/jsmodules.js')
        else:
            filename = pkg.resource_filename(options.app, '/static/jsmodules.js')

        d = {}
        for name in x.get('TEMPLATE_USE', {}).keys():
            s = find(name)
            m = s[0] + s[1]
            d[name] = [url_for_static(i) for i in m if not i.startswith('<!--')]

        print 'jsmodules.js is saved in {} please check'.format(filename)
        with open(filename, 'wb') as f:
            f.write('var jsmodules = ')
            f.write(json_dumps(d))
开发者ID:uliwebext,项目名称:uliweb-ui,代码行数:35,代码来源:commands.py


示例2: process

    def process(self, theme_name, data, options, global_options, args):
        from uliweb.utils.common import pkg, copy_dir
        import shutil
        from uliweb.utils.pyini import Ini
        
        #if there is no apps/appname then create files in current directory
        
        path = os.path.join(global_options.apps_dir, data['appname'])
        if not os.path.exists(path):
            path = '.'
            
        gpath = pkg.resource_filename('uliweb.contrib.generic', 'template_files/%s' % theme_name)
        
        def render(fpath, dst, df):
            text = template_file(fpath, data).replace('\r\n', '\n')
            open(df, 'w').write(text)
            return True
        
        #copy template files
        copy_dir(os.path.join(gpath, 'templates'), os.path.join(path, 'templates', data['classname']),
            processor=render)

        #process config.ini
        src_config = os.path.join(gpath, 'config.ini')
        dst_config = os.path.join(path, 'config.ini')
        if os.path.exists(dst_config):
            dst = Ini(dst_config)
            src = Ini(src_config)
            for x in src.DEPENDS.REQUIRED_APPS:
                if x not in dst.DEPENDS.REQUIRED_APPS:
                    dst.DEPENDS.REQUIRED_APPS.append(x)
            dst.save()
        else:
            shutil.copy2(os.path.join(gpath, 'config.ini'), path)
            
        cpath = pkg.resource_filename('uliweb.contrib.generic', 'template_files/common')

        #check if layout is existed, if not then create it
        layout_file = os.path.join(path, 'templates', data['layout'])
        if not os.path.exists(layout_file):
            self.copy_template(os.path.join(cpath, 'layout.html'), data, layout_file)

        #copy views file
        self.copy_view(os.path.join(cpath, 'views.py.tmpl'), data, 
            os.path.join(path, data['viewfile']), options.replace)
        
        #copy add, edit, view
        dpath = os.path.join(path, 'templates', data['classname'])
        if data['addview_popup']:
            self.copy_template(os.path.join(cpath, 'ajax_add.html'), data, os.path.join(dpath, 'add.html'))
        else:
            self.copy_template(os.path.join(cpath, 'add.html'), data, os.path.join(dpath, 'add.html')) 
        if data['editview_popup']:
            self.copy_template(os.path.join(cpath, 'ajax_edit.html'), data, os.path.join(dpath, 'edit.html')) 
        else:
            self.copy_template(os.path.join(cpath, 'edit.html'), data, os.path.join(dpath, 'edit.html')) 
        self.copy_template(os.path.join(cpath, 'view.html'), data, os.path.join(dpath, 'view.html')) 
        
开发者ID:28sui,项目名称:uliweb,代码行数:57,代码来源:commands.py


示例3: handle

 def handle(self, options, global_options, *args):
     from uliweb.utils.common import check_apps_dir
     opts = {'verbose':global_options.verbose, 'template':options.template,
         'exact':options.exact}
     if options.project:
         check_apps_dir(global_options.apps_dir)
         app = self.get_application(global_options)
         
         _process(global_options.apps_dir, options.locale, opts, output_dir=global_options.project)
     elif options.apps or args:
         check_apps_dir(global_options.apps_dir)
         
         app = self.get_application(global_options)
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if global_options.verbose:
                 print 'Processing... app=>[%s] path=>[%s]' % (appname, path)
             _process(path, options.locale, opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
开发者ID:08haozi,项目名称:uliweb,代码行数:28,代码来源:i18ntool.py


示例4: handle

    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir
        from uliweb.utils.common import pkg

        _types = []
        support_dirs = {}
        app_dirs = [
            os.path.join(SimpleFrame.get_app_dir(appname), "template_files/support")
            for appname in self.get_apps(global_options)
        ]
        for path in [pkg.resource_filename("uliweb", "template_files/support/")] + app_dirs:
            if os.path.exists(path):
                for f in os.listdir(path):
                    _path = os.path.join(path, f)
                    if os.path.isdir(_path) and not f.startswith("."):
                        _name = f
                        _types.append(_name)
                        support_dirs[_name] = _path

        support_type = args[0] if args else ""
        while not support_type in _types and support_type != "quit":
            print "Supported types:\n"
            print "    " + "\n    ".join(sorted(_types))
            print
            support_type = raw_input("Please enter support type[quit to exit]:")

        if support_type != "quit":
            src_dir = support_dirs[support_type]
            copy_dir(src_dir, ".", verbose=global_options.verbose)
开发者ID:08haozi,项目名称:uliweb,代码行数:29,代码来源:manage.py


示例5: _loader

 def _loader(filename):
     from werkzeug.exceptions import Forbidden, NotFound
     from uliweb.utils.common import pkg
     
     app = self.app
     f = None
     if dir:
         fname = os.path.normpath(os.path.join(dir, filename)).replace('\\', '/')
         if not fname.startswith(dir):
             return Forbidden("You can only visit the files under static directory."), None
         if os.path.exists(fname):
             f = fname
     else:
         for p in reversed(app.apps):
             fname = os.path.normpath(os.path.join('static', filename)).replace('\\', '/')
             if not fname.startswith('static/'):
                 return Forbidden("You can only visit the files under static directory."), None
             
             ff = pkg.resource_filename(p, fname)
             if os.path.exists(ff):
                 f = ff
                 break
     
     if f:
         return f, self._opener(f)
     
     return NotFound("Can't found the file %s" % filename), None
开发者ID:tangjn,项目名称:uliweb,代码行数:27,代码来源:wsgi_staticfiles.py


示例6: handle

    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir
        from uliweb.utils.common import pkg
        
        _types = []
        support_dirs = {}
        app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/support') for appname in self.get_apps(global_options)]
        for path in [pkg.resource_filename('uliweb', 'template_files/support/')] + app_dirs:
            if os.path.exists(path):
                for f in os.listdir(path):
                    _path = os.path.join(path, f)
                    if os.path.isdir(_path) and not f.startswith('.'):
                        _name = f
                        _types.append(_name)
                        support_dirs[_name] = _path

        support_type = args[0] if args else ''
        while not support_type in _types and support_type != 'quit':
            print 'Supported types:\n'
            print '    ' + '\n    '.join(sorted(_types))
            print
            support_type = raw_input('Please enter support type[quit to exit]:')
        
        if support_type != 'quit':
            src_dir = support_dirs[support_type]
            copy_dir(src_dir, '.', verbose=global_options.verbose)
开发者ID:dtld,项目名称:uliweb,代码行数:26,代码来源:manage.py


示例7: get_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
开发者ID:lssebastian,项目名称:uliweb,代码行数:31,代码来源:SimpleFrame.py


示例8: develop_app_conf

def develop_app_conf():
    module = request.GET['module']
    app_path = pkg.resource_filename(module, '')
    
    form = '<h3>Nothing need to configure!</h3>'
    message = ''
    if is_pyfile_exist(app_path, 'conf'):
        try:
            mod = __import__(module + '.conf', {}, {}, [''])
            f = getattr(mod, 'ManageForm', None)
            if f:
                form = f(action=url_for(develop_app_conf)+'?module=%s' % module, method='post')
                if request.method == 'POST':
                    ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
                    default_ini = Ini(os.path.join(app_path, 'settings.ini'))
                    r = form.validate(request.POST)
                    if r:
                        flag = form_to_ini(form, ini, default_ini)
                        if flag:
                            message = '<div class="note">Changes have been saved!</div>'
                            ini.save()
                        else:
                            message = '<div class="important">There are no changes.</div>'
                    else:
                        message = '<div class="warning">There are some errors.</div>'
                elif request.method == 'GET':
                    ini = Ini()
                    ini_file = os.path.join(app_path, 'settings.ini')
                    if os.path.exists(ini_file):
                        ini.read(ini_file)
                    ini.read(os.path.join(application.apps_dir, 'settings.ini'))
                    ini_to_form(form, ini)
        
        except ImportError, e:
            log.exception(e)
开发者ID:datakungfu,项目名称:uliweb,代码行数:35,代码来源:views.py


示例9: collect_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(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
开发者ID:biluo1989,项目名称:uliweb,代码行数:56,代码来源:SimpleFrame.py


示例10: handle

 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs, pkg
     from uliweb.core.template import template_file
     
     extract_dirs('uliweb.contrib.orm', 'templates/alembic', '.', verbose=global_options.verbose, replace=False)
     engine_string = get_engine(options, global_options)
     ini_file = os.path.join(pkg.resource_filename('uliweb.contrib.orm', 'templates/alembic/alembic.ini'))
     text = template_file(ini_file, {'CONNECTION':engine_string})
     with open(os.path.join(global_options.project, 'alembic.ini'), 'w') as f:
         f.write(text)
开发者ID:bobgao,项目名称:uliweb,代码行数:10,代码来源:commands.py


示例11: collect_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
开发者ID:yonglehou,项目名称:uliweb,代码行数:53,代码来源:SimpleFrame.py


示例12: init

    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, '..'))
        
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules['settings'])

        self.debug = settings.GLOBAL.get('DEBUG', False)

        #process global_objects
        self.install_global_objects()
        
        #process binds
        self.install_binds()
        
        dispatch.call(self, 'after_init_settings')
        
        Dispatcher.settings = settings
        
        #process domains
        self.process_domains(settings)
        
        #setup log
        self.set_log()
        
        #set app rules
        rules.set_app_rules(dict(settings.get('URL', {})))
        rules.set_urlroute_rules(dict(settings.get('URL_ROUTE', {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_loader = self.install_template_loader(Dispatcher.template_dirs)

        #begin to start apps
        self.install_apps()
        dispatch.call(self, 'after_init_apps')
        #process views
        self.install_views(self.modules['views'])
        #process exposes
        self.install_exposes()
        #process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        dispatch.call(self, 'prepare_default_env', Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename('uliweb.core', 'default.html')
        
        Dispatcher.installed = True
开发者ID:hb44,项目名称:uliweb,代码行数:51,代码来源:SimpleFrame.py


示例13: init

    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, ".."))
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, "apps"))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules["settings"])

        # process global_objects
        self.install_global_objects()

        # process binds
        self.install_binds()

        dispatch.call(self, "after_init_settings")

        Dispatcher.settings = settings

        # process domains
        self.process_domains(settings)

        # setup log
        self.set_log()

        # set app rules
        rules.set_app_rules(dict(settings.get("URL", {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_processors = {}
        self.install_template_processors()

        # begin to start apps
        self.install_apps()
        dispatch.call(self, "after_init_apps")
        # process views
        self.install_views(self.modules["views"])
        # process exposes
        self.install_exposes()
        # process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        self.debug = settings.GLOBAL.get("DEBUG", False)
        dispatch.call(self, "prepare_default_env", Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename("uliweb.core", "default.html")

        Dispatcher.installed = True
开发者ID:biluo1989,项目名称:uliweb,代码行数:49,代码来源:SimpleFrame.py


示例14: get_file

 def get_file(self, filename, dir='static'):
     """
     get_file will search from apps directory
     """
     if os.path.exists(filename):
         return filename
     dirs = self.apps
     if dir:
         fname = os.path.join(dir, filename)
     else:
         fname = filename
     for d in reversed(dirs):
         path = pkg.resource_filename(d, fname)
         if os.path.exists(path):
             return path
     return None
开发者ID:lssebastian,项目名称:uliweb,代码行数:16,代码来源:SimpleFrame.py


示例15: collect_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):
            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
开发者ID:datakungfu,项目名称:uliweb,代码行数:47,代码来源:SimpleFrame.py


示例16: startup_installed

def startup_installed(sender):
    """
    @LANGUAGE_CODE
    """
    import os
    from uliweb.core.SimpleFrame import get_app_dir
    from uliweb.i18n import install, set_default_language
    from uliweb.utils.common import pkg, expand_path
    
    path = pkg.resource_filename('uliweb', '')
    _dirs = []
    for d in sender.settings.get_var('I18N/LOCALE_DIRS', []):
        _dirs.append(expand_path(d))
    localedir = ([os.path.normpath(sender.apps_dir + '/..')] + 
        [get_app_dir(appname) for appname in sender.apps] + [path] + _dirs)
    install('uliweb', localedir)
    set_default_language(sender.settings.I18N.LANGUAGE_CODE)
开发者ID:08haozi,项目名称:uliweb,代码行数:17,代码来源:__init__.py


示例17: handle

    def handle(self, options, global_options, *args):
        from uliweb.utils.common import pkg
        from uliweb import functions
        from uliweb.core.template import template_file
        from uliweb.orm import true
        import time

        self.get_application(global_options)

        Recorder = functions.get_model('uliwebrecorder')

        if args:
            if os.path.exists(args[0]):
                message = "Ths file %s is already exists, do you want to overwrite it?" % args[0]
                ans = 'Y' if global_options.yes else get_answer(message)
                if ans != 'Y':
                    return

            out = open(args[0], 'w')
            relpath = os.path.normpath(os.path.relpath(os.path.dirname(args[0]) or './', '.')).replace('\\', '/')
        else:
            out = sys.stdout
            relpath = '.'

        condition = true()
        if options.begin_time:
            condition = (Recorder.c.begin_datetime >= options.begin_time) & condition
        if options.id:
            condition = (Recorder.c.id >= int(options.id)) & condition

        path = pkg.resource_filename('uliweb.contrib.recorder', 'template_files')
        tplfile = os.path.join(path, options.template).replace('\\', '/')
        row_tplfile = os.path.join(path, options.template_row).replace('\\', '/')

        out.write('#coding=utf8\n')
        if global_options.verbose:
            print '#recorder template is "%s"' % tplfile
            print '#recorder row template is "%s"' % row_tplfile

        begin = time.time()
        rows = []
        for row in Recorder.filter(condition):
            rows.append(template_file(row_tplfile, {'row':row}).rstrip())

        out.write(template_file(tplfile, {'project_dir':relpath, 'rows':rows}))
        out.write('\n#total %d records output, time used %ds\n' % (len(rows), time.time()-begin))
开发者ID:limodou,项目名称:uliweb,代码行数:46,代码来源:subcommands.py


示例18: get_app_dir

def get_app_dir(app):
    """
    Get an app's directory
    """
    path = __app_dirs__.get(app)
    if path is not None:
        return path
    else:
        p = app.split('.')
        try:
            path = pkg.resource_filename(p[0], '')
        except ImportError, e:
            log.exception(e)
            path = ''
        if len(p) > 1:
            path = os.path.join(path, *p[1:])
        
        __app_dirs__[app] = path
        return path
开发者ID:datakungfu,项目名称:uliweb,代码行数:19,代码来源:SimpleFrame.py


示例19: develop_build

def develop_build():
    from uliweb.utils.common import pkg
    
    import uliweb.core.SimpleFrame as sf
    app_apps = sf.get_apps(application.apps_dir)
    
    contrib_path = pkg.resource_filename('uliweb.contrib', '')
    apps_dirs = [(application.apps_dir, ''), (contrib_path, 'uliweb.contrib')]
    
    #using entry point to find installed apps
    try:
        from pkg_resources import iter_entry_points
    except:
        iter_entry_points = None
    if iter_entry_points:
        #process apps group
        for p in iter_entry_points('uliweb_apps'):
            apps_dirs.append((os.path.join(p.dist.location, p.module_name), p.module_name))
            
    catalogs, apps = get_apps(application, apps_dirs, app_apps)
    
    if iter_entry_points:
        #proces single app
        for p in iter_entry_points('uliweb_app'):
            _get_app(os.path.join(p.dist.location, p.module_name), p.module_name, apps, catalogs, app_apps)
    
    from forms import GenericForm
    
    f = GenericForm(method="post")
    
    if request.method == 'GET':
#        ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
        ini_to_form(f, application.settings)
        
    else:
        r = f.validate(request.params)
        if r:
            ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
            flag = form_to_ini(f, ini, application.settings)
            if flag:
                ini.save()
        
    return {'catalogs':catalogs, 'generic_form':f}
开发者ID:datakungfu,项目名称:uliweb,代码行数:43,代码来源:views.py


示例20: handle

 def handle(self, options, global_options, *args):
     opts = {'verbose':global_options.verbose}
     if options.project:
         _process(global_options.project, options.locale, opts)
     elif options.apps or args:
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if not path.startswith(apps_dir):
                 continue
             _process(SimpleFrame.get_app_dir(appname), options.locale, opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
开发者ID:datakungfu,项目名称:uliweb,代码行数:20,代码来源:i18ntool.py



注:本文中的uliweb.utils.common.pkg.resource_filename函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python date.now函数代码示例发布时间:2022-05-27
下一篇:
Python log.exception函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap