本文整理汇总了Python中nikola.utils.config_changed函数的典型用法代码示例。如果您正苦于以下问题:Python config_changed函数的具体用法?Python config_changed怎么用?Python config_changed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_changed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_tasks
def gen_tasks(self):
"""Generate Windows Live Tiles and notifications."""
kw = {
"default_lang": self.site.config["DEFAULT_LANG"],
"site_url": self.site.config["BASE_URL"],
"output_folder": self.site.config["OUTPUT_FOLDER"],
"show_untranslated_posts": self.site.config["SHOW_UNTRANSLATED_POSTS"],
"windows_live_tiles": self.site.config["WINDOWS_LIVE_TILES"],
}
msapplication_assets = os.path.join(kw["output_folder"], "assets", "msapplication")
if not os.path.exists(msapplication_assets):
os.makedirs(msapplication_assets)
self.site.scan_posts()
yield self.group_task()
deps = []
if kw["show_untranslated_posts"]:
posts = self.site.posts[:5]
else:
posts = [x for x in self.site.posts if x.is_translation_available(kw["default_lang"])][:5]
for post in posts:
deps += post.deps(kw["default_lang"])
for i, post in zip(range(len(posts)), posts):
notification_deps = post.deps(kw["default_lang"])
output_name = os.path.join(msapplication_assets, "tile_notification" + str(i + 1) + ".xml")
titles = {
"maintitle": post.title(kw["default_lang"]),
"title1": posts[0].title(kw["default_lang"]),
"title2": posts[1].title(kw["default_lang"]),
"title3": posts[2].title(kw["default_lang"])
}
yield {
"basename": "windows_live_tiles",
"name": os.path.normpath(output_name),
"file_dep": notification_deps,
"targets": [output_name],
"actions": [(self.generate_notification_tile, (output_name, kw["default_lang"], kw["windows_live_tiles"]["tileimages"], titles, post.meta[kw["default_lang"]]["previewimage"]))],
"task_dep": ["render_posts"],
"clean": True,
"uptodate": [utils.config_changed(kw)],
}
browserconfig_output_name = os.path.join(kw["output_folder"], "browserconfig.xml")
yield {
"basename": "windows_live_tiles",
"name": os.path.normpath(browserconfig_output_name),
"file_dep": deps,
"targets": [browserconfig_output_name],
"actions": [(self.generate_browserconfig,
(browserconfig_output_name, kw["windows_live_tiles"],
len(posts)))],
"task_dep": ["render_posts"],
"clean": True,
"uptodate": [utils.config_changed(kw)],
}
示例2: remove_excluded_image
def remove_excluded_image(self, img):
# Remove excluded images
# img is something like galleries/demo/tesla2_lg.jpg so it's the *source* path
# and we should remove both the large and thumbnail *destination* paths
img = os.path.relpath(img, self.kw['gallery_path'])
output_folder = os.path.dirname(
os.path.join(
self.kw["output_folder"],
self.site.path("gallery", os.path.dirname(img))))
img_path = os.path.join(output_folder, os.path.basename(img))
fname, ext = os.path.splitext(img_path)
thumb_path = fname + '.thumbnail' + ext
yield utils.apply_filters({
'basename': '_render_galleries_clean',
'name': thumb_path,
'actions': [
(utils.remove_file, (thumb_path,))
],
'clean': True,
'uptodate': [utils.config_changed(self.kw)],
}, self.kw['filters'])
yield utils.apply_filters({
'basename': '_render_galleries_clean',
'name': img_path,
'actions': [
(utils.remove_file, (img_path,))
],
'clean': True,
'uptodate': [utils.config_changed(self.kw)],
}, self.kw['filters'])
示例3: remove_excluded_image
def remove_excluded_image(self, img, input_folder):
# Remove excluded images
# img is something like input_folder/demo/tesla2_lg.jpg so it's the *source* path
# and we should remove both the large and thumbnail *destination* paths
output_folder = os.path.dirname(
os.path.join(self.kw["output_folder"], self.site.path("gallery", os.path.dirname(img)))
)
img = os.path.relpath(img, input_folder)
img_path = os.path.join(output_folder, os.path.basename(img))
fname, ext = os.path.splitext(img_path)
thumb_path = fname + ".thumbnail" + ext
yield utils.apply_filters(
{
"basename": "_render_galleries_clean",
"name": thumb_path,
"actions": [(utils.remove_file, (thumb_path,))],
"clean": True,
"uptodate": [utils.config_changed(self.kw, "nikola.plugins.task.galleries:clean_thumb")],
},
self.kw["filters"],
)
yield utils.apply_filters(
{
"basename": "_render_galleries_clean",
"name": img_path,
"actions": [(utils.remove_file, (img_path,))],
"clean": True,
"uptodate": [utils.config_changed(self.kw, "nikola.plugins.task.galleries:clean_file")],
},
self.kw["filters"],
)
示例4: gen_tasks
def gen_tasks(self):
"""Create tasks to copy the assets of the whole theme chain.
If a file is present on two themes, use the version
from the "youngest" theme.
"""
kw = {
"themes": self.site.THEMES,
"output_folder": self.site.config['OUTPUT_FOLDER'],
"filters": self.site.config['FILTERS'],
"code_color_scheme": self.site.config['CODE_COLOR_SCHEME'],
}
flag = True
has_code_css = False
tasks = {}
code_css_path = os.path.join(kw['output_folder'], 'assets', 'css', 'code.css')
for theme_name in kw['themes']:
src = os.path.join(utils.get_theme_path(theme_name), 'assets')
dst = os.path.join(kw['output_folder'], 'assets')
for task in utils.copy_tree(src, dst):
if task['name'] in tasks:
continue
if task['targets'][0] == code_css_path:
has_code_css = True
tasks[task['name']] = task
task['uptodate'] = [utils.config_changed(kw)]
task['basename'] = self.name
flag = False
yield utils.apply_filters(task, kw['filters'])
if flag:
yield {
'basename': self.name,
'name': 'None',
'uptodate': [True],
'actions': [],
}
if not has_code_css: # Generate it
def create_code_css():
from pygments.formatters import get_formatter_by_name
formatter = get_formatter_by_name('html', style=kw["code_color_scheme"])
utils.makedirs(os.path.dirname(code_css_path))
with codecs.open(code_css_path, 'wb+', 'utf8') as outf:
outf.write(formatter.get_style_defs('.code'))
outf.write("table.codetable { width: 100%;} td.linenos {text-align: right; width: 4em;}")
task = {
'basename': self.name,
'name': code_css_path,
'targets': [code_css_path],
'uptodate': [utils.config_changed(kw)],
'actions': [(create_code_css, [])],
'clean': True,
}
yield utils.apply_filters(task, kw['filters'])
示例5: gen_tasks
def gen_tasks(self):
"""Create tasks to copy the assets of the whole theme chain.
If a file is present on two themes, use the version
from the "youngest" theme.
"""
kw = {
"themes": self.site.THEMES,
"output_folder": self.site.config["OUTPUT_FOLDER"],
"filters": self.site.config["FILTERS"],
"code_color_scheme": self.site.config["CODE_COLOR_SCHEME"],
}
has_code_css = False
tasks = {}
code_css_path = os.path.join(kw["output_folder"], "assets", "css", "code.css")
yield self.group_task()
for theme_name in kw["themes"]:
src = os.path.join(utils.get_theme_path(theme_name), "assets")
dst = os.path.join(kw["output_folder"], "assets")
for task in utils.copy_tree(src, dst):
if task["name"] in tasks:
continue
if task["targets"][0] == code_css_path:
has_code_css = True
tasks[task["name"]] = task
task["uptodate"] = [utils.config_changed(kw)]
task["basename"] = self.name
yield utils.apply_filters(task, kw["filters"])
if not has_code_css: # Generate it
def create_code_css():
from pygments.formatters import get_formatter_by_name
formatter = get_formatter_by_name("html", style=kw["code_color_scheme"])
utils.makedirs(os.path.dirname(code_css_path))
with codecs.open(code_css_path, "wb+", "utf8") as outf:
outf.write(formatter.get_style_defs(["pre.code", "div.code pre"]))
outf.write("\ntable.codetable { width: 100%;} td.linenos {text-align: right; width: 4em;}\n")
task = {
"basename": self.name,
"name": code_css_path,
"targets": [code_css_path],
"uptodate": [utils.config_changed(kw)],
"actions": [(create_code_css, [])],
"clean": True,
}
yield utils.apply_filters(task, kw["filters"])
示例6: create_target_images
def create_target_images(self, img, input_path):
"""Copy images to output."""
gallery_name = os.path.dirname(img)
output_gallery = os.path.dirname(
os.path.join(
self.kw["output_folder"],
self.site.path("gallery_global", gallery_name)))
# Do thumbnails and copy originals
# img is "galleries/name/image_name.jpg"
# img_name is "image_name.jpg"
# fname, ext are "image_name", ".jpg"
# thumb_path is
# "output/GALLERY_PATH/name/image_name.thumbnail.jpg"
img_name = os.path.basename(img)
fname, ext = os.path.splitext(img_name)
thumb_path = os.path.join(
output_gallery,
".thumbnail".join([fname, ext]))
# thumb_path is "output/GALLERY_PATH/name/image_name.jpg"
orig_dest_path = os.path.join(output_gallery, img_name)
yield utils.apply_filters({
'basename': self.name,
'name': thumb_path,
'file_dep': [img],
'targets': [thumb_path],
'actions': [
(self.resize_image,
(img, thumb_path, self.kw['thumbnail_size'], True, self.kw['preserve_exif_data'],
self.kw['exif_whitelist'], self.kw['preserve_icc_profiles']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['thumbnail_size']
}, 'nikola.plugins.task.galleries:resize_thumb')],
}, self.kw['filters'])
yield utils.apply_filters({
'basename': self.name,
'name': orig_dest_path,
'file_dep': [img],
'targets': [orig_dest_path],
'actions': [
(self.resize_image,
(img, orig_dest_path, self.kw['max_image_size'], True, self.kw['preserve_exif_data'],
self.kw['exif_whitelist'], self.kw['preserve_icc_profiles']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['max_image_size']
}, 'nikola.plugins.task.galleries:resize_max')],
}, self.kw['filters'])
示例7: create_target_images
def create_target_images(self, img):
gallery_name = os.path.relpath(os.path.dirname(img), self.kw['gallery_path'])
output_gallery = os.path.dirname(
os.path.join(
self.kw["output_folder"],
self.site.path("gallery", gallery_name)))
# Do thumbnails and copy originals
# img is "galleries/name/image_name.jpg"
# img_name is "image_name.jpg"
# fname, ext are "image_name", ".jpg"
# thumb_path is
# "output/GALLERY_PATH/name/image_name.thumbnail.jpg"
img_name = os.path.basename(img)
fname, ext = os.path.splitext(img_name)
thumb_path = os.path.join(
output_gallery,
".thumbnail".join([fname, ext]))
# thumb_path is "output/GALLERY_PATH/name/image_name.jpg"
orig_dest_path = os.path.join(output_gallery, img_name)
yield utils.apply_filters({
'basename': self.name,
'name': thumb_path,
'file_dep': [img],
'targets': [thumb_path],
'actions': [
(self.resize_image,
(img, thumb_path, self.kw['thumbnail_size']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['thumbnail_size']
})],
}, self.kw['filters'])
yield utils.apply_filters({
'basename': self.name,
'name': orig_dest_path,
'file_dep': [img],
'targets': [orig_dest_path],
'actions': [
(self.resize_image,
(img, orig_dest_path, self.kw['max_image_size']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['max_image_size']
})],
}, self.kw['filters'])
示例8: gen_tasks
def gen_tasks(self):
"""Copy static files into the output folder."""
self.kw = {
'image_thumbnail_size': self.site.config['IMAGE_THUMBNAIL_SIZE'],
'image_thumbnail_format': self.site.config['IMAGE_THUMBNAIL_FORMAT'],
'max_image_size': self.site.config['MAX_IMAGE_SIZE'],
'image_folders': self.site.config['IMAGE_FOLDERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'filters': self.site.config['FILTERS'],
'preserve_exif_data': self.site.config['PRESERVE_EXIF_DATA'],
'exif_whitelist': self.site.config['EXIF_WHITELIST'],
'preserve_icc_profiles': self.site.config['PRESERVE_ICC_PROFILES'],
}
self.image_ext_list = self.image_ext_list_builtin
self.image_ext_list.extend(self.site.config.get('EXTRA_IMAGE_EXTENSIONS', []))
yield self.group_task()
for src in self.kw['image_folders']:
dst = self.kw['output_folder']
filters = self.kw['filters']
real_dst = os.path.join(dst, self.kw['image_folders'][src])
for task in self.process_tree(src, real_dst):
task['basename'] = self.name
task['uptodate'] = [utils.config_changed(self.kw)]
yield utils.apply_filters(task, filters)
示例9: gen_tasks
def gen_tasks(self):
"""Build final pages from metadata and HTML fragments."""
kw = {
"post_pages": self.site.config["post_pages"],
"translations": self.site.config["TRANSLATIONS"],
"filters": self.site.config["FILTERS"],
}
self.site.scan_posts()
flag = False
for lang in kw["translations"]:
for post in self.site.timeline:
for task in self.site.generic_page_renderer(lang, post,
kw["filters"]):
task['uptodate'] = [config_changed({
1: task['uptodate'][0].config,
2: kw})]
task['basename'] = self.name
flag = True
yield task
if flag is False: # No page rendered, yield a dummy task
yield {
'basename': self.name,
'name': 'None',
'uptodate': [True],
'actions': [],
}
示例10: tag_page_as_list
def tag_page_as_list(self, tag, lang, post_list, kw, is_category):
"""We render a single flat link list with this tag's posts"""
kind = "category" if is_category else "tag"
template_name = "tag.tmpl"
output_name = os.path.join(kw['output_folder'], self.site.path(
kind, tag, lang))
context = {}
context["lang"] = lang
context["title"] = kw["messages"][lang]["Posts about %s"] % tag
context["posts"] = post_list
context["permalink"] = self.site.link(kind, tag, lang)
context["tag"] = tag
context["kind"] = kind
context["description"] = None
task = self.site.generic_post_list_renderer(
lang,
post_list,
output_name,
template_name,
kw['filters'],
context,
)
task_cfg = {1: task['uptodate'][0].config, 2: kw}
task['uptodate'] = [utils.config_changed(task_cfg)]
task['basename'] = str(self.name)
yield task
示例11: author_page_as_list
def author_page_as_list(self, author, lang, post_list, kw):
"""Render a single flat link list with this author's posts."""
kind = "author"
template_name = "author.tmpl"
output_name = os.path.join(kw['output_folder'], self.site.path(
kind, author, lang))
context = {}
context["lang"] = lang
title = self._get_title(author)
context["author"] = title
context["title"] = kw["messages"][lang]["Posts by %s"] % title
context["posts"] = post_list
context["permalink"] = self.site.link(kind, author, lang)
context["kind"] = kind
context["description"] = self._get_description(author, lang)
context["pagekind"] = ["list", "author_page"]
task = self.site.generic_post_list_renderer(
lang,
post_list,
output_name,
template_name,
kw['filters'],
context,
)
task['uptodate'] = task['uptodate'] + [utils.config_changed(kw, 'nikola.plugins.task.authors:list')]
task['basename'] = str(self.name)
yield task
示例12: list_tags_page
def list_tags_page(self, kw):
"""a global "all your tags/categories" page for each language"""
tags = list(self.site.posts_per_tag.keys())
categories = list(self.site.posts_per_category.keys())
# We want our tags to be sorted case insensitive
tags.sort(key=lambda a: a.lower())
categories.sort(key=lambda a: a.lower())
if categories != [""]:
has_categories = True
else:
has_categories = False
template_name = "tags.tmpl"
kw["tags"] = tags
kw["categories"] = categories
for lang in kw["translations"]:
output_name = os.path.join(kw["output_folder"], self.site.path("tag_index", None, lang))
output_name = output_name
context = {}
if has_categories:
context["title"] = kw["messages"][lang]["Tags and Categories"]
else:
context["title"] = kw["messages"][lang]["Tags"]
context["items"] = [(tag, self.site.link("tag", tag, lang)) for tag in tags]
if has_categories:
context["cat_items"] = [(tag, self.site.link("category", tag, lang)) for tag in categories]
else:
context["cat_items"] = None
context["permalink"] = self.site.link("tag_index", None, lang)
context["description"] = None
task = self.site.generic_post_list_renderer(lang, [], output_name, template_name, kw["filters"], context)
task_cfg = {1: task["uptodate"][0].config, 2: kw}
task["uptodate"] = [utils.config_changed(task_cfg)]
task["basename"] = str(self.name)
yield task
示例13: _generate_classification_page_as_rss
def _generate_classification_page_as_rss(self, taxonomy, classification, filtered_posts, title, description, kw, lang):
"""Create a RSS feed for a single classification in a given language."""
kind = taxonomy.classification_name
# Render RSS
output_name = os.path.normpath(os.path.join(self.site.config['OUTPUT_FOLDER'], self.site.path(kind + "_rss", classification, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(kind + "_rss", classification, lang).lstrip('/'))
deps = []
deps_uptodate = []
for post in filtered_posts:
deps += post.deps(lang)
deps_uptodate += post.deps_uptodate(lang)
blog_title = kw["blog_title"](lang)
task = {
'basename': str(self.name),
'name': output_name,
'file_dep': deps,
'targets': [output_name],
'actions': [(utils.generic_rss_renderer,
(lang, "{0} ({1})".format(blog_title, title) if blog_title != title else blog_title,
kw["site_url"], description, filtered_posts,
output_name, kw["feed_teasers"], kw["feed_plain"], kw['feed_length'],
feed_url, _enclosure, kw["feed_links_append_query"]))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.taxonomies:rss')] + deps_uptodate,
'task_dep': ['render_posts'],
}
return utils.apply_filters(task, kw['filters'])
示例14: _render_classification_overview
def _render_classification_overview(self, classification_name, template, lang, context, kw):
# Prepare rendering
context["permalink"] = self.site.link("{}_index".format(classification_name), None, lang)
if "pagekind" not in context:
context["pagekind"] = ["list", "tags_page"]
output_name = os.path.join(self.site.config['OUTPUT_FOLDER'], self.site.path('{}_index'.format(classification_name), None, lang))
blinker.signal('generate_classification_overview').send({
'site': self.site,
'classification_name': classification_name,
'lang': lang,
'context': context,
'kw': kw,
'output_name': output_name,
})
task = self.site.generic_post_list_renderer(
lang,
[],
output_name,
template,
kw['filters'],
context,
)
task['uptodate'] = task['uptodate'] + [utils.config_changed(kw, 'nikola.plugins.task.taxonomies:page')]
task['basename'] = str(self.name)
yield task
示例15: tag_rss
def tag_rss(self, tag, lang, posts, kw, is_category):
"""RSS for a single tag / language"""
kind = "category" if is_category else "tag"
# Render RSS
output_name = os.path.normpath(
os.path.join(kw['output_folder'],
self.site.path(kind + "_rss", tag, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(kind + "_rss", tag, lang).lstrip('/'))
deps = []
deps_uptodate = []
post_list = sorted(posts, key=lambda a: a.date)
post_list.reverse()
for post in post_list:
deps += post.deps(lang)
deps_uptodate += post.deps_uptodate(lang)
task = {
'basename': str(self.name),
'name': output_name,
'file_dep': deps,
'targets': [output_name],
'actions': [(utils.generic_rss_renderer,
(lang, "{0} ({1})".format(kw["blog_title"](lang), tag),
kw["site_url"], None, post_list,
output_name, kw["rss_teasers"], kw["rss_plain"], kw['feed_length'],
feed_url))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.tags:rss')] + deps_uptodate,
'task_dep': ['render_posts'],
}
return utils.apply_filters(task, kw['filters'])