changeset 92:36f5d31c3ed6

partial upgrade to py3.7
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 May 2020 14:43:00 -0700
parents 823c5c26fe66
children 93cf6ebe8a94
files pyloader/__init__.py pyloader/cast.py pyloader/factory.py pyloader/invoke.py pyloader/loader.py pyloader/parser.py tox.ini
diffstat 7 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pyloader/__init__.py	Wed Apr 12 12:47:44 2017 -0700
+++ b/pyloader/__init__.py	Sun May 10 14:43:00 2020 -0700
@@ -1,2 +1,2 @@
 # import front-ends
-from loader import *
+from .loader import *
--- a/pyloader/cast.py	Wed Apr 12 12:47:44 2017 -0700
+++ b/pyloader/cast.py	Sun May 10 14:43:00 2020 -0700
@@ -54,11 +54,11 @@
 cast = StringCaster(*casts)
 
 # cast by type
-cast_dict = dict([(i,i) for i in int, float])
+cast_dict = dict([(i,i) for i in (int, float)])
 cast_dict[bool] = str2bool
 cast_dict[tuple] = cast_dict[list] = str2list
 
 if __name__ == '__main__':
   import sys
   for arg in sys.argv[1:]:
-    print cast(arg)
+    print(cast(arg))
--- a/pyloader/factory.py	Wed Apr 12 12:47:44 2017 -0700
+++ b/pyloader/factory.py	Sun May 10 14:43:00 2020 -0700
@@ -4,8 +4,8 @@
 abstract factories
 """
 
-import cast
-import loader
+from . import cast
+from . import loader
 import os
 import sys
 from copy import deepcopy
@@ -270,6 +270,7 @@
 
         return cls.configuration(config, **parser.defaults())
 
+
 def main(args=sys.argv[1:]):
     """command line entry point"""
     usage = '%prog file1.ini -arg1 -arg2 --key1=value1 --key2=value2'
@@ -282,7 +283,8 @@
 
     factory = IniFactory(args[0])
     obj = factory.load()
-    print obj
+    print (obj)
+
 
 if __name__ == '__main__':
     main()
--- a/pyloader/invoke.py	Wed Apr 12 12:47:44 2017 -0700
+++ b/pyloader/invoke.py	Sun May 10 14:43:00 2020 -0700
@@ -13,7 +13,7 @@
     # - you should also be able to provide your own casts
     # This will have to be made an object in order to actually do this
     # so that these parameters may be provided to __init__
-    
+
     inspected = obj
     if inspect.isclass(obj):
         inspected = obj.__init__ # inspect the ctor
@@ -47,8 +47,10 @@
             kw[arg] = kwargs[arg]
     return obj(**kw)
 
+
 def main(args=sys.argv[1:]):
     """CLI entry point"""
+
     from loader import load
     from optparse import OptionParser
     usage = '%prog Object arg1=value1 arg2=value2 [...]'
@@ -59,7 +61,7 @@
         parser.exit()
     obj = load(args[0])
     obj_args, obj_kwargs = str2args(' '.join(args[1:]))
-    print strcall(obj, *obj_args, **obj_kwargs)
+    print(strcall(obj, *obj_args, **obj_kwargs))
 
 if __name__ == '__main__':
     main()
--- a/pyloader/loader.py	Wed Apr 12 12:47:44 2017 -0700
+++ b/pyloader/loader.py	Sun May 10 14:43:00 2020 -0700
@@ -45,7 +45,7 @@
       # module: dotted path
       return import_dotted_path(string)
   except:
-    print string
+    print (string)
     raise
 
   # TODO: entry points
@@ -53,4 +53,4 @@
 if __name__ == '__main__':
   import sys
   for i in sys.argv[1:]:
-    print load(i)
+    print(load(i))
--- a/pyloader/parser.py	Wed Apr 12 12:47:44 2017 -0700
+++ b/pyloader/parser.py	Sun May 10 14:43:00 2020 -0700
@@ -40,9 +40,10 @@
         raise Exception
     return _args1, _args2, kw
 
+
 if __name__ == '__main__':
     import sys
     args, positional_args, kwargs = parse(sys.argv[1:])
-    print args
-    print positional_args
-    print kwargs
+    print (args)
+    print (positional_args)
+    print (kwargs)
--- a/tox.ini	Wed Apr 12 12:47:44 2017 -0700
+++ b/tox.ini	Sun May 10 14:43:00 2020 -0700
@@ -1,5 +1,5 @@
 # https://tox.readthedocs.io/en/latest/
 [tox]
-envlist=py27
+envlist=py27,py37
 [testenv]
 commands=python setup.py test
\ No newline at end of file