Move all imports to top of file and organize
authorBen Steffen <bds@mit.edu>
Wed, 8 Jan 2020 03:17:24 +0000 (22:17 -0500)
committerBen Steffen <bds@mit.edu>
Wed, 8 Jan 2020 03:32:16 +0000 (22:32 -0500)
python/invirt/authz.py
python/invirt/common.py
python/invirt/config.py
python/invirt/remctl.py
scripts/invirt-getconf
scripts/invirt-mako-render

index f5f02a0..53ffc03 100644 (file)
@@ -8,7 +8,6 @@ a unique name. That name can then be configured in
 /etc/invirt/master.yaml as the authz mechanism.
 """
 
-
 import pkg_resources
 
 from invirt.config import structs as cfg
index 57fea45..a8d62a0 100644 (file)
@@ -1,10 +1,9 @@
-from __future__ import with_statement
-
 import unittest
 from fcntl import flock, LOCK_EX, LOCK_SH, LOCK_UN
 import contextlib as clib
 import subprocess
 
+
 class InvirtConfigError(AttributeError):
     pass
 
index 626b76a..b96e942 100644 (file)
@@ -1,7 +1,4 @@
-from __future__ import with_statement
-
 import json
-from invirt.common import *
 import os
 from os import rename
 from os.path import getmtime
@@ -9,6 +6,9 @@ from contextlib import closing
 import yaml
 import re
 
+from invirt.common import *
+
+
 try:    loader = yaml.CSafeLoader
 except: loader = yaml.SafeLoader
 
@@ -141,4 +141,5 @@ def load(force_refresh = False):
 
 dicts = load()
 structs = dicts2struct(dicts, '')
+
 safestructs = dicts2struct(dicts, '', '')
index 956ca2d..9dbe8bd 100644 (file)
@@ -2,11 +2,13 @@
 Functions to perform remctls.
 """
 
-from invirt.common import CodeError
 import subprocess
 import sys
 from socket import getfqdn
 
+from invirt.common import CodeError
+
+
 def kinit(principal=None, keytab=None):
     """Kinit with a given username and keytab"""
     if principal is None:
index d07b215..e5563a4 100755 (executable)
@@ -16,9 +16,12 @@ Examples:
   invirt-getconf hosts.0.ip
 """
 
-from invirt import config
 from sys import argv, exit, stderr, stdout
 from optparse import OptionParser
+import yaml
+
+from invirt import config
+
 
 class invirt_exception(Exception): pass
 
@@ -73,7 +76,6 @@ def main(argv):
             if type(conf) not in (dict, list):
                 print conf
             else:
-                import yaml
                 yaml.dump(conf, stdout,
                           Dumper=yaml.CSafeDumper, default_flow_style=False)
     except invirt_exception, ex:
index 1eaeede..2cd2ffb 100755 (executable)
@@ -2,23 +2,23 @@
 # Modified from mako-render by gdb.
 # TODO: set the lookup path dynamically.
 
-def render(data):
-    from mako.template import Template
-    from mako.lookup import TemplateLookup
+from os.path import isfile
+from sys import stdin
+import sys
+from optparse import OptionParser
+
+from mako.template import Template
+from mako.lookup import TemplateLookup
+
 
+def render(data):
     lookup = TemplateLookup(['.', '/etc/apache2/conf.invirt'])
     return Template(data, lookup=lookup).render()
 
 def main(argv=None):
-    from os.path import isfile
-    from sys import stdin
-
     if argv is None:
-        import sys
         argv = sys.argv
 
-    from optparse import OptionParser
-
     parser = OptionParser("usage: %prog [FILENAME]")
 
     opts, args = parser.parse_args(argv[1:])