Remove helpers.universal_open()
This helper function only had a single usage, this was always an awkward way to support Python 3.5 that I'd forget to use.
This commit is contained in:
@@ -130,14 +130,6 @@ def is_file_writable(test_file):
|
||||
|
||||
|
||||
if sys.version_info[0:2] <= (3, 5):
|
||||
def universal_open(p, *args, **kwargs):
|
||||
"""Work around Python 3.5's inability to open(pathlib.Path())"""
|
||||
try:
|
||||
return p.open(*args, **kwargs)
|
||||
except AttributeError:
|
||||
return open(p, *args, **kwargs)
|
||||
|
||||
|
||||
def fspath(path):
|
||||
"""https://www.python.org/dev/peps/pep-0519/#os"""
|
||||
import pathlib
|
||||
@@ -167,7 +159,6 @@ if sys.version_info[0:2] <= (3, 5):
|
||||
+ path_type.__name__)
|
||||
|
||||
else:
|
||||
universal_open = open
|
||||
fspath = os.fspath
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ from datetime import datetime
|
||||
import pkg_resources
|
||||
from libxmp.utils import file_to_dict
|
||||
from libxmp import consts
|
||||
from pathlib import Path
|
||||
|
||||
from .helpers import universal_open
|
||||
|
||||
ICC_PROFILE_RELPATH = 'data/sRGB.icc'
|
||||
|
||||
@@ -216,8 +216,7 @@ def generate_pdfa_ps(target_filename, pdfmark, icc='sRGB'):
|
||||
|
||||
# We should have encoded everything to pure ASCII by this point, and
|
||||
# to be safe, only allow ASCII in PostScript
|
||||
with universal_open(target_filename, 'w', encoding='ascii') as f:
|
||||
f.write(ps)
|
||||
Path(target_filename).write_text(ps, encoding='ascii')
|
||||
|
||||
|
||||
def file_claims_pdfa(filename):
|
||||
|
||||
@@ -29,7 +29,7 @@ from enum import Enum
|
||||
from contextlib import contextmanager
|
||||
|
||||
from .exec import ghostscript
|
||||
from .helpers import universal_open, fspath
|
||||
from .helpers import fspath
|
||||
|
||||
from pikepdf import PdfMatrix
|
||||
import pikepdf
|
||||
|
||||
Reference in New Issue
Block a user