projects
/
invirt/packages/invirt-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
56adc1b
)
Don't use contextlib where it is no longer necessary
author
Ben Steffen
<bds@mit.edu>
Tue, 26 Nov 2019 19:49:54 +0000
(14:49 -0500)
committer
Ben Steffen
<bds@mit.edu>
Tue, 26 Nov 2019 19:49:54 +0000
(14:49 -0500)
python/invirt/config.py
patch
|
blob
|
history
diff --git
a/python/invirt/config.py
b/python/invirt/config.py
index
03b6a2d
..
245464b
100644
(file)
--- a/
python/invirt/config.py
+++ b/
python/invirt/config.py
@@
-1,7
+1,6
@@
import json
from invirt.common import *
import os
import json
from invirt.common import *
import os
-from contextlib import closing
import yaml
import re
import yaml
import re
@@
-59,7
+58,7
@@
def list_files():
def load_master():
config = dict()
for filename in list_files():
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
augment(config, yaml.load(f, loader))
return config
@@
-112,7
+111,7
@@
def load(force_refresh = False):
# lock with other concurrent reads). This isolation is accomplished
# using an atomic filesystem rename in the refreshing stage.
try:
# 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
ns.cfg = json.read(f.read())
except: do_refresh = True
@@
-127,7
+126,7
@@
def load(force_refresh = False):
with lock_file(lock_path):
ns.cfg = load_master()
try:
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)
f.write(json.write(ns.cfg))
except: pass # silent failure
else: os.rename(cache_path + '.tmp', cache_path)