Fix formatting
authorBen Steffen <bds@mit.edu>
Tue, 26 Nov 2019 21:10:54 +0000 (16:10 -0500)
committerBen Steffen <bds@mit.edu>
Tue, 26 Nov 2019 21:10:54 +0000 (16:10 -0500)
python/invirt/config.py

index 93d61c7..f9bff6a 100644 (file)
@@ -69,7 +69,7 @@ def get_src_mtime():
     return max(max(os.path.getmtime(filename) for filename in list_files()),
                os.path.getmtime(src_dirpath))
 
-def load(force_refresh = False):
+def load(force_refresh=False):
     """
     Try loading the configuration from the faster-to-load JSON cache at
     cache_path.  If it doesn't exist or is outdated, load the configuration
@@ -85,9 +85,12 @@ def load(force_refresh = False):
         do_refresh = True
     else:
         src_mtime = get_src_mtime()
-        try:            cache_mtime = os.path.getmtime(cache_path)
-        except OSError: do_refresh  = True
-        else:           do_refresh  = src_mtime + 1 >= cache_mtime
+        try:
+            cache_mtime = os.path.getmtime(cache_path)
+        except OSError:
+            do_refresh  = True
+        else:
+            do_refresh  = src_mtime + 1 >= cache_mtime
 
         # We chose not to simply say
         #
@@ -113,10 +116,11 @@ def load(force_refresh = False):
         # (changing) version of the data (but the transaction can share the
         # lock with other concurrent reads).  This isolation is accomplished
         # using an atomic filesystem rename in the refreshing stage.
-        try: 
+        try:
             with open(cache_path) as f:
                 ns.cfg = json.read(f.read())
-        except: do_refresh = True
+        except:
+            do_refresh = True
 
     if do_refresh:
         # Atomically reload the source and regenerate the cache.  The read and
@@ -128,11 +132,13 @@ def load(force_refresh = False):
         try:
             with invirt.common.open_locked(lock_path):
                 ns.cfg = load_master()
-                try: 
+                try:
                     with open(cache_path + '.tmp', 'w') as f:
                         f.write(json.write(ns.cfg))
-                except: pass # silent failure
-                else: os.rename(cache_path + '.tmp', cache_path)
+                except:
+                    pass # silent failure
+                else:
+                    os.rename(cache_path + '.tmp', cache_path)
         except IOError:
             ns.cfg = load_master()
     return ns.cfg