Increase Python 3 compatibility (`print()` and `except ... as ...`).
authorW. Trevor King <wking@drexel.edu>
Fri, 30 Mar 2012 03:36:34 +0000 (23:36 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 30 Mar 2012 03:36:34 +0000 (23:36 -0400)
h5config/config.py
h5config/storage/hdf5.py
h5config/storage/yaml.py
h5config/test.py

index 478ac3f44939f3ef38c160c4fb5486f73d1ae6dd..09037dd2f8a3d2bf4a935c0f7680e4422a3138f3 100644 (file)
@@ -167,8 +167,8 @@ class FloatSetting (NumericSetting):
     8.0
     >>> try:
     ...     s.convert_from_text('invalid')
-    ... except ValueError, e:
-    ...     print 'caught a ValueError'
+    ... except ValueError as e:
+    ...     print('caught a ValueError')
     caught a ValueError
     """
     def __init__(self, default=1.0, **kwargs):
@@ -333,11 +333,11 @@ class Config (dict):
         ...             default=2),
         ...         ]
         >>> c = MyConfig()
-        >>> print c.dump()
+        >>> print(c.dump())
         number: one
         odd: yes
         guesses: 2
-        >>> print c.dump(help=True)  # doctest: +NORMALIZE_WHITESPACE
+        >>> print(c.dump(help=True))  # doctest: +NORMALIZE_WHITESPACE
         number: one (I have a number behind my back...  Default: one.
                      Choices: one, two)
         odd: yes    (The number behind my back is odd.  Default: yes.
index 6af6b2decfe64a96e80fddf79f6c0fd4e29ead8d..79e968200741299b030f7af040cb53c0dea47580 100644 (file)
@@ -30,14 +30,14 @@ from . import FileStorage as _FileStorage
 
 
 def pprint_HDF5(*args, **kwargs):
-    print pformat_HDF5(*args, **kwargs)
+    print(pformat_HDF5(*args, **kwargs))
 
 def pformat_HDF5(filename, group='/'):
     try:
         with _h5py.File(filename, 'r') as f:
             cwg = f[group]
             ret = '\n'.join(_pformat_hdf5(cwg))
-    except IOError, e:
+    except IOError as e:
         if 'unable to open' in e.message:
             if _os_path.getsize(filename) == 0:
                 return 'EMPTY'
@@ -204,7 +204,7 @@ class HDF5_Storage (_FileStorage):
                 else:
                     try:
                         v = group[s.name][...]
-                    except Exception, e:
+                    except Exception as e:
                         _LOG.error('Could not access {}/{}: {}'.format(
                                 group.name, s.name, e))
                         raise 
index 7999d20d03791627de7fa1e55d327676597f1f6a..9b61c6ecec157eb693513a784c62536bfa56327b 100644 (file)
@@ -61,7 +61,7 @@ class YAML_Storage (_FileStorage):
 
     >>> c['alive'] = True
     >>> c.save()
-    >>> print open(filename, 'r').read()  # doctest: +REPORT_UDIFF
+    >>> print(open(filename, 'r').read())  # doctest: +REPORT_UDIFF
     age: 1.3
     alive: yes
     bids:
index 7da3af47d3751604e8b1b0c7a363e3ca8af6eb3c..ac22c107d7fb3950bdbd9bf84c3043229d0f4245 100644 (file)
@@ -66,7 +66,7 @@ Saving fills in all the config values.
 
 If you want more details, you can dump with help strings.
 
->>> print c.dump(help=True)  # doctest: +REPORT_UDIFF, +NORMALIZE_WHITESPACE
+>>> print(c.dump(help=True))  # doctest: +REPORT_UDIFF, +NORMALIZE_WHITESPACE
 name:                    (The parrot's name.  Default: .)
 species: Norwegian Blue  (Type of parrot.  Default: Norwegian Blue.
                           Choices: Norwegian Blue, Macaw)