yield from run_parts_list(SRC_DIRPATH)
def load_master():
- config = dict()
+ cfg = dict()
for filename in list_files():
with open(filename) as f:
- augment(config, yaml.load(f, yaml.CSafeLoader))
- return config
+ augment(cfg, yaml.load(f, yaml.CSafeLoader))
+ return cfg
def get_src_mtime():
return max(max(os.path.getmtime(filename) for filename in list_files()),
I assume I have the permissions to write to the cache directory.
"""
- # Namespace container for state variables, so that they can be updated by
- # closures.
- ns = struct()
+ cfg = dict()
if force_refresh:
do_refresh = True
# using an atomic filesystem rename in the refreshing stage.
try:
with open(CACHE_PATH) as f:
- ns.cfg = json.read(f.read())
+ cfg = json.load(f)
except:
do_refresh = True
# acquire the lock, just try to load the master configuration.
try:
with invirt.common.open_locked(LOCK_PATH):
- ns.cfg = load_master()
+ cfg = load_master()
try:
with open(CACHE_PATH + '.tmp', 'w') as f:
- f.write(json.write(ns.cfg))
+ json.dump(cfg, f)
except:
pass # silent failure
else:
os.rename(CACHE_PATH + '.tmp', CACHE_PATH)
except IOError:
- ns.cfg = load_master()
- return ns.cfg
+ cfg = load_master()
-dicts = load()
-structs = dicts2struct(dicts, '')
+ return cfg
+
+config = load()