From 60ffe0b2b498b808c97d02eb01dacc596ee3df6b Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 4 Jul 2017 06:26:46 -0500 Subject: [PATCH] hardcode more encodings --- fetch.py | 4 ++-- index.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fetch.py b/fetch.py index 32116408..7978b815 100644 --- a/fetch.py +++ b/fetch.py @@ -126,7 +126,7 @@ def archive_dot_org(out_dir, link, overwrite=False, timeout=60): print(' Failed: {} {}'.format(e.__class__.__name__, e)) if success: - with open('{}/archive.org.txt'.format(out_dir), 'w') as f: + with open('{}/archive.org.txt'.format(out_dir), 'w', encoding='utf-8') as f: f.write(saved_url) chmod_file('archive.org.txt', cwd=out_dir) @@ -215,7 +215,7 @@ def dump_link_info(out_dir, link, update=True): link_json = derived_link_info(link) link_json['archived_timstamp'] = str(datetime.now().timestamp()).split('.')[0] - with open(info_file_path, 'w') as link_file: + with open(info_file_path, 'w', encoding='utf-8') as link_file: link_file.write(json.dumps( link_json, indent=4, diff --git a/index.py b/index.py index 92787481..d8a5910a 100644 --- a/index.py +++ b/index.py @@ -8,11 +8,11 @@ from parse import derived_link_info def dump_index(links, service): """create index.html file for a given list of links and service""" - with open(INDEX_TEMPLATE, 'r') as f: + with open(INDEX_TEMPLATE, 'r', encoding='utf-8') as f: index_html = f.read() # TODO: refactor this out into index_template.html - with open(INDEX_ROW_TEMPLATE, 'r') as f: + with open(INDEX_ROW_TEMPLATE, 'r', encoding='utf-8') as f: link_html = f.read() article_rows = '\n'.join(