batchfetch 1.0.5__tar.gz → 1.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {batchfetch-1.0.5 → batchfetch-1.0.7}/PKG-INFO +4 -3
- {batchfetch-1.0.5 → batchfetch-1.0.7}/README.md +3 -2
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch/batchfetch_base.py +10 -9
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch/batchfetch_cli.py +52 -38
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch/batchfetch_git.py +8 -6
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch/helpers.py +4 -2
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch.egg-info/PKG-INFO +4 -3
- {batchfetch-1.0.5 → batchfetch-1.0.7}/setup.py +1 -1
- {batchfetch-1.0.5 → batchfetch-1.0.7}/LICENSE +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch/__init__.py +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch.egg-info/SOURCES.txt +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch.egg-info/dependency_links.txt +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch.egg-info/entry_points.txt +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch.egg-info/requires.txt +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/batchfetch.egg-info/top_level.txt +0 -0
- {batchfetch-1.0.5 → batchfetch-1.0.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: batchfetch
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Efficiently clone and pull multiple Git repositories.
|
|
5
5
|
Home-page: https://github.com/jamescherti/batchfetch
|
|
6
6
|
Author: James Cherti
|
|
@@ -80,12 +80,13 @@ usage: batchfetch [--option] [args]
|
|
|
80
80
|
|
|
81
81
|
Command line interface.
|
|
82
82
|
|
|
83
|
+
positional arguments:
|
|
84
|
+
N Specify the batchfetch YAML file(s) (default: './batchfetch.yaml').
|
|
85
|
+
|
|
83
86
|
options:
|
|
84
87
|
-h, --help show this help message and exit
|
|
85
88
|
-j JOBS, --jobs JOBS Run up to N Number of parallel processes (Default: 5).
|
|
86
89
|
-v, --verbose Enable verbose mode.
|
|
87
|
-
-f BATCHFETCH_FILE, --batchfetch-file BATCHFETCH_FILE
|
|
88
|
-
Specify the batchfetch YAML file (default: './batchfetch.yaml').
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
## License
|
|
@@ -60,12 +60,13 @@ usage: batchfetch [--option] [args]
|
|
|
60
60
|
|
|
61
61
|
Command line interface.
|
|
62
62
|
|
|
63
|
+
positional arguments:
|
|
64
|
+
N Specify the batchfetch YAML file(s) (default: './batchfetch.yaml').
|
|
65
|
+
|
|
63
66
|
options:
|
|
64
67
|
-h, --help show this help message and exit
|
|
65
68
|
-j JOBS, --jobs JOBS Run up to N Number of parallel processes (Default: 5).
|
|
66
69
|
-v, --verbose Enable verbose mode.
|
|
67
|
-
-f BATCHFETCH_FILE, --batchfetch-file BATCHFETCH_FILE
|
|
68
|
-
Specify the batchfetch YAML file (default: './batchfetch.yaml').
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
## License
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
#
|
|
11
11
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
12
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
13
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14
|
+
# details.
|
|
14
15
|
#
|
|
15
16
|
# You should have received a copy of the GNU General Public License along with
|
|
16
17
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
|
@@ -40,21 +41,21 @@ class BatchFetchBase:
|
|
|
40
41
|
|
|
41
42
|
# Default
|
|
42
43
|
self.global_options_schema: Dict[Any, Any] = {
|
|
43
|
-
Optional("
|
|
44
|
-
Optional("
|
|
44
|
+
Optional("exec_before"): Or([str], str),
|
|
45
|
+
Optional("exec_after"): Or([str], str),
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
self.item_schema: Dict[Any, Any] = {
|
|
48
49
|
Optional("path"): str,
|
|
49
50
|
Optional("delete"): bool,
|
|
50
51
|
|
|
51
|
-
Optional("
|
|
52
|
-
Optional("
|
|
52
|
+
Optional("exec_before"): Or([str], str),
|
|
53
|
+
Optional("exec_after"): Or([str], str),
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
self.global_options_values: Dict[str, Any] = {
|
|
56
|
-
"
|
|
57
|
-
"
|
|
57
|
+
"exec_before": [],
|
|
58
|
+
"exec_after": [],
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
self.item_default_values: Dict[str, Any] = {
|
|
@@ -111,7 +112,7 @@ class BatchFetchBase:
|
|
|
111
112
|
|
|
112
113
|
def _run_pre_exec(self, cwd: os.PathLike = Path(".")):
|
|
113
114
|
self._initialize_data()
|
|
114
|
-
for pre_exec in self["
|
|
115
|
+
for pre_exec in self["exec_before"]:
|
|
115
116
|
if not pre_exec:
|
|
116
117
|
continue
|
|
117
118
|
|
|
@@ -123,7 +124,7 @@ class BatchFetchBase:
|
|
|
123
124
|
if self["delete"] or not self.is_changed():
|
|
124
125
|
return
|
|
125
126
|
|
|
126
|
-
for post_exec in self["
|
|
127
|
+
for post_exec in self["exec_after"]:
|
|
127
128
|
if not post_exec:
|
|
128
129
|
continue
|
|
129
130
|
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
#
|
|
11
11
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
12
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
13
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14
|
+
# details.
|
|
14
15
|
#
|
|
15
16
|
# You should have received a copy of the GNU General Public License along with
|
|
16
17
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
|
@@ -24,7 +25,7 @@ import subprocess
|
|
|
24
25
|
import sys
|
|
25
26
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
26
27
|
from pathlib import Path
|
|
27
|
-
from typing import Any, Dict, Set
|
|
28
|
+
from typing import Any, Dict, Set
|
|
28
29
|
|
|
29
30
|
import colorama
|
|
30
31
|
import yaml # type: ignore
|
|
@@ -48,8 +49,6 @@ class BatchFetchCli:
|
|
|
48
49
|
self._logger = logging.getLogger(self.__class__.__name__)
|
|
49
50
|
self.dirs_relative_to_batchfetch: Set[str] = set()
|
|
50
51
|
|
|
51
|
-
self.main_key = "git"
|
|
52
|
-
|
|
53
52
|
# Plugin
|
|
54
53
|
self.batchfetch_schemas: Dict[Any, Any] = {}
|
|
55
54
|
self.batchfetch_classes: Dict[str, BatchFetchBase] = {}
|
|
@@ -134,17 +133,16 @@ class BatchFetchCli:
|
|
|
134
133
|
print(f"Schema error: {err}.", file=sys.stderr)
|
|
135
134
|
sys.exit(1)
|
|
136
135
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
dest_path = Path(batchfetch_instance["path"]).resolve()
|
|
137
|
+
if str(dest_path) in dict_local_dir:
|
|
138
|
+
err_str = ("More than one task have the " +
|
|
139
|
+
f"destination path '{dest_path}' (" +
|
|
141
140
|
str(task[keyword]) + " and " +
|
|
142
|
-
str(dict_local_dir[
|
|
141
|
+
str(dict_local_dir[(str(dest_path))]) +
|
|
143
142
|
")")
|
|
144
143
|
raise BatchFetchError(err_str)
|
|
145
144
|
|
|
146
|
-
dict_local_dir[
|
|
147
|
-
batchfetch_instance[keyword]
|
|
145
|
+
dict_local_dir[str(dest_path)] = batchfetch_instance[keyword]
|
|
148
146
|
|
|
149
147
|
def run_tasks(self) -> bool:
|
|
150
148
|
failed = []
|
|
@@ -203,7 +201,7 @@ class BatchFetchCli:
|
|
|
203
201
|
return False
|
|
204
202
|
else:
|
|
205
203
|
if num_success == 0:
|
|
206
|
-
print("
|
|
204
|
+
print("Nothing to do.")
|
|
207
205
|
elif not self.verbose:
|
|
208
206
|
print("Success.")
|
|
209
207
|
|
|
@@ -216,6 +214,10 @@ def parse_args():
|
|
|
216
214
|
usage = "%(prog)s [--option] [args]"
|
|
217
215
|
parser = argparse.ArgumentParser(description=desc, usage=usage)
|
|
218
216
|
|
|
217
|
+
parser.add_argument("batchfetch_files", metavar="N", type=str, nargs="*",
|
|
218
|
+
help=("Specify the batchfetch YAML file(s) "
|
|
219
|
+
"(default: './batchfetch.yaml')."))
|
|
220
|
+
|
|
219
221
|
parser.add_argument(
|
|
220
222
|
"-j", "--jobs", default="5", required=False,
|
|
221
223
|
help="Run up to N Number of parallel processes (Default: 5).",
|
|
@@ -226,40 +228,25 @@ def parse_args():
|
|
|
226
228
|
help="Enable verbose mode.",
|
|
227
229
|
)
|
|
228
230
|
|
|
229
|
-
parser.add_argument(
|
|
230
|
-
"-f",
|
|
231
|
-
"--batchfetch-file",
|
|
232
|
-
default="./batchfetch.yaml",
|
|
233
|
-
required=False,
|
|
234
|
-
help="Specify the batchfetch YAML file (default: './batchfetch.yaml').",
|
|
235
|
-
)
|
|
236
|
-
|
|
237
231
|
args = parser.parse_args()
|
|
232
|
+
if not args.batchfetch_files:
|
|
233
|
+
args.batchfetch_files = ["./batchfetch.yaml"]
|
|
238
234
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
for batchfetch_file in args.batchfetch_files:
|
|
236
|
+
if not Path(batchfetch_file).is_file():
|
|
237
|
+
print(f"Error: File not found: {batchfetch_file}",
|
|
238
|
+
file=sys.stderr)
|
|
239
|
+
sys.exit(1)
|
|
243
240
|
|
|
244
241
|
return args
|
|
245
242
|
|
|
246
243
|
|
|
247
|
-
def
|
|
248
|
-
"""Command line interface."""
|
|
244
|
+
def run_batchfetch_procedure(batchfetch_file: Path, args) -> int:
|
|
249
245
|
errno = 0
|
|
250
|
-
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
|
|
251
|
-
format="%(asctime)s %(name)s: %(message)s")
|
|
252
|
-
|
|
253
|
-
colorama.init()
|
|
254
|
-
setproctitle(subprocess.list2cmdline([Path(sys.argv[0]).name] +
|
|
255
|
-
sys.argv[1:]))
|
|
256
|
-
|
|
257
|
-
args = parse_args()
|
|
258
246
|
batchfetch_cli = BatchFetchCli(verbose=args.verbose,
|
|
259
247
|
max_workers=int(args.jobs))
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
os.chdir(os.path.dirname(args.batchfetch_file))
|
|
248
|
+
batchfetch_cli.load(batchfetch_file)
|
|
249
|
+
os.chdir(batchfetch_file.parent)
|
|
263
250
|
|
|
264
251
|
try:
|
|
265
252
|
if not batchfetch_cli.run_tasks():
|
|
@@ -271,4 +258,31 @@ def command_line_interface():
|
|
|
271
258
|
print(f"Error: {err}.", file=sys.stderr)
|
|
272
259
|
errno = 1
|
|
273
260
|
|
|
274
|
-
|
|
261
|
+
return errno
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def command_line_interface():
|
|
265
|
+
"""Command line interface."""
|
|
266
|
+
try:
|
|
267
|
+
errno = 0
|
|
268
|
+
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
|
|
269
|
+
format="%(asctime)s %(name)s: %(message)s")
|
|
270
|
+
|
|
271
|
+
colorama.init()
|
|
272
|
+
setproctitle(subprocess.list2cmdline([Path(sys.argv[0]).name] +
|
|
273
|
+
sys.argv[1:]))
|
|
274
|
+
|
|
275
|
+
args = parse_args()
|
|
276
|
+
done = []
|
|
277
|
+
for batchfetch_file in args.batchfetch_files:
|
|
278
|
+
batchfetch_file = Path(batchfetch_file)
|
|
279
|
+
batchfetch_file_resolved = batchfetch_file.resolve()
|
|
280
|
+
if batchfetch_file_resolved in done:
|
|
281
|
+
continue
|
|
282
|
+
|
|
283
|
+
done.append(batchfetch_file_resolved)
|
|
284
|
+
errno |= run_batchfetch_procedure(batchfetch_file, args)
|
|
285
|
+
|
|
286
|
+
sys.exit(errno)
|
|
287
|
+
except BrokenPipeError:
|
|
288
|
+
pass
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
#
|
|
11
11
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
12
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
13
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14
|
+
# details.
|
|
14
15
|
#
|
|
15
16
|
# You should have received a copy of the GNU General Public License along with
|
|
16
17
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
|
@@ -158,7 +159,7 @@ class BatchFetchGit(BatchFetchBase):
|
|
|
158
159
|
textwrap.indent(err.stderr, " " * self.indent))
|
|
159
160
|
|
|
160
161
|
if not self.is_error() and not self.is_changed():
|
|
161
|
-
self.add_output(self.indent_spaces + "
|
|
162
|
+
self.add_output(self.indent_spaces + "[INFO] Nothing to do.\n")
|
|
162
163
|
|
|
163
164
|
return self.values
|
|
164
165
|
|
|
@@ -175,7 +176,7 @@ class BatchFetchGit(BatchFetchBase):
|
|
|
175
176
|
|
|
176
177
|
def _repo_delete(self):
|
|
177
178
|
if not self.git_local_dir.exists():
|
|
178
|
-
self.add_output(self.indent_spaces + "
|
|
179
|
+
self.add_output(self.indent_spaces + "[INFO] Already deleted\n")
|
|
179
180
|
elif not self.git_local_dir.joinpath(".git").is_dir():
|
|
180
181
|
self.add_output(
|
|
181
182
|
self.indent_spaces +
|
|
@@ -186,7 +187,7 @@ class BatchFetchGit(BatchFetchBase):
|
|
|
186
187
|
elif self.git_local_dir.is_dir():
|
|
187
188
|
shutil.rmtree(str(self.git_local_dir))
|
|
188
189
|
self.add_output(self.indent_spaces +
|
|
189
|
-
f"
|
|
190
|
+
f"[INFO] Deleted: '{self.git_local_dir}'")
|
|
190
191
|
self.set_changed(True)
|
|
191
192
|
|
|
192
193
|
def _repo_clone(self):
|
|
@@ -240,7 +241,7 @@ class BatchFetchGit(BatchFetchBase):
|
|
|
240
241
|
|
|
241
242
|
if ignore_git_pull:
|
|
242
243
|
self.add_output(self.indent_spaces +
|
|
243
|
-
"
|
|
244
|
+
"[INFO] git pull ignored\n")
|
|
244
245
|
else:
|
|
245
246
|
cmd = ["git", "fetch", "origin"]
|
|
246
247
|
self._run(cmd, cwd=str(self.git_local_dir), env=self.env)
|
|
@@ -317,7 +318,8 @@ class BatchFetchGit(BatchFetchBase):
|
|
|
317
318
|
# Update the branch
|
|
318
319
|
self._run(["git", "checkout"] + [self["reference"]],
|
|
319
320
|
cwd=str(self.git_local_dir), env=self.env)
|
|
320
|
-
self.add_output(self.indent_spaces +
|
|
321
|
+
self.add_output(self.indent_spaces +
|
|
322
|
+
"[INFO] Branch changed to " +
|
|
321
323
|
self["reference"] + "\n")
|
|
322
324
|
self.set_changed(True)
|
|
323
325
|
branch_changed = True
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
1
2
|
#
|
|
2
3
|
# Copyright (c) James Cherti
|
|
3
4
|
# URL: https://github.com/jamescherti/batchfetch
|
|
@@ -9,7 +10,8 @@
|
|
|
9
10
|
#
|
|
10
11
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
11
12
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
12
|
-
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
13
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14
|
+
# details.
|
|
13
15
|
#
|
|
14
16
|
# You should have received a copy of the GNU General Public License along with
|
|
15
17
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
|
@@ -28,7 +30,7 @@ def md5sum(filename: os.PathLike):
|
|
|
28
30
|
Calculate and return the MD5 checksum of a file.
|
|
29
31
|
|
|
30
32
|
Args:
|
|
31
|
-
filename:
|
|
33
|
+
filename: Path to the file for which the MD5 checksum is calculated.
|
|
32
34
|
|
|
33
35
|
Returns:
|
|
34
36
|
str: The MD5 checksum of the file.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: batchfetch
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Efficiently clone and pull multiple Git repositories.
|
|
5
5
|
Home-page: https://github.com/jamescherti/batchfetch
|
|
6
6
|
Author: James Cherti
|
|
@@ -80,12 +80,13 @@ usage: batchfetch [--option] [args]
|
|
|
80
80
|
|
|
81
81
|
Command line interface.
|
|
82
82
|
|
|
83
|
+
positional arguments:
|
|
84
|
+
N Specify the batchfetch YAML file(s) (default: './batchfetch.yaml').
|
|
85
|
+
|
|
83
86
|
options:
|
|
84
87
|
-h, --help show this help message and exit
|
|
85
88
|
-j JOBS, --jobs JOBS Run up to N Number of parallel processes (Default: 5).
|
|
86
89
|
-v, --verbose Enable verbose mode.
|
|
87
|
-
-f BATCHFETCH_FILE, --batchfetch-file BATCHFETCH_FILE
|
|
88
|
-
Specify the batchfetch YAML file (default: './batchfetch.yaml').
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
## License
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|