Fix some open calls were not being made through pathlib

This was causing the documentation to fail to build under Python 3.5.
This commit is contained in:
Lonami Exo 2019-01-06 21:36:32 +01:00
parent e565552ae9
commit b57e3e3e0a
3 changed files with 3 additions and 3 deletions

View File

@ -288,7 +288,7 @@ class DocsWriter:
def __enter__(self):
# Sanity check
self.filename.parent.mkdir(parents=True, exist_ok=True)
self.handle = open(self.filename, 'w', encoding='utf-8')
self.handle = self.filename.open('w', encoding='utf-8')
return self
def __exit__(self, exc_type, exc_val, exc_tb):

View File

@ -196,7 +196,7 @@ def _get_description(arg):
def _copy_replace(src, dst, replacements):
"""Copies the src file into dst applying the replacements dict"""
with open(src, 'r') as infile, open(dst, 'w') as outfile:
with src.open() as infile, dst.open('w') as outfile:
outfile.write(re.sub(
'|'.join(re.escape(k) for k in replacements),
lambda m: str(replacements[m.group(0)]),

View File

@ -137,7 +137,7 @@ def parse_tl(file_path, layer, methods=None, ignored_ids=CORE_TYPES):
def find_layer(file_path):
"""Finds the layer used on the specified scheme.tl file."""
layer_regex = re.compile(r'^//\s*LAYER\s*(\d+)$')
with open(file_path, 'r', encoding='utf-8') as file:
with file_path.open('r') as file:
for line in file:
match = layer_regex.match(line)
if match: