From 45d466e6e52d52966147b5d61178daef9b98032b Mon Sep 17 00:00:00 2001 From: mar77i Date: Mon, 20 May 2024 17:40:34 +0200 Subject: [PATCH] clean up code, add ga-cli --- gitweb_configs.py | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/gitweb_configs.py b/gitweb_configs.py index 514d823..660b6c2 100755 --- a/gitweb_configs.py +++ b/gitweb_configs.py @@ -7,30 +7,13 @@ from shutil import rmtree from subprocess import CalledProcessError, check_output, run GITWEB_CONFIGS = { - "admin": { - "owner": "mar77i ", - "description": "admin scripts", - }, - "mar77i.info": { - "owner": "mar77i ", - "description": "mar77i.info website", - }, - "hublib": { - "owner": "mar77i ", - "description": "base for websocket toys", - }, - "laptop-config": { - "owner": "mar77i ", - "description": "laptop screen configuration", - }, - "rcfiles": { - "owner": "mar77i ", - "description": "user configuration files", - }, - "bigintmandel": { - "owner": "mar77i ", - "description": "Qt mandelbrot toy, with big integers only", - }, + "admin": "admin scripts", + "mar77i.info": "mar77i.info website", + "hublib": "base for websocket toys", + "laptop-config": "laptop screen configuration", + "rcfiles": "user configuration files", + "bigintmandel": "Qt mandelbrot toy, with big integers only", + "ga-cli": "Google authenticator for CLI", } @@ -40,7 +23,7 @@ def main(): if p.is_dir() and p.name not in GITWEB_CONFIGS: rmtree(p) print(f"removed {p.name}") - for repository, configs in GITWEB_CONFIGS.items(): + for repository, description in GITWEB_CONFIGS.items(): p = base_dir / repository if not p.exists(): p.mkdir(0o755) @@ -49,14 +32,18 @@ def main(): print(f"created {p.name}") else: os.chdir(p) - description = p / "description" - if description.exists(): - description.unlink() - assert set(configs) == {"owner", "description"} + description_path = p / "description" + if description_path.exists(): + description_path.unlink() + configs = { + "owner": "mar77i ", + "description": description, + } for key, value in configs.items(): try: output = check_output( - ["git", "config", "--get", f"gitweb.{key}"], universal_newlines=True + ["git", "config", "--get", f"gitweb.{key}"], + universal_newlines=True, ) except CalledProcessError: output = None -- 2.47.0