git-editlog 1.0.1__py3-none-any.whl

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.
@@ -0,0 +1,8 @@
1
+ VERSION = "1.0.1"
2
+
3
+ import sys
4
+
5
+ if sys.platform == 'linux':
6
+ from .pyinotify_watcher import RepoWatcher
7
+ else:
8
+ from .watchdog_watcher import RepoWatcher
@@ -0,0 +1,66 @@
1
+ import sys
2
+ import re
3
+ import time
4
+ import os
5
+ import argparse
6
+ import subprocess
7
+ import traceback
8
+ import copy
9
+ import logging
10
+ from pathlib import Path
11
+
12
+ from ktpanda import git_helper
13
+
14
+ from . import RepoWatcher
15
+
16
+ def setup_python_logging(verbose=False):
17
+ root = logging.getLogger()
18
+ root.setLevel(logging.DEBUG if verbose else logging.INFO)
19
+
20
+ log_formatter = logging.Formatter('%(asctime)s %(levelname)s: [%(name)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
21
+ console_handler = logging.StreamHandler(sys.stdout)
22
+ console_handler.setFormatter(log_formatter)
23
+ root.addHandler(console_handler)
24
+
25
+ def main():
26
+ p = argparse.ArgumentParser(description='')
27
+ p.add_argument('repos', type=Path, nargs='*')
28
+ p.add_argument('-l', '--repo-list', type=Path)
29
+ p.add_argument('-v', '--verbose', action='store_true', help='')
30
+ #p.add_argument(help='')
31
+ args = p.parse_args()
32
+
33
+ setup_python_logging(args.verbose)
34
+
35
+ repo_paths = []
36
+ repo_watchers = []
37
+ for path in args.repos:
38
+ repo_paths.append(path)
39
+
40
+ if args.repo_list:
41
+ base = args.repo_list.parent
42
+ with args.repo_list.open() as fp:
43
+ for line in fp:
44
+ line = line.strip()
45
+ if not line or line.startswith('#'):
46
+ continue
47
+
48
+ path = (base / line).absolute()
49
+ repo_paths.append(path)
50
+
51
+ for path in repo_paths:
52
+ try:
53
+ print(f'Initialzing watcher for {path} ...')
54
+ repo_watchers.append(RepoWatcher(path))
55
+ except Exception:
56
+ print(f'Error initializing watcher for {path}', file=sys.stderr)
57
+ traceback.print_exc()
58
+
59
+ if not repo_watchers:
60
+ print('No repositories defined', file=sys.stderr)
61
+ return
62
+
63
+ RepoWatcher.run(repo_watchers)
64
+
65
+ if __name__ == '__main__':
66
+ main()