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


Python Environment.save方法代码示例

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


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

示例1: Assets

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import save [as 别名]
class Assets(object):
    """
    Uses the gears package to compile all .scss and .coffee files into CSS and JS
    """

    def __init__(self):
        project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
        app_dir = os.path.join(project_dir, 'app')
        public_dir = os.path.join(project_dir, 'public')

        self.gears = Environment(public_dir, fingerprinting=False,
            manifest_path=False)
        self.gears.finders.register(ExtFinder(
            [app_dir],
            ['.coffee', '.scss', '.handlebars', '.js', '.css'],
            ['app.handlebars', 'partials/header.handlebars', 'partials/footer.handlebars']
        ))

        self.gears.compilers.register('.scss', LibsassCompiler.as_handler())
        self.gears.compilers.register('.coffee', CoffeeScriptCompiler.as_handler())
        self.gears.compilers.register('.handlebars', CustomHandlebarsCompiler.as_handler())

        if env.is_prod():
            self.gears.compressors.register('text/css', CleanCSSCompressor.as_handler())

        self.gears.register_defaults()

    def compile(self):
        """
        Perform the cross-compile of the assets
        """

        self.gears.save()
开发者ID:wbond,项目名称:packagecontrol.io,代码行数:35,代码来源:assets.py

示例2: CompilerTest

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import save [as 别名]
class CompilerTest(unittest.TestCase):
    def setUp(self):
        self.compiler = SASSCompiler()

        self.env = Environment(root=OUTPUT_DIR, public_assets=(r".*\.css",), fingerprinting=False)
        self.env.finders.register(FileSystemFinder([SCSS_DIR]))
        self.env.compilers.register(".scss", self.compiler.as_handler())
        self.env.register_defaults()
        self.env.save()

    def test_syntax(self):
        scss, css, output = fixture_load("syntax")
        self.assertEqual(css, output)

    def test_variables(self):
        scss, css, output = fixture_load("variables")
        self.assertEqual(css, output)

    def test_mixin(self):
        scss, css, output = fixture_load("mixin")
        self.assertEqual(css, output)

    def test_import(self):
        scss, css, output = fixture_load("import")
        self.assertEqual(css, output)

    def test_image(self):
        scss, css, output = fixture_load("image")
        self.assertEqual(css, output)
开发者ID:ChillyBwoy,项目名称:gears-sass,代码行数:31,代码来源:test_compiler.py

示例3: Assets

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import save [as 别名]
class Assets(object):
    """
    Uses the gears package to compile all .scss and .coffee files into CSS and JS
    """

    def __init__(self):
        project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
        app_dir = os.path.join(project_dir, 'app')
        public_dir = os.path.join(project_dir, 'public')

        self.gears = Environment(public_dir, public_assets=[self._public_assets])
        self.gears.finders.register(ExtFinder([app_dir], ['.coffee', '.scss', '.handlebars']))

        self.gears.compilers.register('.scss', SCSSCompiler.as_handler())
        self.gears.compilers.register('.coffee', CoffeeScriptCompiler.as_handler())
        self.gears.compilers.register('.handlebars', CustomHandlebarsCompiler.as_handler())

        if env.is_prod():
            self.gears.compressors.register('application/javascript', UglifyJSCompressor.as_handler())
            self.gears.compressors.register('text/css', CleanCSSCompressor.as_handler())

        self.gears.register_defaults()


    def _public_assets(self, path):
        """
        Method is used by gears to determine what should be copied/published

        Allows only the app.js and app.css files to be compiled, filtering out
        all others since they should be included via require, require_tree,
        etc directives. Also, anything not js or css will be allowed through.

        :param path:
            The filesystem path to check

        :return:
            If the path should be copied to the public folder
        """

        if path in ['js/app.js', 'js/package.js', 'css/app.css']:
            return True
        return not any(path.endswith(ext) for ext in ('.css', '.js'))

    def compile(self):
        """
        Perform the cross-compile of the assets
        """

        self.gears.save()
开发者ID:joneshf,项目名称:sublime.wbond.net,代码行数:51,代码来源:assets.py

示例4: CompilerTest

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import save [as 别名]
class CompilerTest(unittest.TestCase):

    def setUp(self):
        self.compiler = JSXCompiler()

        self.env = Environment(root=OUTPUT_DIR, public_assets=(r'.*\.js',),
                               fingerprinting=False)
        self.env.finders.register(FileSystemFinder([JSX_DIR]))
        self.env.compilers.register('.jsx', self.compiler.as_handler())
        self.env.register_defaults()
        self.env.save()

    def test_transform(self):
        jsx, js, output = fixture_load('transform')
        self.assertEqual(js, output)
开发者ID:ChillyBwoy,项目名称:gears-jsx,代码行数:17,代码来源:test_compiler.py

示例5: Environment

# 需要导入模块: from gears.environment import Environment [as 别名]
# 或者: from gears.environment.Environment import save [as 别名]
import os

from gears.environment import Environment
from gears.finders import FileSystemFinder

from gears_handlebars import HandlebarsCompiler


ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
ASSETS_DIR = os.path.join(ROOT_DIR, 'assets')
STATIC_DIR = os.path.join(ROOT_DIR, 'static')

env = Environment(STATIC_DIR)
env.finders.register(FileSystemFinder([ASSETS_DIR]))
env.compilers.register('.hbs', HandlebarsCompiler.as_handler())
env.register_defaults()


if __name__ == '__main__':
    env.save()
开发者ID:gears,项目名称:gears-handlebars,代码行数:22,代码来源:compile.py


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