From d64fccae8d3ef5f39af0da1ccfd5712ad503c0bb Mon Sep 17 00:00:00 2001 From: davidovski Date: Mon, 8 Nov 2021 22:22:39 +0000 Subject: separated verbs into submodules --- src/verbs/__init__.py | 0 src/verbs/sync.py | 20 ++++++++++++++++++++ src/xi.py | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/verbs/__init__.py create mode 100644 src/verbs/sync.py (limited to 'src') diff --git a/src/verbs/__init__.py b/src/verbs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/verbs/sync.py b/src/verbs/sync.py new file mode 100644 index 0000000..f23d4fc --- /dev/null +++ b/src/verbs/sync.py @@ -0,0 +1,20 @@ + + +# have separate list and download methods for each scheme +def sync_package_infos(source_name, url, repos): + scheme = url.split(":")[0] + + # TODO: add ftp + if scheme.startswith("http"): + sync_func = download_repo + else: + # Assume its a location on the file system + sync_func = copy_repo + + for repo in repos: + sync_func(output, url + f"/{repo}" if url[-1] == "/" else repo) + + +def sync(options, config): + sources = config["sources"] + print("Synced!") diff --git a/src/xi.py b/src/xi.py index 90930c2..9e723de 100644 --- a/src/xi.py +++ b/src/xi.py @@ -1,14 +1,14 @@ import options import config +from verbs.sync import sync + def search(): pass def install(): pass def remove(): pass -def sync(): - pass verbs = { v: globals()[v] for v in [ "search", @@ -32,7 +32,7 @@ def main(): ( verbs[verb] if verb in verbs else search )( - args[1:] if len(args) > 1 else [] + args[1:] if len(args) > 1 else [], conf ) else: options.print_usage() -- cgit v1.2.1