diff --git a/README.md b/README.md
index e7f27cd..bbd346d 100644
--- a/README.md
+++ b/README.md
@@ -67,8 +67,14 @@ Create a `notgitmodules.yaml` file in your project's root directory.
```yaml
# directory_name: url (ssh or https)
-# Example:
-file_reader: https://github.com/Free-Apps-for-All/file_manager_git_module
+# Example:
+utils:
+ file_manager: https://github.com/not-gitmodules/notgitmodules-file-manager-py
+ file_encryptor: https://github.com/not-gitmodules/notgitmodules-file-encryptor-py
+
+services:
+ forsaken_mail: https://github.com/malaohu/forsaken-mail
+ sim_mail: https://github.com/Webador/SlmMail
```
## 2. Usage Options
@@ -149,7 +155,7 @@ pip show not_gitmodules
- Example:
```text
- not_gitmodules~=0.2
+ not_gitmodules~=0.0
```
---
@@ -158,7 +164,6 @@ pip show not_gitmodules
| Flag (all of them are optional) | Description | Example |
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
-| `-d`, `--dir_name` | Specify the directory name where the modules will be saved.
By default, the modules will be saved in a directory named `my_gitmodules`. | • `not_gitmodules -d custom_folder`: Saves the repositories in `custom_folder` folder |
| `-y`, `--yaml-path` | Specify a custom path for the `notgitmodules.yaml` configuration file.
By default, it looks for `notgitmodules.yaml` in the current working directory. Naming it `notgitmodules` is a matter of best practices; you can name it as you want. | • `not_gitmodules -y /path/to/custom_notgitmodules.yaml`: Uses a custom YAML file located at `/path/to/custom_notgitmodules.yaml` |
| `-t`, `--threaded` | Enable threaded execution, where repositories are cloned in parallel (using threads). This flag is mutually exclusive with `-s`.
This is the default behavior if neither `-t` nor `-s` is specified. | • `not_gitmodules -t`: Clones repositories in parallel using threads
• `not_gitmodules --threaded`: Same as `-t`, using long form |
| `-s`, `--sequential` | Enable sequential execution, where repositories are cloned one by one in the order they appear in the YAML file. This flag is mutually exclusive with `-t`. | • `not_gitmodules -s`: Clones repositories one by one in order
• `not_gitmodules --sequential`: Same as `-s`, using long form |
@@ -177,13 +182,13 @@ not_gitmodules install
- ### Command pattern:
```bash
-not_gitmodules install --yaml-path --dir_name --threaded
+not_gitmodules install --yaml-path --threaded
```
or
```bash
-not_gitmodules install -y -d -t
+not_gitmodules install -y -t
```
---
@@ -223,7 +228,7 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY notgitmodules.yaml .
# install modules using not_gitmodules
-RUN not_gitmodules install -y notgitmodules.yaml -d my_directory -t
+RUN not_gitmodules install -y notgitmodules.yaml -t
CMD ["python", "main.py"]
```
diff --git a/not_gitmodules/cli.py b/not_gitmodules/cli.py
index 59dfe89..289e4eb 100644
--- a/not_gitmodules/cli.py
+++ b/not_gitmodules/cli.py
@@ -13,12 +13,12 @@ def cli():
help="Path to the custom YAML configuration file. By default it's notgitmodules.yaml."
)
- arg_parser.add_argument(
- "-d", "--dir_name",
- nargs="?", # optional
- default="my_gitmodules",
- help="The name of the directory the modules will be saved in. By default it's my_gitmodules."
- )
+ # arg_parser.add_argument(
+ # "-d", "--dir_name",
+ # nargs="?", # optional
+ # default="my_gitmodules",
+ # help="The name of the directory the modules will be saved in. By default it's my_gitmodules."
+ # )
# modes
mode_group = arg_parser.add_mutually_exclusive_group()
@@ -40,6 +40,6 @@ def cli():
initializer(
yaml_config_path=args.yaml_path,
- root_dir_name=args.dir_name,
+ # root_dir_name=args.dir_name,
download_in_threads=download_in_threads
)
diff --git a/not_gitmodules/core.py b/not_gitmodules/core.py
index 41b6fff..167b811 100644
--- a/not_gitmodules/core.py
+++ b/not_gitmodules/core.py
@@ -3,28 +3,27 @@
from concurrent.futures import ThreadPoolExecutor
-def execute_sequentially(root_dir_name: str, yaml_content: dict):
- for directory, repo_url in yaml_content.items():
- clone_repo(root_dir_name=root_dir_name, directory_name=directory, url=repo_url)
+def proceed_task(root_dir_name, directory_name, repo_url):
+ """Packed-up collection of actions, to run in a separate thread."""
+ ensure_dir_exists(root_dir_name)
- module_path = os.path.join(root_dir_name, directory)
+ if clone_repo(root_dir_name=root_dir_name, directory_name=directory_name, url=repo_url):
+ module_path = os.path.join(root_dir_name, directory_name)
delete_git_folder(module_path)
clean_github_leftovers(module_path)
+ # skipping else to not perform clean-up on skipped directories
-def execute_in_threads(root_dir_name: str, yaml_content: dict):
- def proceed_task(root_dir_name, directory, repo_url):
- """Packed-up collection of actions, to run in a separate thread."""
- clone_repo(root_dir_name=root_dir_name, directory_name=directory, url=repo_url)
+def execute_sequentially(root_dir_name: str, repo_dict: dict):
+ for directory_name, repo_url in repo_dict.items():
+ proceed_task(root_dir_name, directory_name, repo_url)
- module_path = os.path.join(root_dir_name, directory)
- delete_git_folder(module_path)
- clean_github_leftovers(module_path)
+def execute_in_threads(root_dir_name: str, repo_dict: dict):
with ThreadPoolExecutor() as executor:
futures = [
- executor.submit(proceed_task, root_dir_name, directory, repo_url)
- for directory, repo_url in yaml_content.items()
+ executor.submit(proceed_task, root_dir_name, directory_name, repo_url)
+ for directory_name, repo_url in repo_dict.items()
]
for future in futures:
@@ -33,25 +32,20 @@ def proceed_task(root_dir_name, directory, repo_url):
def initializer(
yaml_config_path: str = 'notgitmodules.yaml',
- root_dir_name="my_gitmodules",
download_in_threads: bool = True,
):
- # Read yaml
- # Ensure root_dir exists
- # Clone the repo to root dir
- # Clean-up
-
"""
+ Initializes the download and clean-up process.
+
:param yaml_config_path: The path to notgitmodules.yaml file
- :param root_dir_name: The name of directory where modules will be downloaded to.
:param download_in_threads: If you want to clone repos simultaneously or one at a time
- # :param max_threads: Maximum amount of allowed threads
- :return:
"""
yaml_content = read_yaml(yaml_config_path)
- ensure_dir_exists(root_dir_name)
- if download_in_threads:
- execute_in_threads(root_dir_name, yaml_content)
- else:
- execute_sequentially(root_dir_name, yaml_content)
+ for root_dir_name, repo_dict in yaml_content.items():
+ ensure_dir_exists(root_dir_name)
+
+ if download_in_threads:
+ execute_in_threads(root_dir_name, repo_dict)
+ else:
+ execute_sequentially(root_dir_name, repo_dict)
diff --git a/not_gitmodules/parts/clone_repo.py b/not_gitmodules/parts/clone_repo.py
index fec4177..0bbc197 100644
--- a/not_gitmodules/parts/clone_repo.py
+++ b/not_gitmodules/parts/clone_repo.py
@@ -2,7 +2,7 @@
import subprocess
-def clone_repo(root_dir_name, directory_name, url):
+def clone_repo(root_dir_name, directory_name, url) -> bool | None:
"""Clone the repository into the specified directory."""
target_path = os.path.join(root_dir_name, directory_name)
@@ -27,3 +27,5 @@ def clone_repo(root_dir_name, directory_name, url):
print(f"Failed to clone {url}: {e.stderr}")
except FileExistsError:
print(f"Target path {target_path} already exists.")
+ else:
+ return True
diff --git a/setup.py b/setup.py
index 5ccb12c..062869a 100644
--- a/setup.py
+++ b/setup.py
@@ -1,10 +1,10 @@
from setuptools import setup, find_packages
-__version__ = "0.4.3"
+__version__ = "0.4.4"
setup(
name='not_gitmodules',
- version='0.4.3',
+ version='0.4.4',
packages=find_packages(),
license='Custom License',
entry_points={
diff --git a/speed_comparison.py b/speed_comparison.py
index a949000..26a28b1 100644
--- a/speed_comparison.py
+++ b/speed_comparison.py
@@ -27,7 +27,6 @@ def test_sequentially(root_dir_name):
initializer(
yaml_config_path='dev/config.yaml',
download_in_threads=False,
- root_dir_name=root_dir_name
)
@@ -36,7 +35,6 @@ def test_parallely(root_dir_name):
initializer(
yaml_config_path='dev/config.yaml',
download_in_threads=True,
- root_dir_name=root_dir_name
)