Skip to content

Commit

Permalink
Drop Python 2.7 support
Browse files Browse the repository at this point in the history
* Remove py27 toxenv
* Remove 2.7 classifier and bump version
* Update dependencies
* Add upgrade tools to pre-commit configuration
* Run pre-commit
* Update README
  • Loading branch information
replaceafill committed Jun 20, 2023
1 parent ce8ce14 commit 6cab31a
Show file tree
Hide file tree
Showing 28 changed files with 274 additions and 352 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Expand Up @@ -12,8 +12,6 @@ jobs:
strategy:
matrix:
include:
- python-version: "2.7"
toxenv: "py27"
- python-version: "3.6"
toxenv: "py36"
- python-version: "3.7"
Expand Down Expand Up @@ -60,7 +58,7 @@ jobs:
flags: ${{ matrix.toxenv }}
lint:
name: "Lint"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"
Expand All @@ -77,7 +75,7 @@ jobs:
tox -e linting
docs:
name: "Docs"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"
Expand Down
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
@@ -1,10 +1,19 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py3-plus, --py36-plus]
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
args: [--py3-plus, --py36-plus]
- repo: https://github.com/ambv/black
rev: 21.9b0
rev: 22.8.0
hooks:
- id: black
args: [--safe, --quiet, --target-version, py27]
additional_dependencies: ['click==8.0.4']
args: [--safe, --quiet]
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -20,11 +20,10 @@ METSRW can be installed with pip.

METSRW has been tested with:

* Python 2.7
* Python 3.5
* Python 3.6
* Python 3.7
* Python 3.8
* Python 3.9

## Basic Usage

Expand Down
24 changes: 11 additions & 13 deletions docs/conf.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# . documentation build configuration file, created by
# sphinx-quickstart on Wed Jul 23 16:07:11 2014.
Expand All @@ -11,9 +10,8 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -43,8 +41,8 @@
master_doc = "index"

# General information about the project.
project = u"METS Reader & Writer"
copyright = u"Artefactual"
project = "METS Reader & Writer"
copyright = "Artefactual"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -193,7 +191,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [("index", "sphinx.tex", u". Documentation", u"Author", "manual")]
latex_documents = [("index", "sphinx.tex", ". Documentation", "Author", "manual")]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
Expand All @@ -220,7 +218,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "sphinx", u". Documentation", [u"Author"], 1)]
man_pages = [("index", "sphinx", ". Documentation", ["Author"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -235,8 +233,8 @@
(
"index",
"sphinx",
u". Documentation",
u"Author",
". Documentation",
"Author",
"sphinx",
"One line description of project.",
"Miscellaneous",
Expand All @@ -259,10 +257,10 @@
# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
epub_title = u"."
epub_author = u"Author"
epub_publisher = u"Author"
epub_copyright = u"2014, Author"
epub_title = "."
epub_author = "Author"
epub_publisher = "Author"
epub_copyright = "2014, Author"

# The basename for the epub file. It defaults to the project name.
# epub_basename = u'.'
Expand Down
75 changes: 36 additions & 39 deletions metsrw/__init__.py
@@ -1,50 +1,47 @@
# -*- coding: utf-8 -*-
"""METS reader and writer."""

from __future__ import absolute_import
import logging

from .exceptions import MetsError, ParseError
from . import plugins
from .di import Dependency
from .di import feature_broker
from .di import FeatureBroker
from .di import has_class_methods
from .di import has_methods
from .di import is_class
from .di import set_feature_broker_to_default_state
from .exceptions import MetsError
from .exceptions import ParseError
from .fsentry import FSEntry
from .metadata import Agent, AltRecordID, AMDSec, SubSection, MDRef, MDWrap
from .metadata import Agent
from .metadata import AltRecordID
from .metadata import AMDSec
from .metadata import MDRef
from .metadata import MDWrap
from .metadata import SubSection
from .mets import METSDocument
from .utils import (
NAMESPACES,
SCHEMA_LOCATIONS,
lxmlns,
FILE_ID_PREFIX,
GROUP_ID_PREFIX,
urlencode,
urldecode,
generate_mdtype_key,
)
from .validate import (
METS_XSD_PATH,
AM_SCT_PATH,
AM_PNTR_SCT_PATH,
get_schematron,
validate,
get_xmlschema,
xsd_validate,
schematron_validate,
sct_report_string,
xsd_error_log_string,
report_string,
)
from .di import (
FeatureBroker,
set_feature_broker_to_default_state,
feature_broker,
Dependency,
has_class_methods,
has_methods,
is_class,
)
from . import plugins
from .utils import FILE_ID_PREFIX
from .utils import generate_mdtype_key
from .utils import GROUP_ID_PREFIX
from .utils import lxmlns
from .utils import NAMESPACES
from .utils import SCHEMA_LOCATIONS
from .utils import urldecode
from .utils import urlencode
from .validate import AM_PNTR_SCT_PATH
from .validate import AM_SCT_PATH
from .validate import get_schematron
from .validate import get_xmlschema
from .validate import METS_XSD_PATH
from .validate import report_string
from .validate import schematron_validate
from .validate import sct_report_string
from .validate import validate
from .validate import xsd_error_log_string
from .validate import xsd_validate

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())
__version__ = "0.3.23"
__version__ = "0.4.0"

__all__ = [
"Agent",
Expand Down
14 changes: 5 additions & 9 deletions metsrw/di.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Dependency Injection logic for metsrw.
Here a global singleton feature broker is instantiated. By providing features
Expand All @@ -19,13 +18,10 @@
See http://code.activestate.com/recipes/413268/
"""

from six import with_metaclass

from .plugins import premisrw


class FeatureBroker(object):
class FeatureBroker:
"""Feature broker allows for the provisioning of features. These features
are dependencies that can be injected. Usage::
Expand Down Expand Up @@ -61,7 +57,7 @@ def __getitem__(self, feature_name):
try:
provider = self.providers[feature_name]
except KeyError:
raise KeyError("Unknown feature named {!r}".format(feature_name))
raise KeyError(f"Unknown feature named {feature_name!r}")
return provider()


Expand All @@ -77,7 +73,7 @@ def set_feature_broker_to_default_state(fb):
set_feature_broker_to_default_state(feature_broker)


class Dependency(object):
class Dependency:
"""Non-overriding descriptor for declaring required dependencies in metsrw
classes. In the following example usage the ``FSEntry`` class is declaring
a dependency on a feature named 'premis_object_class' which is a class and
Expand Down Expand Up @@ -118,13 +114,13 @@ class attribute it was assigned to in the managed class. In short, it
"""

def __init__(cls, name, bases, attr_dict):
super(DependencyPossessorMeta, cls).__init__(name, bases, attr_dict)
super().__init__(name, bases, attr_dict)
for key, attr in attr_dict.items():
if isinstance(attr, Dependency):
attr.dependency_name = key


class DependencyPossessor(with_metaclass(DependencyPossessorMeta, object)):
class DependencyPossessor(metaclass=DependencyPossessorMeta):
pass


Expand Down
1 change: 0 additions & 1 deletion metsrw/exceptions.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Exceptions for metsrw.
Expand Down

0 comments on commit 6cab31a

Please sign in to comment.