Skip to content

Commit 7d8b595

Browse files
[skip-ci] new version (#15)
1 parent dc35739 commit 7d8b595

File tree

6 files changed

+45
-46
lines changed

6 files changed

+45
-46
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ Create a `notgitmodules.yaml` file in your project's root directory.
6767
```yaml
6868
# directory_name: url (ssh or https)
6969

70-
# Example:
71-
file_reader: https://github.com/Free-Apps-for-All/file_manager_git_module
70+
# Example:
71+
utils:
72+
file_manager: https://github.com/not-gitmodules/notgitmodules-file-manager-py
73+
file_encryptor: https://github.com/not-gitmodules/notgitmodules-file-encryptor-py
74+
75+
services:
76+
forsaken_mail: https://github.com/malaohu/forsaken-mail
77+
sim_mail: https://github.com/Webador/SlmMail
7278
```
7379
7480
## 2. Usage Options
@@ -149,7 +155,7 @@ pip show not_gitmodules
149155

150156
- Example:
151157
```text
152-
not_gitmodules~=0.2
158+
not_gitmodules~=0.0
153159
```
154160
155161
---
@@ -158,7 +164,6 @@ pip show not_gitmodules
158164
159165
| Flag (all of them are optional) | Description | Example |
160166
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
161-
| `-d`, `--dir_name` | Specify the directory name where the modules will be saved. <br>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 |
162167
| `-y`, `--yaml-path` | Specify a custom path for the `notgitmodules.yaml` configuration file. <br>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` |
163168
| `-t`, `--threaded` | Enable threaded execution, where repositories are cloned in parallel (using threads). This flag is mutually exclusive with `-s`. <br> This is the default behavior if neither `-t` nor `-s` is specified. | • `not_gitmodules -t`: Clones repositories in parallel using threads <br> • `not_gitmodules --threaded`: Same as `-t`, using long form |
164169
| `-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 <br> • `not_gitmodules --sequential`: Same as `-s`, using long form |
@@ -177,13 +182,13 @@ not_gitmodules install
177182
- ### Command pattern:
178183

179184
```bash
180-
not_gitmodules install --yaml-path </path/to/notgitmodules.yaml> --dir_name <directory_name> --threaded
185+
not_gitmodules install --yaml-path </path/to/notgitmodules.yaml> --threaded
181186
```
182187

183188
or
184189

185190
```bash
186-
not_gitmodules install -y </path/to/notgitmodules.yaml> -d <directory_name> -t
191+
not_gitmodules install -y </path/to/notgitmodules.yaml> -t
187192
```
188193

189194
---
@@ -223,7 +228,7 @@ RUN pip install --no-cache-dir -r requirements.txt
223228
COPY notgitmodules.yaml .
224229

225230
# install modules using not_gitmodules
226-
RUN not_gitmodules install -y notgitmodules.yaml -d my_directory -t
231+
RUN not_gitmodules install -y notgitmodules.yaml -t
227232

228233
CMD ["python", "main.py"]
229234
```

not_gitmodules/cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def cli():
1313
help="Path to the custom YAML configuration file. By default it's notgitmodules.yaml."
1414
)
1515

16-
arg_parser.add_argument(
17-
"-d", "--dir_name",
18-
nargs="?", # optional
19-
default="my_gitmodules",
20-
help="The name of the directory the modules will be saved in. By default it's my_gitmodules."
21-
)
16+
# arg_parser.add_argument(
17+
# "-d", "--dir_name",
18+
# nargs="?", # optional
19+
# default="my_gitmodules",
20+
# help="The name of the directory the modules will be saved in. By default it's my_gitmodules."
21+
# )
2222

2323
# modes
2424
mode_group = arg_parser.add_mutually_exclusive_group()
@@ -40,6 +40,6 @@ def cli():
4040

4141
initializer(
4242
yaml_config_path=args.yaml_path,
43-
root_dir_name=args.dir_name,
43+
# root_dir_name=args.dir_name,
4444
download_in_threads=download_in_threads
4545
)

not_gitmodules/core.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
from concurrent.futures import ThreadPoolExecutor
44

55

6-
def execute_sequentially(root_dir_name: str, yaml_content: dict):
7-
for directory, repo_url in yaml_content.items():
8-
clone_repo(root_dir_name=root_dir_name, directory_name=directory, url=repo_url)
6+
def proceed_task(root_dir_name, directory_name, repo_url):
7+
"""Packed-up collection of actions, to run in a separate thread."""
8+
ensure_dir_exists(root_dir_name)
99

10-
module_path = os.path.join(root_dir_name, directory)
10+
if clone_repo(root_dir_name=root_dir_name, directory_name=directory_name, url=repo_url):
11+
module_path = os.path.join(root_dir_name, directory_name)
1112
delete_git_folder(module_path)
1213
clean_github_leftovers(module_path)
14+
# skipping else to not perform clean-up on skipped directories
1315

1416

15-
def execute_in_threads(root_dir_name: str, yaml_content: dict):
16-
def proceed_task(root_dir_name, directory, repo_url):
17-
"""Packed-up collection of actions, to run in a separate thread."""
18-
clone_repo(root_dir_name=root_dir_name, directory_name=directory, url=repo_url)
17+
def execute_sequentially(root_dir_name: str, repo_dict: dict):
18+
for directory_name, repo_url in repo_dict.items():
19+
proceed_task(root_dir_name, directory_name, repo_url)
1920

20-
module_path = os.path.join(root_dir_name, directory)
21-
delete_git_folder(module_path)
22-
clean_github_leftovers(module_path)
2321

22+
def execute_in_threads(root_dir_name: str, repo_dict: dict):
2423
with ThreadPoolExecutor() as executor:
2524
futures = [
26-
executor.submit(proceed_task, root_dir_name, directory, repo_url)
27-
for directory, repo_url in yaml_content.items()
25+
executor.submit(proceed_task, root_dir_name, directory_name, repo_url)
26+
for directory_name, repo_url in repo_dict.items()
2827
]
2928

3029
for future in futures:
@@ -33,25 +32,20 @@ def proceed_task(root_dir_name, directory, repo_url):
3332

3433
def initializer(
3534
yaml_config_path: str = 'notgitmodules.yaml',
36-
root_dir_name="my_gitmodules",
3735
download_in_threads: bool = True,
3836
):
39-
# Read yaml
40-
# Ensure root_dir exists
41-
# Clone the repo to root dir
42-
# Clean-up
43-
4437
"""
38+
Initializes the download and clean-up process.
39+
4540
:param yaml_config_path: The path to notgitmodules.yaml file
46-
:param root_dir_name: The name of directory where modules will be downloaded to.
4741
:param download_in_threads: If you want to clone repos simultaneously or one at a time
48-
# :param max_threads: Maximum amount of allowed threads
49-
:return:
5042
"""
5143
yaml_content = read_yaml(yaml_config_path)
52-
ensure_dir_exists(root_dir_name)
5344

54-
if download_in_threads:
55-
execute_in_threads(root_dir_name, yaml_content)
56-
else:
57-
execute_sequentially(root_dir_name, yaml_content)
45+
for root_dir_name, repo_dict in yaml_content.items():
46+
ensure_dir_exists(root_dir_name)
47+
48+
if download_in_threads:
49+
execute_in_threads(root_dir_name, repo_dict)
50+
else:
51+
execute_sequentially(root_dir_name, repo_dict)

not_gitmodules/parts/clone_repo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import subprocess
33

44

5-
def clone_repo(root_dir_name, directory_name, url):
5+
def clone_repo(root_dir_name, directory_name, url) -> bool | None:
66
"""Clone the repository into the specified directory."""
77
target_path = os.path.join(root_dir_name, directory_name)
88

@@ -27,3 +27,5 @@ def clone_repo(root_dir_name, directory_name, url):
2727
print(f"Failed to clone {url}: {e.stderr}")
2828
except FileExistsError:
2929
print(f"Target path {target_path} already exists.")
30+
else:
31+
return True

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from setuptools import setup, find_packages
22

3-
__version__ = "0.4.3"
3+
__version__ = "0.4.4"
44

55
setup(
66
name='not_gitmodules',
7-
version='0.4.3',
7+
version='0.4.4',
88
packages=find_packages(),
99
license='Custom License',
1010
entry_points={

speed_comparison.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def test_sequentially(root_dir_name):
2727
initializer(
2828
yaml_config_path='dev/config.yaml',
2929
download_in_threads=False,
30-
root_dir_name=root_dir_name
3130
)
3231

3332

@@ -36,7 +35,6 @@ def test_parallely(root_dir_name):
3635
initializer(
3736
yaml_config_path='dev/config.yaml',
3837
download_in_threads=True,
39-
root_dir_name=root_dir_name
4038
)
4139

4240

0 commit comments

Comments
 (0)