diff --git a/bagit.py b/bagit.py index 944bf94..32cfb9b 100755 --- a/bagit.py +++ b/bagit.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - import argparse import codecs import gettext @@ -42,10 +40,8 @@ def find_locale_dir(): TRANSLATION_CATALOG = gettext.translation( "bagit-python", localedir=find_locale_dir(), fallback=True ) -if sys.version_info < (3,): - _ = TRANSLATION_CATALOG.ugettext -else: - _ = TRANSLATION_CATALOG.gettext + +_ = TRANSLATION_CATALOG.gettext MODULE_NAME = "bagit" if __name__ == "__main__" else __name__ @@ -1039,22 +1035,10 @@ def posix_multiprocessing_worker_initializer(): # is consistency since the input value will be preserved: -def normalize_unicode_py3(s): +def normalize_unicode(s): return unicodedata.normalize("NFC", s) -def normalize_unicode_py2(s): - if isinstance(s, str): - s = s.decode("utf-8") - return unicodedata.normalize("NFC", s) - - -if sys.version_info > (3, 0): - normalize_unicode = normalize_unicode_py3 -else: - normalize_unicode = normalize_unicode_py2 - - def build_unicode_normalized_lookup_dict(filenames): """ Return a dictionary mapping unicode-normalized filenames to as-encoded diff --git a/pyproject.toml b/pyproject.toml index 49db106..7cd2d39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,10 @@ Homepage = "https://libraryofcongress.github.io/bagit-python/" [tool] +[tool.ruff] +target-version = "py38" + + [tool.setuptools_scm] [tool.isort] diff --git a/setup.py b/setup.py index aaed63a..15c91b4 100644 --- a/setup.py +++ b/setup.py @@ -10,10 +10,6 @@ from setuptools import setup -if sys.version_info < (2, 7): - print("Python 2.7 or higher is required") - sys.exit(1) - description = "Create and validate BagIt packages" diff --git a/test.py b/test.py index b5b4252..1e7c22f 100644 --- a/test.py +++ b/test.py @@ -266,9 +266,7 @@ def test_validation_completeness_error_details(self): def test_bom_in_bagit_txt(self): bag = bagit.make_bag(self.tmpdir) - BOM = codecs.BOM_UTF8 - if sys.version_info[0] >= 3: - BOM = BOM.decode("utf-8") + BOM = codecs.BOM_UTF8.decode("utf-8") with open(j(self.tmpdir, "bagit.txt"), "r") as bf: bagfile = BOM + bf.read() with open(j(self.tmpdir, "bagit.txt"), "w") as bf: