Skip to content
Permalink
Browse files
fix #112
  • Loading branch information
ralsina committed Sep 9, 2015
1 parent 672e7b5 commit 6df073bbdb75aa2312e5334d696bdedd39c74e38
Showing 2 changed files with 10 additions and 9 deletions.
@@ -7,6 +7,6 @@ MinVersion = 7.4.0

[Documentation]
Author = Chris Warrick
Version = 0.1.2
Version = 0.1.3
Website = http://plugins.getnikola.com/#upgrade_metadata
Description = Upgrade old-style metadata
@@ -77,15 +77,16 @@ def _execute(self, options, args):
meta_path = os.path.splitext(post.source_path)[0] + '.meta'
fname = utils.get_translation_candidate(post.config, meta_path, lang)

with io.open(fname, 'r', encoding='utf-8') as fh:
meta = fh.readlines()
if os.path.exists(fname):
with io.open(fname, 'r', encoding='utf-8') as fh:
meta = fh.readlines()

if not meta[1].startswith('.. '):
# check if we’re dealing with old style metadata
with io.open(fname, 'w', encoding='utf-8') as fh:
for k, v in zip(self.fields, meta):
fh.write('.. {0}: {1}'.format(k, v))
L.debug(fname)
if not meta[min(1, len(meta)-1)].startswith('.. '):
# check if we’re dealing with old style metadata
with io.open(fname, 'w', encoding='utf-8') as fh:
for k, v in zip(self.fields, meta):
fh.write('.. {0}: {1}'.format(k, v))
L.debug(fname)

L.info('{0} posts upgraded.'.format(len(flagged)))
else:

0 comments on commit 6df073b

Please sign in to comment.