Unverified Commit 3e7edd6c authored by Maxim Baz's avatar Maxim Baz
Browse files

Port nicer repo load code to all scripts

parent 405ebc91
......@@ -13,6 +13,7 @@ from lib.dbwrite import generate_dbs
async def main(repo_from, repo_to, pkgbases) -> int:
metadir = (Path(argv[0]).parent / "meta").resolve(strict=True)
# FIXME: Put this into metadir/.git/
lockfile = (metadir / "dbscripts.lock").open(mode="w")
flock(lockfile, LOCK_EX)
......@@ -27,13 +28,15 @@ async def main(repo_from, repo_to, pkgbases) -> int:
raise RuntimeError("repo_from and repo_to cannot be the same")
# load existing repo metadata
meta = {
repo: {
p.stem: json.load((metadir / repo / p).open())
for p in (metadir / repo).glob("*.json")
}
for repo in [repo_from, repo_to]
}
def json_load(path):
with path.open() as f:
return json.load(f)
def repo_load(repo):
repodir = metadir / repo
return {p.stem: json_load(repodir / p) for p in repodir.glob("*.json")}
meta = {repo: repo_load(repo) for repo in [repo_from, repo_to]}
# validate that the move is possible
for pkgbase in pkgbases:
......
......@@ -13,6 +13,7 @@ from lib.dbwrite import generate_dbs
async def main(repo, pkgbases) -> int:
metadir = (Path(argv[0]).parent / "meta").resolve(strict=True)
# FIXME: Put this into metadir/.git/
lockfile = (metadir / "dbscripts.lock").open(mode="w")
flock(lockfile, LOCK_EX)
......@@ -21,12 +22,15 @@ async def main(repo, pkgbases) -> int:
raise RuntimeError(f"repo '{repo}' is not allowed")
# load existing repo metadata
meta = {
repo: {
p.stem: json.load((metadir / repo / p).open())
for p in (metadir / repo).glob("*.json")
}
}
def json_load(path):
with path.open() as f:
return json.load(f)
def repo_load(repo):
repodir = metadir / repo
return {p.stem: json_load(repodir / p) for p in repodir.glob("*.json")}
meta = {repo: repo_load(repo)}
# remove packages from meta and corresponding json files
for pkgbase in pkgbases:
......
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