From cedf44862986089664516ebb8014609aac967472 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 21 Dec 2022 12:20:03 -0800 Subject: [PATCH] Try to fix CI (#162) * Removed 2.7 code --- .github/workflows/cibuild.yml | 14 ++- caom2/README.rst | 3 - caom2/caom2/artifact.py | 9 +- caom2/caom2/caom_util.py | 14 +-- caom2/caom2/checksum.py | 5 +- caom2/caom2/chunk.py | 8 +- caom2/caom2/common.py | 21 +---- caom2/caom2/diff.py | 6 +- caom2/caom2/obs_reader_writer.py | 16 +--- caom2/caom2/observation.py | 13 +-- caom2/caom2/part.py | 6 +- caom2/caom2/plane.py | 14 +-- caom2/caom2/shape.py | 6 +- caom2/caom2/tests/caom_test_instances.py | 11 +-- caom2/caom2/tests/test_artifact.py | 8 +- caom2/caom2/tests/test_caom_util.py | 6 +- caom2/caom2/tests/test_checksum.py | 8 +- caom2/caom2/tests/test_chunk.py | 6 +- caom2/caom2/tests/test_common.py | 6 +- caom2/caom2/tests/test_diffs.py | 5 +- caom2/caom2/tests/test_obs_reader_writer.py | 12 +-- caom2/caom2/tests/test_observation.py | 6 +- caom2/caom2/tests/test_part.py | 6 +- caom2/caom2/tests/test_plane.py | 6 +- caom2/caom2/tests/test_shape.py | 6 +- caom2/caom2/tests/test_wcs.py | 6 +- caom2/caom2/wcs.py | 6 +- caom2/setup.cfg | 11 +-- caom2/setup.py | 3 +- caom2repo/caom2repo/core.py | 10 +- .../data/plugins/cadcschemeplugin.py | 6 +- .../caom2repo/data/plugins/daoformatplugin.py | 4 +- .../data/plugins/fuseformatplugin.py | 93 ------------------- .../data/plugins/ukirtformatplugin.py | 93 ------------------- caom2repo/caom2repo/tests/addplaneplugin.py | 4 +- .../caom2repo/tests/artifacturiplugin.py | 4 +- caom2repo/caom2repo/tests/test_core.py | 7 +- caom2repo/setup.cfg | 6 +- caom2repo/setup.py | 2 +- caom2repo/tests/test-integration.py | 3 - caom2repo/tests/visitor-plugin.py | 4 +- caom2utils/README.rst | 2 - .../caom2utils/tests/test_fits2caom2.py | 54 +++++------ .../caom2utils/tests/test_obs_blueprint.py | 6 +- caom2utils/setup.cfg | 8 +- caom2utils/setup.py | 2 +- caom2utils/tox.ini | 2 +- 47 files changed, 109 insertions(+), 448 deletions(-) delete mode 100755 caom2repo/caom2repo/data/plugins/fuseformatplugin.py delete mode 100755 caom2repo/caom2repo/data/plugins/ukirtformatplugin.py diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index c81e7a12..1a7afba7 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -22,10 +22,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.10" - name: Install tox run: python -m pip install --upgrade tox - name: egg-info caom2 @@ -41,8 +41,12 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.6","3.7","3.8","3.9","3.10"] + python-version: ["3.7","3.8","3.9","3.10", "3.11"] package: [caom2, caom2utils, caom2repo] + exclude: + # temporary since hdf5 is not working yet + - python-version: "3.11" + package: caom2utils steps: - name: Checkout code uses: actions/checkout@v2 @@ -67,10 +71,10 @@ jobs: needs: tests steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.10" - name: Setup Graphviz uses: ts-graphviz/setup-graphviz@v1 - name: Install tox diff --git a/caom2/README.rst b/caom2/README.rst index 629e51e5..d34951d1 100644 --- a/caom2/README.rst +++ b/caom2/README.rst @@ -19,9 +19,6 @@ To create a minimal Simple Observation .. code:: python - # make it compatible with Python 2 and 3 - from __future__ import (absolute_import, division, print_function, - unicode_literals) import sys from caom2 import SimpleObservation, TypedOrderedDict, Plane, Artifact,\ Part, Chunk, ObservationWriter, ProductType,\ diff --git a/caom2/caom2/artifact.py b/caom2/caom2/artifact.py index 80f2c216..b09ea22e 100644 --- a/caom2/caom2/artifact.py +++ b/caom2/caom2/artifact.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -71,12 +70,8 @@ """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - - from builtins import str, int -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse from . import caom_util from .chunk import ProductType diff --git a/caom2/caom2/caom_util.py b/caom2/caom2/caom_util.py index 2433c989..6595cf76 100644 --- a/caom2/caom2/caom_util.py +++ b/caom2/caom2/caom_util.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** @@ -76,16 +75,11 @@ engineer get the correct meta data more quickly. """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import sys import collections from datetime import datetime -import six -from six.moves import collections_abc -from six.moves.urllib.parse import urlsplit +from urllib.parse import urlsplit from builtins import int, str as newstr @@ -267,7 +261,7 @@ def key_type(self): return self._oktypes -class TypedSet(collections_abc.MutableSet): +class TypedSet(collections.abc.MutableSet): """ Class that implements a typed set in Python. Supported types are specified when instance is created. Example: @@ -402,12 +396,12 @@ def __init__(self, key_type=None, *args): def __str__(self): return "\n".join(["{} => {}".format(k, v) - for k, v in six.iteritems(self)]) + for k, v in self.items()]) def __repr__(self): return "TypedOrderedDict((%r))," % self._oktypes + ( "(".join( - ["(%r,%r)" % (k, v) for k, v in six.iteritems(self)]) + ")") + ["(%r,%r)" % (k, v) for k, v in self.items()]) + ")") def check(self, key, value): """ diff --git a/caom2/caom2/checksum.py b/caom2/caom2/checksum.py index 0ea7e46d..c858bb82 100644 --- a/caom2/caom2/checksum.py +++ b/caom2/caom2/checksum.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2017. (c) 2017. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -66,8 +65,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) import hashlib import logging diff --git a/caom2/caom2/chunk.py b/caom2/caom2/chunk.py index 5f6a653c..a06e124f 100644 --- a/caom2/caom2/chunk.py +++ b/caom2/caom2/chunk.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2019. (c) 2019. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -71,8 +70,6 @@ """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) from builtins import str @@ -98,9 +95,6 @@ class ProductType(OrderedEnum): FLAT: "flat" WAVECAL: "wavecal" """ - # __order__ required for Python2.7 - __order__ = "SCIENCE CALIBRATION PREVIEW INFO NOISE WEIGHT AUXILIARY " \ - "THUMBNAIL BIAS DARK FLAT WAVECAL" SCIENCE = "science" CALIBRATION = "calibration" PREVIEW = "preview" diff --git a/caom2/caom2/common.py b/caom2/caom2/common.py index bd461305..e4174efe 100644 --- a/caom2/caom2/common.py +++ b/caom2/caom2/common.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,17 +66,13 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import inspect import uuid from datetime import datetime from builtins import int, str -from six.moves.urllib.parse import SplitResult, urlparse, urlsplit +from urllib.parse import SplitResult, urlparse, urlsplit import logging -import six from . import caom_util import warnings @@ -110,7 +105,7 @@ class OrderedEnum(Enum): """ Enums are in the order of their definition. - This is here just for Python2.7 and to work with aenum. + TODO: not sure this is required in Python 3 enum.Enum is supposed to support this. """ @@ -148,10 +143,7 @@ def __init__(self): pass def __str__(self): - if six.PY3: - args = inspect.getfullargspec(self.__init__).args[1:] - else: - args = inspect.getargspec(self.__init__).args[1:] + args = inspect.getfullargspec(self.__init__).args[1:] class_name = self.__class__.__name__ return "\n".join(["{}.{} : {}". format(class_name, arg, getattr(self, arg, None)) @@ -164,10 +156,7 @@ def __eq__(self, other): return False def __repr__(self): - if six.PY3: - args = inspect.getfullargspec(self.__init__).args[1:] - else: - args = inspect.getargspec(self.__init__).args[1:] + args = inspect.getfullargspec(self.__init__).args[1:] class_name = "" if self.__class__.__module__ != '__main__': class_name += self.__class__.__module__ + "." diff --git a/caom2/caom2/diff.py b/caom2/caom2/diff.py index 72cd01af..047baf4e 100644 --- a/caom2/caom2/diff.py +++ b/caom2/caom2/diff.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2018. (c) 2018. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -72,9 +71,6 @@ """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import math from caom2.common import CaomObject diff --git a/caom2/caom2/obs_reader_writer.py b/caom2/caom2/obs_reader_writer.py index b2524a28..87ddb227 100644 --- a/caom2/caom2/obs_reader_writer.py +++ b/caom2/caom2/obs_reader_writer.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -70,14 +70,10 @@ """ Defines ObservationReader class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import os import uuid from builtins import str, int -import six -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse from lxml import etree @@ -2039,7 +2035,7 @@ def _add_planes_element(self, planes, parent): return element = self._get_caom_element("planes", parent) - for _plane in six.itervalues(planes): + for _plane in planes.values(): plane_element = self._get_caom_element("plane", element) self._add_entity_attributes(_plane, plane_element) self._add_element("productID", _plane.product_id, plane_element) @@ -2297,7 +2293,7 @@ def _add_artifacts_element(self, artifacts, parent): return element = self._get_caom_element("artifacts", parent) - for _artifact in six.itervalues(artifacts): + for _artifact in artifacts.values(): artifact_element = self._get_caom_element("artifact", element) self._add_entity_attributes(_artifact, artifact_element) self._add_element("uri", _artifact.uri, artifact_element) @@ -2335,7 +2331,7 @@ def _add_parts_element(self, parts, parent): return element = self._get_caom_element("parts", parent) - for _part in six.itervalues(parts): + for _part in parts.values(): part_element = self._get_caom_element("part", element) self._add_entity_attributes(_part, part_element) self._add_element("name", _part.name, part_element) @@ -2680,8 +2676,6 @@ def _add_element(self, name, value, parent): element.text = value else: if isinstance(value, float): - # in Python 2.7 str(float) might alter precision of float - # therefore call repr instead element.text = repr(value) else: element.text = str(value) diff --git a/caom2/caom2/observation.py b/caom2/caom2/observation.py index 963ec5b7..7d5d8245 100644 --- a/caom2/caom2/observation.py +++ b/caom2/caom2/observation.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,12 +68,8 @@ """definition of the caom2.Observation object.""" -from __future__ import (absolute_import, division, print_function, - unicode_literals) - from datetime import datetime -import six from builtins import str import warnings from deprecated import deprecated @@ -86,7 +81,7 @@ from .common import _CAOM_VOCAB_NS from .plane import Plane from .shape import Point -from six.moves.urllib.parse import urlsplit +from urllib.parse import urlsplit with warnings.catch_warnings(): warnings.simplefilter('ignore') from aenum import Enum @@ -103,8 +98,6 @@ class ObservationIntentType(OrderedEnum): CALIBRATION: "calibration" SCIENCE: "science" """ - # __order__ required for Python2.7 - __order__ = "SCIENCE CALIBRATION" SCIENCE = "science" CALIBRATION = "calibration" @@ -506,7 +499,7 @@ def __init__(self, name): simple observation, otherwise name of algorithm that selected composite members or just 'composite' works too. """ - caom_util.type_check(name, six.text_type, 'name', override=False) + caom_util.type_check(name, str, 'name', override=False) self._name = str(name) def _key(self): diff --git a/caom2/caom2/part.py b/caom2/caom2/part.py index fc7f5462..49979083 100644 --- a/caom2/caom2/part.py +++ b/caom2/caom2/part.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -70,9 +69,6 @@ """Defines the caom2.Part class which describes the caom2_Observation_Plane_Artifact_Part object.""" -from __future__ import (absolute_import, division, print_function, - unicode_literals) - from builtins import str from . import caom_util diff --git a/caom2/caom2/plane.py b/caom2/caom2/plane.py index 91c78b5c..c47af0e2 100644 --- a/caom2/caom2/plane.py +++ b/caom2/caom2/plane.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,13 +68,10 @@ """defines the caom2.Plane class""" -from __future__ import (absolute_import, division, print_function, - unicode_literals) - from datetime import datetime from builtins import str, int -from six.moves.urllib.parse import SplitResult, urlsplit +from urllib.parse import SplitResult, urlsplit from deprecated import deprecated from caom2.caom_util import int_32 @@ -87,6 +83,7 @@ VocabularyTerm, OrderedEnum from .common import _CAOM_VOCAB_NS, _OBSCORE_VOCAB_NS import warnings +from enum import Enum with warnings.catch_warnings(): warnings.simplefilter('ignore') from aenum import Enum, extend_enum @@ -153,8 +150,6 @@ class EnergyBand(OrderedEnum): XRAY: "X-ray" GAMMARAY: "Gamma-ray" """ - # __order__ required for Python2.7 - __order__ = "RADIO MILLIMETER INFRARED OPTICAL UV EUV XRAY GAMMARAY" RADIO = "Radio" MILLIMETER = "Millimeter" INFRARED = "Infrared" @@ -186,9 +181,6 @@ class PolarizationState(OrderedEnum): XY: "XY" YX: "YX" """ - # __order__ required for Python2.7 - __order__ = "I Q U V RR LL RL LR XX YY XY YX POLI FPOLI POLA EPOLI " \ - "CPOLI NPOLI" I = "I" # noqa Q = "Q" U = "U" diff --git a/caom2/caom2/shape.py b/caom2/caom2/shape.py index 8f878a53..2c4ee304 100644 --- a/caom2/caom2/shape.py +++ b/caom2/caom2/shape.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,9 +66,6 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import math from caom2.caom_util import int_32 from . import caom_util diff --git a/caom2/caom2/tests/caom_test_instances.py b/caom2/caom2/tests/caom_test_instances.py index 52bf2007..61acf90f 100644 --- a/caom2/caom2/tests/caom_test_instances.py +++ b/caom2/caom2/tests/caom_test_instances.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,13 +68,9 @@ """ Defines Caom2TestInstances class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import collections from datetime import datetime import uuid -import six from builtins import int from caom2 import artifact @@ -361,7 +356,7 @@ def get_planes(self): _plane.data_read_groups.add('ivo://cadc.nrc.ca/groups?C') if self.depth > 2: - for k, v in six.iteritems(self.get_artifacts()): + for k, v in self.get_artifacts().items(): _plane.artifacts[k] = v planes[prod_id] = _plane return planes @@ -522,7 +517,7 @@ def get_artifacts(self): _artifact.acc_meta_checksum = common.ChecksumURI( "md5:844ce247db0844ad9f721430c80e7a21") if self.depth > 3: - for k, v in six.iteritems(self.get_parts()): + for k, v in self.get_parts().items(): _artifact.parts[k] = v artifacts["ad:foo/bar1"] = _artifact if self.caom_version >= 24: diff --git a/caom2/caom2/tests/test_artifact.py b/caom2/caom2/tests/test_artifact.py index c5334439..5fe0b54e 100644 --- a/caom2/caom2/tests/test_artifact.py +++ b/caom2/caom2/tests/test_artifact.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,12 +68,9 @@ """ Defines TestArtifact class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse from .. import artifact from .. import common diff --git a/caom2/caom2/tests/test_caom_util.py b/caom2/caom2/tests/test_caom_util.py index 2aa4f3cc..04c3b36b 100644 --- a/caom2/caom2/tests/test_caom_util.py +++ b/caom2/caom2/tests/test_caom_util.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,9 +66,6 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest import pytest diff --git a/caom2/caom2/tests/test_checksum.py b/caom2/caom2/tests/test_checksum.py index 20c71d7b..2e497d5e 100644 --- a/caom2/caom2/tests/test_checksum.py +++ b/caom2/caom2/tests/test_checksum.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,9 +68,6 @@ """ Defines TestPlane class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import hashlib import os import sys @@ -86,7 +82,7 @@ from caom2.checksum import update_checksum, int_32, checksum_diff import tempfile from mock import patch -from six import StringIO +from io import StringIO THIS_DIR = os.path.dirname(os.path.realpath(__file__)) TEST_DATA = 'data' diff --git a/caom2/caom2/tests/test_chunk.py b/caom2/caom2/tests/test_chunk.py index aa8b16fe..28bf84da 100644 --- a/caom2/caom2/tests/test_chunk.py +++ b/caom2/caom2/tests/test_chunk.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2019. (c) 2019. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,9 +68,6 @@ """ Defines TestChunk class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest from .. import chunk diff --git a/caom2/caom2/tests/test_common.py b/caom2/caom2/tests/test_common.py index 460ceefb..52d67f91 100644 --- a/caom2/caom2/tests/test_common.py +++ b/caom2/caom2/tests/test_common.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,9 +68,6 @@ """ Defines TestCaom2IdGenerator class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import binascii import unittest diff --git a/caom2/caom2/tests/test_diffs.py b/caom2/caom2/tests/test_diffs.py index ea5a6a4f..d14e8adb 100644 --- a/caom2/caom2/tests/test_diffs.py +++ b/caom2/caom2/tests/test_diffs.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2018. (c) 2018. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -66,8 +65,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) import os import unittest diff --git a/caom2/caom2/tests/test_obs_reader_writer.py b/caom2/caom2/tests/test_obs_reader_writer.py index 68f04114..528b8ca1 100644 --- a/caom2/caom2/tests/test_obs_reader_writer.py +++ b/caom2/caom2/tests/test_obs_reader_writer.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,14 +68,11 @@ """ Defines TestObservationReaderWriter class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import os import unittest from lxml import etree -from six import BytesIO +from io import BytesIO import tempfile from . import caom_test_instances @@ -1197,10 +1193,6 @@ def _validate_with_intent_type(self, intent_type=None): reader = obs_reader_writer.ObservationReader(True) reader.read(BytesIO(xml)) - def runTest(self): - # method required to make tests run on Python 2.7 - pass - def test_schema_validator(self): """ This function is to catch unsupported extensions to our schema. diff --git a/caom2/caom2/tests/test_observation.py b/caom2/caom2/tests/test_observation.py index fc22e790..bd8f5533 100644 --- a/caom2/caom2/tests/test_observation.py +++ b/caom2/caom2/tests/test_observation.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,9 +68,6 @@ """ Defines TestObservation class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest from datetime import datetime from builtins import str diff --git a/caom2/caom2/tests/test_part.py b/caom2/caom2/tests/test_part.py index 0bf6efe6..98e5286b 100644 --- a/caom2/caom2/tests/test_part.py +++ b/caom2/caom2/tests/test_part.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,9 +68,6 @@ """ Defines TestPart class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest from .. import chunk diff --git a/caom2/caom2/tests/test_plane.py b/caom2/caom2/tests/test_plane.py index 7d894076..b0a66f61 100644 --- a/caom2/caom2/tests/test_plane.py +++ b/caom2/caom2/tests/test_plane.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -69,9 +68,6 @@ """ Defines TestPlane class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest from datetime import datetime diff --git a/caom2/caom2/tests/test_shape.py b/caom2/caom2/tests/test_shape.py index 7f3ec1bb..3ced4b11 100644 --- a/caom2/caom2/tests/test_shape.py +++ b/caom2/caom2/tests/test_shape.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,9 +66,6 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import math import pytest import unittest diff --git a/caom2/caom2/tests/test_wcs.py b/caom2/caom2/tests/test_wcs.py index 7b166346..2263bd36 100644 --- a/caom2/caom2/tests/test_wcs.py +++ b/caom2/caom2/tests/test_wcs.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,9 +66,6 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest from builtins import int diff --git a/caom2/caom2/wcs.py b/caom2/caom2/wcs.py index ec2e6217..4c2b19c7 100644 --- a/caom2/caom2/wcs.py +++ b/caom2/caom2/wcs.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,9 +66,6 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - from builtins import str, int from . import caom_util diff --git a/caom2/setup.cfg b/caom2/setup.cfg index 7120d377..db8fa757 100644 --- a/caom2/setup.cfg +++ b/caom2/setup.cfg @@ -36,24 +36,21 @@ url = http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2 edit_on_github = False github_project = opencadc/caom2tools # version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) -version = 2.5 +version = 2.6 [options] install_requires = - future aenum - six deprecated - lxml<=4.3.0;python_version=="3.4" - lxml>=3.7.0;python_version>="3.5" + lxml>=3.7.0 [options.extras_require] test = pytest>=4.6 pytest-cov>=2.5.1 flake8>=3.4.1 - funcsigs==1.0.2 - mock==2.0.0 + funcsigs>=1.0.2 + mock>=2.0.0 [entry_points] caom2-checksum = caom2.checksum:checksum_diff diff --git a/caom2/setup.py b/caom2/setup.py index 8bf5c0e1..e3e4f467 100755 --- a/caom2/setup.py +++ b/caom2/setup.py @@ -90,14 +90,13 @@ def run_tests(self): use_2to3=False, setup_requires=['pytest-runner'], entry_points=entry_points, - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4', + python_requires='>=3.7, <4', packages=find_packages(), package_data={PACKAGENAME: ['data/*', 'tests/data/*', '*/data/*', '*/tests/data/*']}, classifiers=[ 'Natural Language :: English', 'License :: OSI Approved :: GNU Affero General Public License v3', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', ], cmdclass = { diff --git a/caom2repo/caom2repo/core.py b/caom2repo/caom2repo/core.py index d5cff2a4..c7cec5e3 100755 --- a/caom2repo/caom2repo/core.py +++ b/caom2repo/caom2repo/core.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2021. (c) 2021. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -66,9 +66,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import argparse import imp import logging @@ -85,8 +82,7 @@ from caom2.obs_reader_writer import ObservationReader, ObservationWriter from caom2 import obs_reader_writer from caom2.version import version as caom2_version -from six import BytesIO -from six.moves import xrange +from io import BytesIO # from . import version as caom2repo_version from caom2repo import version @@ -660,7 +656,7 @@ def main_app(): help='file containing observations to be visited', type=argparse.FileType('r')) visit_parser.add_argument( - '--threads', type=int, choices=xrange(2, 10), + '--threads', type=int, choices=range(2, 10), help='number of working threads used by the visitor when getting ' + 'observations, range is 2 to 10') visit_parser.add_argument( diff --git a/caom2repo/caom2repo/data/plugins/cadcschemeplugin.py b/caom2repo/caom2repo/data/plugins/cadcschemeplugin.py index 0c5412c7..9d442a24 100755 --- a/caom2repo/caom2repo/data/plugins/cadcschemeplugin.py +++ b/caom2repo/caom2repo/data/plugins/cadcschemeplugin.py @@ -1,10 +1,8 @@ -#!/usr/bin/env python2.7 -# # -*- coding: utf-8 -*- # *********************************************************************** # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2021. (c) 2021. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,8 +65,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) from caom2.observation import Observation diff --git a/caom2repo/caom2repo/data/plugins/daoformatplugin.py b/caom2repo/caom2repo/data/plugins/daoformatplugin.py index e509bde9..9ec2b568 100755 --- a/caom2repo/caom2repo/data/plugins/daoformatplugin.py +++ b/caom2repo/caom2repo/data/plugins/daoformatplugin.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -66,8 +66,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) from caom2.observation import Observation diff --git a/caom2repo/caom2repo/data/plugins/fuseformatplugin.py b/caom2repo/caom2repo/data/plugins/fuseformatplugin.py deleted file mode 100755 index 3d753b1f..00000000 --- a/caom2repo/caom2repo/data/plugins/fuseformatplugin.py +++ /dev/null @@ -1,93 +0,0 @@ -# # -*- coding: utf-8 -*- -# *********************************************************************** -# ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* -# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** -# -# (c) 2016. (c) 2016. -# Government of Canada Gouvernement du Canada -# National Research Council Conseil national de recherches -# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 -# All rights reserved Tous droits réservés -# -# NRC disclaims any warranties, Le CNRC dénie toute garantie -# expressed, implied, or énoncée, implicite ou légale, -# statutory, of any kind with de quelque nature que ce -# respect to the software, soit, concernant le logiciel, -# including without limitation y compris sans restriction -# any warranty of merchantability toute garantie de valeur -# or fitness for a particular marchande ou de pertinence -# purpose. NRC shall not be pour un usage particulier. -# liable in any event for any Le CNRC ne pourra en aucun cas -# damages, whether direct or être tenu responsable de tout -# indirect, special or general, dommage, direct ou indirect, -# consequential or incidental, particulier ou général, -# arising from the use of the accessoire ou fortuit, résultant -# software. Neither the name de l'utilisation du logiciel. Ni -# of the National Research le nom du Conseil National de -# Council of Canada nor the Recherches du Canada ni les noms -# names of its contributors may de ses participants ne peuvent -# be used to endorse or promote être utilisés pour approuver ou -# products derived from this promouvoir les produits dérivés -# software without specific prior de ce logiciel sans autorisation -# written permission. préalable et particulière -# par écrit. -# -# This file is part of the Ce fichier fait partie du projet -# OpenCADC project. OpenCADC. -# -# OpenCADC is free software: OpenCADC est un logiciel libre ; -# you can redistribute it and/or vous pouvez le redistribuer ou le -# modify it under the terms of modifier suivant les termes de -# the GNU Affero General Public la “GNU Affero General Public -# License as published by the License” telle que publiée -# Free Software Foundation, par la Free Software Foundation -# either version 3 of the : soit la version 3 de cette -# License, or (at your option) licence, soit (à votre gré) -# any later version. toute version ultérieure. -# -# OpenCADC is distributed in the OpenCADC est distribué -# hope that it will be useful, dans l’espoir qu’il vous -# but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE -# without even the implied GARANTIE : sans même la garantie -# warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ -# or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF -# PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence -# General Public License for Générale Publique GNU Affero -# more details. pour plus de détails. -# -# You should have received Vous devriez avoir reçu une -# a copy of the GNU Affero copie de la Licence Générale -# General Public License along Publique GNU Affero avec -# with OpenCADC. If not, see OpenCADC ; si ce n’est -# . pas le cas, consultez : -# . -# -# $Revision: 4 $ -# -# *********************************************************************** -# -from __future__ import (absolute_import, division, print_function, - unicode_literals) - -from caom2.observation import Observation - - -class ObservationUpdater(object): - """ObservationUpdater that adds a plane to the observation.""" - - def update(self, observation, **kwargs): - """ - Processes an observation and updates it - """ - assert isinstance(observation, Observation), ( - "observation {} is not an Observation".format(observation)) - - updated = False - for plane in observation.planes.values(): - for artifact in plane.artifacts.values(): - if artifact.content_type == 'application/x-gzip': - print('{}: {} -> text/plain'.format( - artifact.uri, artifact.content_type)) - artifact.content_type = 'text/plain' - updated = True - return updated diff --git a/caom2repo/caom2repo/data/plugins/ukirtformatplugin.py b/caom2repo/caom2repo/data/plugins/ukirtformatplugin.py deleted file mode 100755 index f2750d28..00000000 --- a/caom2repo/caom2repo/data/plugins/ukirtformatplugin.py +++ /dev/null @@ -1,93 +0,0 @@ -# # -*- coding: utf-8 -*- -# *********************************************************************** -# ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* -# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** -# -# (c) 2016. (c) 2016. -# Government of Canada Gouvernement du Canada -# National Research Council Conseil national de recherches -# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 -# All rights reserved Tous droits réservés -# -# NRC disclaims any warranties, Le CNRC dénie toute garantie -# expressed, implied, or énoncée, implicite ou légale, -# statutory, of any kind with de quelque nature que ce -# respect to the software, soit, concernant le logiciel, -# including without limitation y compris sans restriction -# any warranty of merchantability toute garantie de valeur -# or fitness for a particular marchande ou de pertinence -# purpose. NRC shall not be pour un usage particulier. -# liable in any event for any Le CNRC ne pourra en aucun cas -# damages, whether direct or être tenu responsable de tout -# indirect, special or general, dommage, direct ou indirect, -# consequential or incidental, particulier ou général, -# arising from the use of the accessoire ou fortuit, résultant -# software. Neither the name de l'utilisation du logiciel. Ni -# of the National Research le nom du Conseil National de -# Council of Canada nor the Recherches du Canada ni les noms -# names of its contributors may de ses participants ne peuvent -# be used to endorse or promote être utilisés pour approuver ou -# products derived from this promouvoir les produits dérivés -# software without specific prior de ce logiciel sans autorisation -# written permission. préalable et particulière -# par écrit. -# -# This file is part of the Ce fichier fait partie du projet -# OpenCADC project. OpenCADC. -# -# OpenCADC is free software: OpenCADC est un logiciel libre ; -# you can redistribute it and/or vous pouvez le redistribuer ou le -# modify it under the terms of modifier suivant les termes de -# the GNU Affero General Public la “GNU Affero General Public -# License as published by the License” telle que publiée -# Free Software Foundation, par la Free Software Foundation -# either version 3 of the : soit la version 3 de cette -# License, or (at your option) licence, soit (à votre gré) -# any later version. toute version ultérieure. -# -# OpenCADC is distributed in the OpenCADC est distribué -# hope that it will be useful, dans l’espoir qu’il vous -# but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE -# without even the implied GARANTIE : sans même la garantie -# warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ -# or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF -# PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence -# General Public License for Générale Publique GNU Affero -# more details. pour plus de détails. -# -# You should have received Vous devriez avoir reçu une -# a copy of the GNU Affero copie de la Licence Générale -# General Public License along Publique GNU Affero avec -# with OpenCADC. If not, see OpenCADC ; si ce n’est -# . pas le cas, consultez : -# . -# -# $Revision: 4 $ -# -# *********************************************************************** -# -from __future__ import (absolute_import, division, print_function, - unicode_literals) - -from caom2.observation import Observation - - -class ObservationUpdater(object): - """ObservationUpdater that adds a plane to the observation.""" - - def update(self, observation, **kwargs): - """ - Processes an observation and updates it - """ - assert isinstance(observation, Observation), ( - "observation {} is not an Observation".format(observation)) - - updated = False - for plane in observation.planes.values(): - for artifact in plane.artifacts.values(): - if artifact.content_type == 'application/vnd.Kinar': - print('{}: {} -> application/octet-stream'.format( - artifact.uri, artifact.content_type)) - artifact.content_type = 'application/octet-stream' - updated = True - return updated diff --git a/caom2repo/caom2repo/tests/addplaneplugin.py b/caom2repo/caom2repo/tests/addplaneplugin.py index 80fcb900..2ceea9b6 100755 --- a/caom2repo/caom2repo/tests/addplaneplugin.py +++ b/caom2repo/caom2repo/tests/addplaneplugin.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -66,8 +66,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) from caom2.observation import Observation from caom2.plane import Plane diff --git a/caom2repo/caom2repo/tests/artifacturiplugin.py b/caom2repo/caom2repo/tests/artifacturiplugin.py index 70553e9d..1df00fe8 100644 --- a/caom2repo/caom2repo/tests/artifacturiplugin.py +++ b/caom2repo/caom2repo/tests/artifacturiplugin.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -68,7 +68,7 @@ # from caom2 import Observation, ChecksumURI -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse from cadcdata import CadcDataClient from cadcutils import net from builtins import str diff --git a/caom2repo/caom2repo/tests/test_core.py b/caom2repo/caom2repo/tests/test_core.py index 5464594c..efcf028f 100644 --- a/caom2repo/caom2repo/tests/test_core.py +++ b/caom2repo/caom2repo/tests/test_core.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2021. (c) 2021. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -67,9 +67,6 @@ # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import copy import logging import os @@ -85,7 +82,7 @@ from caom2.observation import SimpleObservation from mock import Mock, patch, MagicMock, ANY, call # TODO to be changed to io.BytesIO when caom2 is prepared for python3 -from six import BytesIO, StringIO +from io import BytesIO, StringIO from caom2repo import core from caom2repo.core import CAOM2RepoClient diff --git a/caom2repo/setup.cfg b/caom2repo/setup.cfg index 195045e3..c1e60fe5 100644 --- a/caom2repo/setup.cfg +++ b/caom2repo/setup.cfg @@ -32,12 +32,12 @@ url = http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2 edit_on_github = False github_project = opencadc/caom2tools # version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) -version = 1.5.4 +version = 1.6 [options] install_requires = - cadcutils>=1.2.3 - caom2>=2.5 + cadcutils>=1.5.1 + caom2>=2.6 [options.extras_require] test = diff --git a/caom2repo/setup.py b/caom2repo/setup.py index ca242873..1a56f1f2 100755 --- a/caom2repo/setup.py +++ b/caom2repo/setup.py @@ -116,7 +116,7 @@ def run(self): use_2to3=False, setup_requires=['pytest-runner'], entry_points=entry_points, - python_requires='!=2.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4', + python_requires='>=3.7, <4', packages=find_packages(), package_data={PACKAGENAME: ['data/*', 'tests/data/*', '*/data/*', '*/tests/data/*']}, classifiers=[ diff --git a/caom2repo/tests/test-integration.py b/caom2repo/tests/test-integration.py index 04007765..983e4b2d 100644 --- a/caom2repo/tests/test-integration.py +++ b/caom2repo/tests/test-integration.py @@ -69,9 +69,6 @@ """ Defines TestCaom2IdGenerator class """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest import binascii import os diff --git a/caom2repo/tests/visitor-plugin.py b/caom2repo/tests/visitor-plugin.py index 2f44c629..46b20a00 100644 --- a/caom2repo/tests/visitor-plugin.py +++ b/caom2repo/tests/visitor-plugin.py @@ -3,7 +3,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2017. (c) 2017. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -66,8 +66,6 @@ # # *********************************************************************** # -from __future__ import (absolute_import, division, print_function, - unicode_literals) import logging diff --git a/caom2utils/README.rst b/caom2utils/README.rst index 7465184e..5ae49bab 100755 --- a/caom2utils/README.rst +++ b/caom2utils/README.rst @@ -13,8 +13,6 @@ Validates a CAOM2 element (Observation, Plane, Artifact, Part or Chunk) with res .. code:: python - from __future__ import (absolute_import, division, print_function, - unicode_literals) import sys from caom2 import SimpleObservation import caom2utils diff --git a/caom2utils/caom2utils/tests/test_fits2caom2.py b/caom2utils/caom2utils/tests/test_fits2caom2.py index d71d9841..fc341441 100755 --- a/caom2utils/caom2utils/tests/test_fits2caom2.py +++ b/caom2utils/caom2utils/tests/test_fits2caom2.py @@ -2,7 +2,7 @@ # ****************** CANADIAN ASTRONOMY DATA CENTRE ******************* # ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** # -# (c) 2016. (c) 2016. +# (c) 2022. (c) 2022. # Government of Canada Gouvernement du Canada # National Research Council Conseil national de recherches # Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 @@ -65,7 +65,6 @@ # # *********************************************************************** # -import io from astropy.io import fits from astropy.wcs import WCS as awcs @@ -94,7 +93,7 @@ from lxml import etree from unittest.mock import Mock, patch -from six import StringIO, BytesIO +from io import StringIO, BytesIO import importlib import os @@ -551,25 +550,31 @@ def test_help(): # missing productID when plane count is wrong with patch('sys.stderr', new_callable=StringIO) as stderr_mock: - bad_product_file = os.path.join(TESTDATA_DIR, 'bad_product_id.xml') - sys.argv = ["fits2caom2", "--in", bad_product_file, - "ad:CGPS/CGPS_MA1_HI_line_image.fits"] - with pytest.raises(MyExitError): - main_app() - result = stderr_mock.getvalue() - assert bad_product_id in result, result + with patch('sys.stdout', new_callable=StringIO) as stdout_mock: + bad_product_file = os.path.join(TESTDATA_DIR, 'bad_product_id.xml') + sys.argv = ["fits2caom2", "--in", bad_product_file, + "ad:CGPS/CGPS_MA1_HI_line_image.fits"] + with pytest.raises(MyExitError): + main_app() + # inconsistencies between Python 3.7 and later versions. + # this should be on stderr_mmock only + result = stderr_mock.getvalue() + stdout_mock.getvalue() + assert bad_product_id in result, result # missing productID when blueprint doesn't have one either - with patch('sys.stderr', new_callable=StringIO) as stderr_mock, \ - patch('caom2utils.data_util.StorageClientWrapper'): - sys.argv = ["fits2caom2", "--observation", "test_collection_id", - "test_observation_id", - "ad:CGPS/CGPS_MA1_HI_line_image.fits", - "--resource-id", "ivo://cadc.nrc.ca/uvic/minoc"] - with pytest.raises(MyExitError): - main_app() - result = stderr_mock.getvalue() - assert missing_product_id.strip() in result, result + with patch('sys.stdout', new_callable=StringIO) as stdout_mock: + with patch('sys.stderr', new_callable=StringIO) as stderr_mock, \ + patch('caom2utils.data_util.StorageClientWrapper'): + sys.argv = ["fits2caom2", "--observation", "test_collection_id", + "test_observation_id", + "ad:CGPS/CGPS_MA1_HI_line_image.fits", + "--resource-id", "ivo://cadc.nrc.ca/uvic/minoc"] + with pytest.raises(MyExitError): + main_app() + # inconsistencies between Python 3.7 and later versions. + # this should be on stderr_mmock only + result = stderr_mock.getvalue() + stdout_mock.getvalue() + assert missing_product_id.strip() in result, result # missing required --observation """ @@ -1571,7 +1576,7 @@ def test_update_artifact_meta_errors(): @patch('caom2utils.data_util.StorageInventoryClient', autospec=True) @patch('cadcutils.net.ws.WsCapabilities.get_access_url', autospec=True) -@patch('sys.stdout', new_callable=BytesIO) +@patch('sys.stdout', new_callable=StringIO) @patch('caom2utils.caom2blueprint._augment') def test_gen_proc_failure(augment_mock, stdout_mock, cap_mock, client_mock): """ Tests that gen_proc can return -1.""" @@ -1587,14 +1592,9 @@ def test_gen_proc_failure(augment_mock, stdout_mock, cap_mock, client_mock): test_blueprints = {'test_collection_id': ObsBlueprint()} test_result = gen_proc(test_args, test_blueprints) assert test_result == -1, 'expect failure' - if stdout_mock.getvalue(): - expected = _get_obs(EXPECTED_GENERIC_PARSER_FILE_SCHEME_XML) - actual = _get_obs(stdout_mock.getvalue().decode('ascii')) - result = get_differences(expected, actual, 'Observation') - assert result is None -@patch('sys.stdout', new_callable=io.StringIO) +@patch('sys.stdout', new_callable=StringIO) @patch('caom2utils.caom2blueprint.Client') def test_parser_construction(vos_mock, stdout_mock): vos_mock.get_node.side_effect = _get_node diff --git a/caom2utils/caom2utils/tests/test_obs_blueprint.py b/caom2utils/caom2utils/tests/test_obs_blueprint.py index 4bd26b74..2a1f8a62 100644 --- a/caom2utils/caom2utils/tests/test_obs_blueprint.py +++ b/caom2utils/caom2utils/tests/test_obs_blueprint.py @@ -130,11 +130,7 @@ def test_obs_blueprint(): ob.set_default('Observation.proposal.id', 'NOPROP') assert ob._plan['Observation.proposal.id'][0] == ['PROP2', 'PROP', 'RUNID'] assert ob._plan['Observation.proposal.id'][1] == 'NOPROP' - if sys.version.startswith('2.7.'): - assert ("Observation.proposal.id = ['PROP2', 'PROP', u'RUNID'], " - "default = NOPROP") in str(ob) - else: - assert ("Observation.proposal.id = ['PROP2', 'PROP', 'RUNID'], " + assert ("Observation.proposal.id = ['PROP2', 'PROP', 'RUNID'], " "default = NOPROP") in str(ob) # set in extension diff --git a/caom2utils/setup.cfg b/caom2utils/setup.cfg index 462b5417..52d102c4 100644 --- a/caom2utils/setup.cfg +++ b/caom2utils/setup.cfg @@ -33,14 +33,14 @@ url = https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2 edit_on_github = False github_project = opencadc/caom2tools # version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386) -version = 1.6.6 +version = 1.7 [options] install_requires = - cadcdata==2.0 - caom2>=2.5 + cadcdata>=2.0 + caom2>=2.6 astropy>=2.0 - spherical-geometry>=1.2.11;python_version>="3.6" + spherical-geometry>=1.2.11 vos>=3.1.1 [options.extras_require] diff --git a/caom2utils/setup.py b/caom2utils/setup.py index 26fe2a69..2553885e 100755 --- a/caom2utils/setup.py +++ b/caom2utils/setup.py @@ -108,7 +108,7 @@ def run(self): use_2to3=False, setup_requires=['pytest-runner'], entry_points=entry_points, - python_requires='!=2.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4', + python_requires='>=3.7, <4', packages=find_packages(), package_data={PACKAGENAME: ['data/*', 'tests/data/*', '*/data/*', '*/tests/data/*']}, classifiers=[ diff --git a/caom2utils/tox.ini b/caom2utils/tox.ini index fa6032fe..5ed53ed5 100644 --- a/caom2utils/tox.ini +++ b/caom2utils/tox.ini @@ -5,7 +5,7 @@ name = caom2utils [tox] envlist = - py{36,37,38,39,310} + py{36,37,38,39,310,311} requires = pip >= 19.3.1