Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #112
  • Loading branch information
ralsina committed Sep 9, 2015
1 parent 672e7b5 commit 6df073b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion v7/upgrade_metadata/upgrade_metadata.plugin
Expand Up @@ -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
17 changes: 9 additions & 8 deletions v7/upgrade_metadata/upgrade_metadata.py
Expand Up @@ -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:
Expand Down

0 comments on commit 6df073b

Please sign in to comment.