From b6b8b7810adc341d6a4b455ac96f26e70907a660 Mon Sep 17 00:00:00 2001
From: Maeva Pourpoint <maeva@passcal.nmt.edu>
Date: Thu, 10 Sep 2020 09:40:31 -0600
Subject: [PATCH] Port Python 2 code to Python 3

---
 docs/conf.py           | 14 +++++++-------
 refscrub/refscrub.py   |  5 ++---
 setup.py               |  6 ++++--
 tests/test_refscrub.py |  6 +-----
 4 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 3971c64..6e27d97 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -47,9 +47,9 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'refscrub'
-copyright = u"2018, IRIS PASSCAL"
-author = u"IRIS PASSCAL"
+project = 'refscrub'
+copyright = "2018, IRIS PASSCAL"
+author = "IRIS PASSCAL"
 
 # The version info for the project you're documenting, acts as replacement
 # for |version| and |release|, also used in various other places throughout
@@ -129,8 +129,8 @@ latex_elements = {
 # [howto, manual, or own class]).
 latex_documents = [
     (master_doc, 'refscrub.tex',
-     u'refscrub Documentation',
-     u'IRIS PASSCAL', 'manual'),
+     'refscrub Documentation',
+     'IRIS PASSCAL', 'manual'),
 ]
 
 
@@ -140,7 +140,7 @@ latex_documents = [
 # (source start file, name, description, authors, manual section).
 man_pages = [
     (master_doc, 'refscrub',
-     u'refscrub Documentation',
+     'refscrub Documentation',
      [author], 1)
 ]
 
@@ -152,7 +152,7 @@ man_pages = [
 #  dir menu entry, description, category)
 texinfo_documents = [
     (master_doc, 'refscrub',
-     u'refscrub Documentation',
+     'refscrub Documentation',
      author,
      'refscrub',
      'One line description of project.',
diff --git a/refscrub/refscrub.py b/refscrub/refscrub.py
index ae66381..ff6f301 100644
--- a/refscrub/refscrub.py
+++ b/refscrub/refscrub.py
@@ -14,7 +14,6 @@ Updates to work on both Python 2 & 3.
 Code cleanup to match PEP 8.
 Cleanup global vars.
 """
-from __future__ import (print_function, with_statement)
 from os.path import join, basename, getsize
 import sys
 import struct
@@ -63,12 +62,12 @@ class SNseen(dict):
         ret.look(year, day, hour)
 
     def close_fhs(self):
-        for sn in self.values():
+        for sn in list(self.values()):
             sn.close_fh()
 
     def __str__(self):
         s = "     SN: YR:DAY:HR -- YR:DAY:HR : %12s\n" % 'Good Packets'
-        for sn in self.values():
+        for sn in list(self.values()):
             s += str(sn)
         return s
 
diff --git a/setup.py b/setup.py
index 288cc8f..1dbc630 100644
--- a/setup.py
+++ b/setup.py
@@ -5,10 +5,10 @@
 
 from setuptools import setup, find_packages
 
-with open('README.rst') as readme_file:
+with open('README.rst', 'rt') as readme_file:
     readme = readme_file.read()
 
-with open('HISTORY.rst') as history_file:
+with open('HISTORY.rst', 'rt') as history_file:
     history = history_file.read()
 
 
@@ -21,6 +21,8 @@ setup(
         'License :: OSI Approved ::  GNU General Public License v3 (GPLv3)',
         'Natural Language :: English',
         'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
+        'Programming Language :: Python :: 3.8',
     ],
     description="Remove select packets from RT130 data",
     entry_points={
diff --git a/tests/test_refscrub.py b/tests/test_refscrub.py
index 6af0b2d..56529bb 100644
--- a/tests/test_refscrub.py
+++ b/tests/test_refscrub.py
@@ -21,8 +21,4 @@ class TestRefscrub(unittest.TestCase):
         """Tear down test fixtures, if any."""
 
     def test_import(self):
-        if 'refscrub' in sys.modules:
-            self.assert_(True, "refscrub loaded")
-        else:
-            self.fail()
-
+        self.assertTrue('refscrub' in sys.modules, "Refscrub import failed!")
-- 
GitLab