本文整理汇总了Python中django.contrib.staticfiles.management.commands.collectstatic.Command.stdout方法的典型用法代码示例。如果您正苦于以下问题:Python Command.stdout方法的具体用法?Python Command.stdout怎么用?Python Command.stdout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.staticfiles.management.commands.collectstatic.Command
的用法示例。
在下文中一共展示了Command.stdout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from django.contrib.staticfiles.management.commands.collectstatic import Command [as 别名]
# 或者: from django.contrib.staticfiles.management.commands.collectstatic.Command import stdout [as 别名]
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))