From 444ff615273def81036dedd4a5b8f840e47f0510 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Wed, 17 Jan 2024 00:03:26 +0100 Subject: [PATCH] Drop support for EOL Python 2 (#61) * remove reliance on ancient compatibility libraries * review of the PR * drop Python2.7 from github workflow --- .github/workflows/build-status.yml | 3 +-- README.md | 3 +-- mpegdash/parser.py | 7 +------ mpegdash/utils.py | 3 +-- requirements.txt | 1 - setup.py | 2 -- tests/__init__.py | 5 +---- tests/test_mpdtoxml.py | 5 +---- tests/test_xmltompd.py | 5 +---- 9 files changed, 7 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-status.yml b/.github/workflows/build-status.yml index b7fb2cc..0ff8def 100644 --- a/.github/workflows/build-status.yml +++ b/.github/workflows/build-status.yml @@ -15,8 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # <=2.6 and 2.8 isn't available: https://github.com/actions/python-versions/blob/main/versions-manifest.json - python-version: ['2.7', '3.x'] + python-version: ['3.x'] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index ede56d5..e2de1a2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # python-mpegdash -MPEG-DASH MPD (Media Presentation Description) Parser compatible with Python 2.6+ and Python 3. +MPEG-DASH MPD (Media Presentation Description) Parser compatible with Python 3+. [![Build Status](https://img.shields.io/github/workflow/status/sangwonl/python-mpegdash/Build%20Status?label=Python%202.7%2B%20builds)](https://github.com/sangwonl/python-mpegdash/actions?query=workflow%3A%22Build+Status%22) [![License](https://img.shields.io/github/license/sangwonl/python-mpegdash?style=flat)](https://github.com/sangwonl/python-mpegdash/blob/master/LICENSE) @@ -20,7 +20,6 @@ $ pip install mpegdash ```bash $ python -m unittest discover -$ python3 -m unittest discover ``` * * * diff --git a/mpegdash/parser.py b/mpegdash/parser.py index 18f97f1..3a831e6 100644 --- a/mpegdash/parser.py +++ b/mpegdash/parser.py @@ -1,11 +1,6 @@ +from urllib.request import urlopen from xml.dom import minidom -# python3 support -try: - from urllib2 import urlopen -except ImportError: - from urllib.request import urlopen - from mpegdash.nodes import MPEGDASH from mpegdash.utils import parse_child_nodes, write_child_node from mpegdash.prettyprinter import pretty_print diff --git a/mpegdash/utils.py b/mpegdash/utils.py index 4d7b828..560017d 100644 --- a/mpegdash/utils.py +++ b/mpegdash/utils.py @@ -1,4 +1,3 @@ -from past.builtins import unicode # python3 compat from xml.dom import minidom import re @@ -19,7 +18,7 @@ def parse_child_nodes(xmlnode, tag_name, node_type): nodes = [] for elem in elements: - if node_type in (unicode, str): + if isinstance(node_type, str): node = xmlnode.firstChild.nodeValue else: node = node_type() diff --git a/requirements.txt b/requirements.txt index 2c6edea..e69de29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +0,0 @@ -future diff --git a/setup.py b/setup.py index 20b593d..e45b906 100644 --- a/setup.py +++ b/setup.py @@ -17,9 +17,7 @@ license="MIT", zip_safe=False, include_package_data=True, - install_requires=["future"], url="https://github.com/sangwonl/python-mpegdash", - tests_require=["unittest2"], test_suite="tests.my_module_suite", classifiers=[ "Programming Language :: Python", diff --git a/tests/__init__.py b/tests/__init__.py index 75d0381..562cd77 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,7 +1,4 @@ -try: - import unittest -except ImportError: - import unittest2 as unittest +import unittest def my_module_suite(): diff --git a/tests/test_mpdtoxml.py b/tests/test_mpdtoxml.py index 58dd7ca..40e0250 100644 --- a/tests/test_mpdtoxml.py +++ b/tests/test_mpdtoxml.py @@ -1,7 +1,4 @@ -try: - import unittest -except ImportError: - import unittest2 as unittest +import unittest from sys import version_info from mpegdash.parser import MPEGDASHParser diff --git a/tests/test_xmltompd.py b/tests/test_xmltompd.py index c6f46df..7e840ee 100644 --- a/tests/test_xmltompd.py +++ b/tests/test_xmltompd.py @@ -1,7 +1,4 @@ -try: - import unittest -except ImportError: - import unittest2 as unittest +import unittest from mpegdash.parser import MPEGDASHParser