Skip to content

Commit f79b5c5

Browse files
committedMay 5, 2018
upgrade_metadata_v8: no BOM in saved file; skip untranslated posts
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 70f28b8 commit f79b5c5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎v8/upgrade_metadata_v8/upgrade_metadata_v8.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def _execute(self, options, args):
8080
if not options['yes']:
8181
yesno = utils.ask_yesno("Proceed with metadata upgrade?")
8282
if options['yes'] or yesno:
83-
no_converted = 0
84-
no_converted_partial = 0
83+
number_converted = 0
84+
number_converted_partial = 0
8585
for post in flagged:
8686
converted = False
8787
fully_converted = True
@@ -102,6 +102,10 @@ def _execute(self, options, args):
102102
continue
103103

104104
# Read metadata and text from post file
105+
if not os.path.exists(fname):
106+
L.debug("File {0} does not exist, skipping.".format(fname))
107+
continue
108+
105109
with io.open(fname, "r", encoding="utf-8-sig") as meta_file:
106110
source_text = meta_file.read()
107111
if not is_two_file:
@@ -164,18 +168,18 @@ def _execute(self, options, args):
164168
comment_wrap=(post.compiler.name != 'rest'), site=self.site)
165169
final_str = meta_str if is_two_file else (meta_str + content_str)
166170

167-
with io.open(fname, "w", encoding="utf-8-sig") as meta_file:
171+
with io.open(fname, "w", encoding="utf-8") as meta_file:
168172
meta_file.write(final_str)
169173
converted = True
170174

171175
if converted:
172176
if fully_converted:
173-
no_converted += 1
177+
number_converted += 1
174178
else:
175-
no_converted_partial += 1
179+
number_converted_partial += 1
176180

177181
L.info('{0} out of {2} posts upgraded; {1} only converted partially '
178-
'(see above output).'.format(no_converted + no_converted_partial, no_converted_partial, len(flagged)))
182+
'(see above output).'.format(number_converted + number_converted_partial, number_converted_partial, len(flagged)))
179183
else:
180184
L.info('Metadata not upgraded.')
181185
else:

0 commit comments

Comments
 (0)
Please sign in to comment.