Skip to content
Permalink
Browse files

Fixing wrong .dep filename bug.

  • Loading branch information
felixfontein committed Oct 29, 2016
1 parent 3c5edb3 commit 83ffc8bad8098ca9671f12c729ec47442c19e296
Showing with 18 additions and 7 deletions.
  1. +12 −4 nikola/plugin_categories.py
  2. +6 −3 nikola/post.py
@@ -263,9 +263,13 @@ class PageCompiler(BasePlugin):
}
config_dependencies = []

def _read_extra_deps(self, post):
def get_dep_filename(self, post, lang):
"""Return the .dep file's name for the given post and language."""
return post.translated_base_path(lang) + '.dep'

def _read_extra_deps(self, post, lang):
"""Read contents of .dep file and return them as a list."""
dep_path = post.base_path + '.dep'
dep_path = self.get_dep_filename(post, lang)
if os.path.isfile(dep_path):
with io.open(dep_path, 'r+', encoding='utf8') as depf:
deps = [l.strip() for l in depf.readlines()]
@@ -274,12 +278,16 @@ def _read_extra_deps(self, post):

def register_extra_dependencies(self, post):
"""Add dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')
def create_lambda(lang):
return lambda: self._read_extra_deps(post, lang)

for lang in self.site.config['TRANSLATIONS']:
post.add_dependency(create_lambda(lang), 'fragment')

def get_extra_targets(self, post, lang, dest):
"""Return a list of extra targets for the render_posts task when compiling the post for the specified language."""
if self.use_dep_file:
return [post.base_path + '.dep']
return [self.get_dep_filename(post, lang)]
else:
return []

@@ -461,9 +461,12 @@ def register_depfile(self, dep, dest=None, lang=None):
self._depfile[dest].append(dep)

@staticmethod
def write_depfile(dest, deps_list, post=None):
def write_depfile(dest, deps_list, post=None, lang=None):
"""Write a depfile for a given language."""
deps_path = dest + '.dep'
if post is None or lang is None:
deps_path = dest + '.dep'
else:
deps_path = post.compiler.get_dep_filename(post, lang)
if deps_list or (post.compiler.use_dep_file if post else False):
deps_list = [p for p in deps_list if p != dest] # Don't depend on yourself (#1671)
with io.open(deps_path, "w+", encoding="utf8") as deps_file:
@@ -543,7 +546,7 @@ def wrap_encrypt(path, password):
self.is_two_file,
self,
lang)
Post.write_depfile(dest, self._depfile[dest], post=self)
Post.write_depfile(dest, self._depfile[dest], post=self, lang=lang)

signal('compiled').send({
'source': self.translated_source_path(lang),

0 comments on commit 83ffc8b

Please sign in to comment.
You can’t perform that action at this time.