当前位置: 首页>>代码示例>>Python>>正文


Python Environment.append_path方法代码示例

本文整理汇总了Python中webassets.Environment.append_path方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.append_path方法的具体用法?Python Environment.append_path怎么用?Python Environment.append_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webassets.Environment的用法示例。


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

示例1: webassets_init

# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import append_path [as 别名]
def webassets_init():
    global env

    static_path = get_webassets_path()

    public = config.get(u'ckan.base_public_folder')

    public_folder = os.path.abspath(os.path.join(
        os.path.dirname(__file__), u'..', public))

    base_path = os.path.join(public_folder, u'base')

    env = Environment()
    env.directory = static_path
    env.debug = config.get(u'debug', False)
    env.url = u'/webassets/'

    env.append_path(base_path, u'/base/')

    logger.debug(u'Base path {0}'.format(base_path))
    create_library(u'vendor', os.path.join(
        base_path, u'vendor'))

    create_library(u'base', os.path.join(base_path, u'javascript'))

    create_library(u'datapreview', os.path.join(base_path, u'datapreview'))

    create_library(u'css', os.path.join(base_path, u'css'))
开发者ID:PublicaMundi,项目名称:ckan,代码行数:30,代码来源:webassets_tools.py

示例2: test_append_load_path

# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import append_path [as 别名]
    def test_append_load_path(self):
        env = Environment()
        assert env.load_path == []

        env.append_path('foo', '/foo')
        assert env.load_path == ['foo']
        assert env.url_mapping == {'foo': '/foo'}

        # Works without path
        env.append_path('bar')
        assert env.load_path == ['foo', 'bar']
        assert env.url_mapping == {'foo': '/foo'}
开发者ID:njoyce,项目名称:webassets,代码行数:14,代码来源:test_environment.py

示例3: WPBase

# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import append_path [as 别名]
class WPBase(OldObservable):
    """
    """
    _title = "Indico"

    # required user-specific "data packages"
    _userData = []

    def __init__( self, rh ):
        config = Config.getInstance()
        db_connected = DBMgr.getInstance().isConnected()

        self._rh = rh
        self._locTZ = ""

        self._asset_env = Environment(os.path.join(config.getHtdocsDir(), "static", "assets"), '/static/assets/')
        self._asset_env.config['PYSCSS_LOAD_PATHS'] = [os.path.join(config.getHtdocsDir(), 'sass', 'lib', 'compass')]
        self._asset_env.append_path(config.getHtdocsDir(), '/')

        if db_connected:
            debug = HelperMaKaCInfo.getMaKaCInfoInstance().isDebugActive()
        else:
            debug = False

        # This is done in order to avoid the problem sending the error report because the DB is not connected.
        if db_connected:
            info = HelperMaKaCInfo.getMaKaCInfoInstance()
            self._asset_env.debug = info.isDebugActive()

        self._dir = config.getTPLDir()
        self._asset_env.debug = debug

        if db_connected:
            css_file = config.getCssStylesheetName()
        else:
            css_file = 'Default.css'

        # register existing assets
        assets.register_all_js(self._asset_env)
        assets.register_all_css(self._asset_env, css_file)

        #store page specific CSS and JS
        self._extraCSS = []
        self._extraJS = []

    def _getBaseURL( self ):
        if self._rh._req.is_https() and Config.getInstance().getBaseSecureURL():
            baseurl = Config.getInstance().getBaseSecureURL()
        else:
            baseurl = Config.getInstance().getBaseURL()
        return baseurl

    def _getTitle( self ):
        return self._title

    def _setTitle( self, newTitle ):
        self._title = newTitle.strip()

    def getCSSFiles(self):
        return self._asset_env['base_css'].urls() + \
            self._asset_env['base_sass'].urls()

    def _getJavaScriptInclude(self, scriptPath):
        return '<script src="'+ scriptPath +'" type="text/javascript"></script>\n'

    def getJSFiles(self):
        return self._asset_env['base_js'].urls()

    def _includeJSPackage(self, pkg_names):
        if not isinstance(pkg_names, list):
            pkg_names = [pkg_names]

        urls = []
        for pkg_name in pkg_names:
            urls += self._asset_env['indico_' + pkg_name.lower()].urls()
        return urls

    def _getJavaScriptUserData(self):
        """
        Returns structured data that should be passed on to the client side
        but depends on user data (can't be in vars.js.tpl)
        """

        user = self._getAW().getUser();

        from MaKaC.webinterface.asyndico import UserDataFactory

        userData = dict((packageName,
                         UserDataFactory(user).build(packageName))
                        for packageName in self._userData)

        return userData

    def _getHeadContent( self ):
        """
        Returns _additional_ content between <head></head> tags.
        Please note that <title>, <meta> and standard CSS are always included.

        Override this method to add your own, page-specific loading of
        JavaScript, CSS and other legal content for HTML <head> tag.
#.........这里部分代码省略.........
开发者ID:iason-andr,项目名称:indico,代码行数:103,代码来源:base.py

示例4: skip

# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import append_path [as 别名]
import clld


def skip(_in, out, **kw):
    """filter to skip content of assets which are fetched from CDN in production.
    """
    out.write('')  # pragma: no cover

environment = Environment(
    path(clld.__file__).dirname().joinpath('web', 'static'),
    '/clld:web/static/',
    manifest='json:',
    auto_build=False)

environment.append_path(
    path(clld.__file__).dirname().joinpath('web', 'static'), url='/clld:web/static/')

bundles = {
    'js': [
        Bundle(
            'js/jquery-1.8.2.js',
            'js/leaflet-src.js',
            filters=(skip,)),
        'js/bootstrap.min.js',
        'js/jquery.dataTables.min.js',
        'js/oms.min.js',
        Bundle(
            'js/bootstrapx-clickover.js',
            'js/tree.jquery.js',
            'js/leaflet-providers.js',
            'js/leaflet.label.js',
开发者ID:FieldDB,项目名称:clld,代码行数:33,代码来源:assets.py

示例5: load_environment

# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import append_path [as 别名]
    def load_environment(self):
        """Load an :class:`Environment` instance defined in the YAML file.

        Expects the following format:

        .. code-block:: yaml

            directory: ../static
            url: /media
            debug: True
            updater: timestamp
            config:
                compass_bin: /opt/compass
                another_custom_config_value: foo

            bundles:
                # ...

        All values, including ``directory`` and ``url`` are optional. The
        syntax for defining bundles is the same as for
        :meth:`~.YAMLLoader.load_bundles`.

        Sample usage::

            from webassets.loaders import YAMLLoader
            loader = YAMLLoader('asset.yml')
            env = loader.load_environment()

            env['some-bundle'].urls()
        """
        f, filename = self._open()
        try:
            obj = self.yaml.load(f) or {}

            env = Environment()

            # Load environment settings
            for setting in ('debug', 'cache', 'versions', 'url_expire',
                            'auto_build', 'url', 'directory',
                            # TODO: The deprecated values; remove at some point
                            'expire', 'updater'):
                if setting in obj:
                    setattr(env, setting, obj[setting])

            if 'load_path' in obj:
                load_path = obj['load_path']
                if load_path:
                    if isinstance(load_path, list):
                        env.load_path.extend(load_path)
                    else:
                        env.append_path(load_path)

            # Treat the 'directory' option special, make it relative to the
            # path of the YAML file, if we know it.
            if filename and 'directory' in env.config:
                env.directory = path.normpath(
                    path.join(path.dirname(filename),
                              env.config['directory']))

            # Load custom config options
            if 'config' in obj:
                env.config.update(obj['config'])

            # Load bundles
            bundles = self._get_bundles(obj.get('bundles', {}))
            for name, bundle in bundles.iteritems():
                env.register(name, bundle)

            return env
        finally:
            f.close()
开发者ID:RealKinetic,项目名称:webassets,代码行数:73,代码来源:loaders.py


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