diff martini/main.py @ 23:858fb3bfacfe default tip

python3
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Apr 2021 15:04:15 -0700
parents 112cb171b419
children
line wrap: on
line diff
--- a/martini/main.py	Sat Apr 24 15:01:29 2021 -0700
+++ b/martini/main.py	Sat Apr 24 15:04:15 2021 -0700
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 """
 main front-end functions for command-line programs
 """
@@ -74,16 +72,17 @@
         if f == '-':
             fp = sys.stdin
         else:
-            fp = file(f)
+            fp = open(f)
         munger = config.ConfigMunger(fp, sections)
 
         if f == '-':
             fp = sys.stdout
         else:
             fp.close()
-            fp = file(f, "w")
+            fp = open(f, "w")
         munger.write(fp=fp)
-       
+
+
 def get(args=None):
 
     usage = "%s file1 [file2] [...] --section1 option1 option2 --section2 option3"
@@ -104,7 +103,7 @@
         if f == '-':
             fp = sys.stdin
         else:
-            fp = file(f)
+            fp = open(f)
         munger = config.ConfigMunger(fp)
         for section, options in sections:
             if section in munger.sections():
@@ -136,7 +135,7 @@
         if f == '-':
             fp = sys.stdin
         else:
-            fp = file(f)
+            fp = open(f)
         conf = config.ConfigMunger(fp).dict()
         for section, options in sections:
             if section in conf:
@@ -178,10 +177,7 @@
     conf.append(sections)
     munger = config.ConfigMunger(*conf)
     if options.output:
-        fp = file(options.output, 'w')
+        fp = open(options.output, 'w')
     else:
         fp = sys.stdout
     munger.write(fp)
- 
-if __name__ == '__main__':
-    set(sys.argv[1:])