From 3373e36f64594f78b647201372f18824d4169da6 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 20 Sep 2020 18:30:13 -0700 Subject: [PATCH] Use pathclass.Path.open. --- timesearch_modules/breakdown.py | 2 +- timesearch_modules/get_styles.py | 4 ++-- timesearch_modules/get_wiki.py | 2 +- timesearch_modules/index.py | 2 +- timesearch_modules/offline_reading.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/timesearch_modules/breakdown.py b/timesearch_modules/breakdown.py index 8257db8..36a918d 100644 --- a/timesearch_modules/breakdown.py +++ b/timesearch_modules/breakdown.py @@ -95,7 +95,7 @@ def breakdown_argparse(args): breakdown_basename = breakdown_basename % database.filepath.replace_extension('').basename breakdown_filepath = database.breakdown_dir.with_child(breakdown_basename) os.makedirs(breakdown_filepath.parent.absolute_path, exist_ok=True) - breakdown_file = open(breakdown_filepath.absolute_path, 'w') + breakdown_file = breakdown_filepath.open('w') with breakdown_file: breakdown_file.write(dump) print('Wrote', breakdown_filepath.relative_path) diff --git a/timesearch_modules/get_styles.py b/timesearch_modules/get_styles.py index 3193c52..810f594 100644 --- a/timesearch_modules/get_styles.py +++ b/timesearch_modules/get_styles.py @@ -16,14 +16,14 @@ def get_styles(subreddit): stylesheet_filepath = database.styles_dir.with_child('stylesheet.css') print('Downloading %s' % stylesheet_filepath.relative_path) - with open(stylesheet_filepath.absolute_path, 'w', encoding='utf-8') as stylesheet: + with stylesheet_filepath.open('w', encoding='utf-8') as stylesheet: stylesheet.write(styles.stylesheet) for image in styles.images: image_basename = image['name'] + '.' + image['url'].split('.')[-1] image_filepath = database.styles_dir.with_child(image_basename) print('Downloading %s' % image_filepath.relative_path) - with open(image_filepath.absolute_path, 'wb') as image_file: + with image_filepath.open('wb') as image_file: response = requests.get(image['url']) image_file.write(response.content) diff --git a/timesearch_modules/get_wiki.py b/timesearch_modules/get_wiki.py index 68b4977..4c88455 100644 --- a/timesearch_modules/get_wiki.py +++ b/timesearch_modules/get_wiki.py @@ -16,7 +16,7 @@ def get_wiki(subreddit): wikipage_path = database.wiki_dir.join(wikipage.name).replace_extension('md') os.makedirs(wikipage_path.parent.absolute_path, exist_ok=True) - with open(wikipage_path.absolute_path, 'w', encoding='utf-8') as handle: + with wikipage_path.open('w', encoding='utf-8') as handle: handle.write(wikipage.content_md) print('Wrote', wikipage_path.relative_path) diff --git a/timesearch_modules/index.py b/timesearch_modules/index.py index 1d52f8b..d63d424 100644 --- a/timesearch_modules/index.py +++ b/timesearch_modules/index.py @@ -115,7 +115,7 @@ def index_worker( mash_basename += suffix + extension mash_filepath = database.index_dir.with_child(mash_basename) - mash_handle = open(mash_filepath.absolute_path, 'w', encoding='UTF-8') + mash_handle = mash_filepath.open('w', encoding='UTF-8') if html: mash_handle.write(HTML_HEADER) line_format = LINE_FORMAT_HTML diff --git a/timesearch_modules/offline_reading.py b/timesearch_modules/offline_reading.py index caada00..909d074 100644 --- a/timesearch_modules/offline_reading.py +++ b/timesearch_modules/offline_reading.py @@ -385,7 +385,7 @@ def offline_reading(subreddit=None, username=None, specific_submission=None): for (id, html) in htmls: html_basename = '%s.html' % id html_filepath = database.offline_reading_dir.with_child(html_basename) - html_handle = open(html_filepath.absolute_path, 'w', encoding='utf-8') + html_handle = html_filepath.open('w', encoding='utf-8') html_handle.write(html) html_handle.close() print('Wrote', html_filepath.relative_path)