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


Python collectstatic.Command类代码示例

本文整理汇总了Python中django.contrib.staticfiles.management.commands.collectstatic.Command的典型用法代码示例。如果您正苦于以下问题:Python Command类的具体用法?Python Command怎么用?Python Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_post_processing

    def test_post_processing(self):
        """
        Test that post_processing behaves correctly.

        Files that are alterable should always be post-processed; files that
        aren't should be skipped.

        collectstatic has already been called once in setUp() for this testcase,
        therefore we check by verifying behavior on a second run.
        """
        collectstatic_args = {
            "interactive": False,
            "verbosity": 0,
            "link": False,
            "clear": False,
            "dry_run": False,
            "post_process": True,
            "use_default_ignore_patterns": True,
            "ignore_patterns": ["*.ignoreme"],
        }

        collectstatic_cmd = CollectstaticCommand()
        collectstatic_cmd.set_options(**collectstatic_args)
        stats = collectstatic_cmd.collect()
        self.assertIn(os.path.join("cached", "css", "window.css"), stats["post_processed"])
        self.assertIn(os.path.join("cached", "css", "img", "window.png"), stats["unmodified"])
        self.assertIn(os.path.join("test", "nonascii.css"), stats["post_processed"])
开发者ID:codeclimate-testing,项目名称:django,代码行数:27,代码来源:test_storage.py

示例2: test_post_processing

    def test_post_processing(self):
        """Test that post_processing behaves correctly.

        Files that are alterable should always be post-processed; files that
        aren't should be skipped.

        collectstatic has already been called once in setUp() for this testcase,
        therefore we check by verifying behavior on a second run.
        """
        collectstatic_args = {
            'interactive': False,
            'verbosity': '0',
            'link': False,
            'clear': False,
            'dry_run': False,
            'post_process': True,
            'use_default_ignore_patterns': True,
            'ignore_patterns': ['*.ignoreme'],
        }

        collectstatic_cmd = CollectstaticCommand()
        collectstatic_cmd.set_options(**collectstatic_args)
        stats = collectstatic_cmd.collect()
        self.assertIn(os.path.join('cached', 'css', 'window.css'), stats['post_processed'])
        self.assertIn(os.path.join('cached', 'css', 'img', 'window.png'), stats['unmodified'])
        self.assertIn(os.path.join('test', 'nonascii.css'), stats['post_processed'])
开发者ID:Absherr,项目名称:django,代码行数:26,代码来源:tests.py

示例3: collect

 def collect(self):
     collectstatic_cmd = CollectstaticCommand()
     collectstatic_cmd.set_options(**COLLECTSTATIC_ARGS)
     return collectstatic_cmd.collect()
开发者ID:funkybob,项目名称:django-mangle,代码行数:4,代码来源:__init__.py

示例4: handle

    def handle(self, **options):
        self.set_options(**options)
        force = options.get('force', False)

        # base
        page_themes = 0

        tpl_dirs = merge(DIRS, app_template_dirs)
        templatedirs = [d for d in tpl_dirs if os.path.isdir(d)]

        for templatedir in templatedirs:
            for dirpath, subdirs, filenames in os.walk(templatedir):
                if 'base/page' in dirpath:
                    for f in filenames:
                        # ignore private and hidden members
                        if not f.startswith("_") and not f.startswith("."):
                            page_template = get_or_create_template(
                                f, force=force, prefix="base/page")
                            if not page_template:
                                self.stdout.write("Missing template %s" % f)
                                continue
                            # create themes with bases
                            try:
                                page_theme = PageTheme.objects.get(
                                    name=f.split(".")[0])
                            except PageTheme.DoesNotExist:
                                page_theme = PageTheme()
                                page_theme.label = '{} layout'.format(
                                    f.split(".")[0].title())
                                page_theme.name = f.split(".")[0]
                                page_theme.template = page_template
                                page_theme.save()
                                page_themes += 1

        if page_themes > 0:
            self.stdout.write(
                'Successfully created {} page themes'.format(page_themes))

        cmd = CollectStatic()
        cmd.stdout = self.stdout
        collect_static = cmd.handle(
            **{'interactive': False,
                'link': False,
                'clear': False,
                'dry_run': False,
                'ignore_patterns': [],
                'use_default_ignore_patterns': True,
                'post_process': True,
                'verbosity': 0})

        collected = self.collect()

        self.stdout.write(
            "Page themes synced {}".format(self.page_themes_updated))
        self.stdout.write("Page Skins synced {}".format(self.skins_updated))
开发者ID:django-leonardo,项目名称:django-leonardo,代码行数:55,代码来源:sync_page_themes.py

示例5: delete_file

 def delete_file(self, path, prefixed_path, source_storage):
     if self.comparison_method == 'modified_time':
         return CollectStatic.delete_file(self, path, prefixed_path, source_storage)
     elif self.storage.exists(prefixed_path):
         should_delete = self.compare(path, prefixed_path, source_storage)
         if should_delete:
             if self.dry_run:
                 self.log(u"Pretending to delete '%s'" % path)
             else:
                 self.log(u"Deleting '%s'" % path)
                 self.storage.delete(prefixed_path)
         else:
             self.log(u"Skipping '%s' (not modified)" % path)
             return False
     return True
开发者ID:,项目名称:,代码行数:15,代码来源:


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