Commit 9428a3bb authored by Zixian Cai's avatar Zixian Cai

os.PathLike is not a thing in Python < 3.6

parent 4c0e27bb
...@@ -35,7 +35,7 @@ class LocalStorage(Storage): ...@@ -35,7 +35,7 @@ class LocalStorage(Storage):
def load(cls, repo, host, rev): def load(cls, repo, host, rev):
dirname = cls.STORAGE_PATH / repo / host dirname = cls.STORAGE_PATH / repo / host
filename = dirname.glob("{}*".format(rev)).__next__() filename = dirname.glob("{}*".format(rev)).__next__()
with open(filename) as logfile: with filename.open() as logfile:
l = json.load(logfile) l = json.load(logfile)
attach_info(l, str(filename.stem)) attach_info(l, str(filename.stem))
return l return l
...@@ -45,7 +45,7 @@ class LocalStorage(Storage): ...@@ -45,7 +45,7 @@ class LocalStorage(Storage):
dirname = cls.STORAGE_PATH / repo / host dirname = cls.STORAGE_PATH / repo / host
filename = dirname / "{}_{}".format(rev, timestamp) filename = dirname / "{}_{}".format(rev, timestamp)
os.makedirs(os.path.dirname(str(filename.absolute())), exist_ok=True) os.makedirs(os.path.dirname(str(filename.absolute())), exist_ok=True)
with open(filename, "w") as logfile: with filename.open("w") as logfile:
logfile.write(text_form) logfile.write(text_form)
@classmethod @classmethod
...@@ -55,7 +55,7 @@ class LocalStorage(Storage): ...@@ -55,7 +55,7 @@ class LocalStorage(Storage):
[f.stem for f in dirname.iterdir() if not f.stem.startswith(".")], [f.stem for f in dirname.iterdir() if not f.stem.startswith(".")],
key=lambda x: int(x.split("_")[1])) key=lambda x: int(x.split("_")[1]))
filename = dirname / fs[-(1 + num)] filename = dirname / fs[-(1 + num)]
with open(filename) as logfile: with filename.open() as logfile:
l = json.load(logfile) l = json.load(logfile)
attach_info(l, str(filename.stem)) attach_info(l, str(filename.stem))
return l return l
...@@ -68,7 +68,7 @@ class LocalStorage(Storage): ...@@ -68,7 +68,7 @@ class LocalStorage(Storage):
key=lambda x: int(x.split("_")[1])) key=lambda x: int(x.split("_")[1]))
results = [] results = []
for f in fs: for f in fs:
with open(dirname / f) as logfile: with (dirname / f).open() as logfile:
l = json.load(logfile) l = json.load(logfile)
attach_info(l, str((dirname / f).stem)) attach_info(l, str((dirname / f).stem))
results.append(l) results.append(l)
......
...@@ -309,7 +309,7 @@ def load_file(config_files): ...@@ -309,7 +309,7 @@ def load_file(config_files):
tasksets = [] tasksets = []
for config_file in config_files: for config_file in config_files:
config_file = Path(config_file).resolve() config_file = Path(config_file).resolve()
with open(config_file) as fp: with config_file.open() as fp:
tasksets.extend(load_yaml(fp.read(), tasksets.extend(load_yaml(fp.read(),
config_file.parent)) config_file.parent))
return tasksets return tasksets
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment