import json
from invirt.common import *
import os
-from contextlib import closing
import yaml
import re
def load_master():
config = dict()
for filename in list_files():
- with closing(open(filename)) as f:
+ with open(filename) as f:
augment(config, yaml.load(f, loader))
return config
# lock with other concurrent reads). This isolation is accomplished
# using an atomic filesystem rename in the refreshing stage.
try:
- with closing(open(cache_path)) as f:
+ with open(cache_path) as f:
ns.cfg = json.read(f.read())
except: do_refresh = True
with lock_file(lock_path):
ns.cfg = load_master()
try:
- with closing(open(cache_path + '.tmp', 'w')) as f:
+ 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)