skilleter-thingy 0.0.22__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.

Potentially problematic release.


This version of skilleter-thingy might be problematic. Click here for more details.

Files changed (67) hide show
  1. skilleter_thingy/__init__.py +0 -0
  2. skilleter_thingy/addpath.py +107 -0
  3. skilleter_thingy/aws.py +548 -0
  4. skilleter_thingy/borger.py +269 -0
  5. skilleter_thingy/colour.py +213 -0
  6. skilleter_thingy/console_colours.py +63 -0
  7. skilleter_thingy/dc_curses.py +278 -0
  8. skilleter_thingy/dc_defaults.py +221 -0
  9. skilleter_thingy/dc_util.py +50 -0
  10. skilleter_thingy/dircolors.py +308 -0
  11. skilleter_thingy/diskspacecheck.py +67 -0
  12. skilleter_thingy/docker.py +95 -0
  13. skilleter_thingy/docker_purge.py +113 -0
  14. skilleter_thingy/ffind.py +536 -0
  15. skilleter_thingy/files.py +142 -0
  16. skilleter_thingy/ggit.py +90 -0
  17. skilleter_thingy/ggrep.py +154 -0
  18. skilleter_thingy/git.py +1368 -0
  19. skilleter_thingy/git2.py +1307 -0
  20. skilleter_thingy/git_br.py +180 -0
  21. skilleter_thingy/git_ca.py +142 -0
  22. skilleter_thingy/git_cleanup.py +287 -0
  23. skilleter_thingy/git_co.py +220 -0
  24. skilleter_thingy/git_common.py +61 -0
  25. skilleter_thingy/git_hold.py +154 -0
  26. skilleter_thingy/git_mr.py +92 -0
  27. skilleter_thingy/git_parent.py +77 -0
  28. skilleter_thingy/git_review.py +1416 -0
  29. skilleter_thingy/git_update.py +385 -0
  30. skilleter_thingy/git_wt.py +96 -0
  31. skilleter_thingy/gitcmp_helper.py +322 -0
  32. skilleter_thingy/gitlab.py +193 -0
  33. skilleter_thingy/gitprompt.py +274 -0
  34. skilleter_thingy/gl.py +174 -0
  35. skilleter_thingy/gphotosync.py +610 -0
  36. skilleter_thingy/linecount.py +155 -0
  37. skilleter_thingy/logger.py +112 -0
  38. skilleter_thingy/moviemover.py +133 -0
  39. skilleter_thingy/path.py +156 -0
  40. skilleter_thingy/photodupe.py +110 -0
  41. skilleter_thingy/phototidier.py +248 -0
  42. skilleter_thingy/popup.py +87 -0
  43. skilleter_thingy/process.py +112 -0
  44. skilleter_thingy/py_audit.py +131 -0
  45. skilleter_thingy/readable.py +270 -0
  46. skilleter_thingy/remdir.py +126 -0
  47. skilleter_thingy/rmdupe.py +550 -0
  48. skilleter_thingy/rpylint.py +91 -0
  49. skilleter_thingy/run.py +334 -0
  50. skilleter_thingy/s3_sync.py +383 -0
  51. skilleter_thingy/splitpics.py +99 -0
  52. skilleter_thingy/strreplace.py +82 -0
  53. skilleter_thingy/sysmon.py +435 -0
  54. skilleter_thingy/tfm.py +920 -0
  55. skilleter_thingy/tfm_pane.py +595 -0
  56. skilleter_thingy/tfparse.py +101 -0
  57. skilleter_thingy/tidy.py +160 -0
  58. skilleter_thingy/trimpath.py +84 -0
  59. skilleter_thingy/window_rename.py +92 -0
  60. skilleter_thingy/xchmod.py +125 -0
  61. skilleter_thingy/yamlcheck.py +89 -0
  62. skilleter_thingy-0.0.22.dist-info/LICENSE +619 -0
  63. skilleter_thingy-0.0.22.dist-info/METADATA +22 -0
  64. skilleter_thingy-0.0.22.dist-info/RECORD +67 -0
  65. skilleter_thingy-0.0.22.dist-info/WHEEL +5 -0
  66. skilleter_thingy-0.0.22.dist-info/entry_points.txt +43 -0
  67. skilleter_thingy-0.0.22.dist-info/top_level.txt +1 -0
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """ Run a git command in all working trees in/under the specified subdirectory """
4
+
5
+ import sys
6
+ import os
7
+ import subprocess
8
+ import argparse
9
+
10
+ from skilleter_thingy import git
11
+ from skilleter_thingy import colour
12
+
13
+ ################################################################################
14
+
15
+ def run_git(args, directory, command):
16
+ """ Run a git command in the specified directory """
17
+
18
+ if not args.quiet:
19
+ print('-' * 80)
20
+ print('Running git %s in %s' % (' '.join(command), directory))
21
+ print('-' * 80)
22
+
23
+ sys.stdout.flush()
24
+
25
+ subprocess.run(['git', '-C', directory] + command)
26
+
27
+ ################################################################################
28
+
29
+ def parse_command_line():
30
+ """ Parse the command line options """
31
+
32
+ try:
33
+ argpos = sys.argv.index('--')
34
+
35
+ cmd = sys.argv[argpos + 1:]
36
+ sys.argv = sys.argv[:argpos]
37
+ except ValueError:
38
+ cmd = sys.argv[1:]
39
+ sys.argv = sys.argv[:1]
40
+
41
+ parser = argparse.ArgumentParser(description='Run a git command recursively in subdirectories')
42
+
43
+ parser.add_argument('-q', '--quiet', action='store_true', help='Run quietly - only output errors or output from git')
44
+ parser.add_argument('path', nargs='?', action='store', default='.', help='Specify the path to run in')
45
+
46
+ args = parser.parse_args()
47
+
48
+ return args, cmd
49
+
50
+ ################################################################################
51
+
52
+ def main():
53
+ """ Main function """
54
+
55
+ args, cmdline = parse_command_line()
56
+
57
+ try:
58
+ os.chdir(args.path)
59
+ except FileNotFoundError:
60
+ colour.error(f'[RED:ERROR]: Invalid path [BLUE:{args.path}]')
61
+
62
+ # If the current directory is in a working tree and below the top-level
63
+ # directory then we run the git command here as well as in subdirectories
64
+ # that are working trees.
65
+
66
+ if git.working_tree() and not os.path.isdir('.git'):
67
+ run_git(args, os.getcwd(), cmdline)
68
+
69
+ # Find working trees and run the command in them
70
+
71
+ for root, dirs, _ in os.walk(args.path):
72
+ if '.git' in dirs:
73
+ run_git(args, root, cmdline)
74
+
75
+ ################################################################################
76
+
77
+ def ggit():
78
+ """Entry point"""
79
+
80
+ try:
81
+ main()
82
+ except KeyboardInterrupt:
83
+ sys.exit(1)
84
+ except BrokenPipeError:
85
+ sys.exit(2)
86
+
87
+ ################################################################################
88
+
89
+ if __name__ == '__main__':
90
+ ggit()
@@ -0,0 +1,154 @@
1
+ #! /usr/bin/env python3
2
+
3
+ """ Run 'git grep' in all Git working trees under the current directory or just
4
+ in the current directory if the current director is in a working tree.
5
+
6
+ Copyright (C) 2019-21 John Skilleter
7
+ """
8
+
9
+ ################################################################################
10
+
11
+ import os
12
+ import re
13
+ import sys
14
+ import argparse
15
+
16
+ from skilleter_thingy import colour
17
+ from skilleter_thingy import git
18
+
19
+ ################################################################################
20
+
21
+ BINARY_RE = re.compile(r'(Binary file )(.*)( matches)')
22
+
23
+ ################################################################################
24
+
25
+ def parse_command_line():
26
+ """ Validate the command line, return the arguments """
27
+
28
+ parser = argparse.ArgumentParser(
29
+ description='Run a git grep in either the current working tree or all working git working trees under the current directory')
30
+
31
+ parser.add_argument('-f', '--follow', action='store_true', help='Follow symlinks')
32
+ parser.add_argument('-a', '--text', action='store_true', help='Process binary files as if they were text.')
33
+ parser.add_argument('-i', '--ignore-case', action='store_true', help='Ignore case differences between the patterns and the files.')
34
+ parser.add_argument('-w', '--word-regexp', action='store_true',
35
+ help='Match the pattern only at word boundary (either begin at the beginning of a line, or preceded by a non-word character; end at the end of a line or followed by a non-word character).')
36
+ parser.add_argument('-v', '--invert-match', action='store_true', help='Select non-matching lines.')
37
+ parser.add_argument('-F', '--fixed-strings', action='store_true', help='Use fixed strings for patterns (don’t interpret pattern as a regex).')
38
+ parser.add_argument('-n', '--line-number', action='store_true', help='Prefix the line number to matching lines.')
39
+ parser.add_argument('-l', '--files-with-matches', action='store_true', help='Show only the names of files that contain matches')
40
+ parser.add_argument('-L', '--files-without-matches', action='store_true', help='Show only the names of files that do NOT contain matches')
41
+ parser.add_argument('-W', '--wildcard', action='append', help='Only search files matching the wildcard(s)')
42
+ parser.add_argument('-o', '--only-matching', action='store_true', help='Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.')
43
+ parser.add_argument('--no-color', action='store_true', help='Turn off match highlighting')
44
+ parser.add_argument('pattern', action='store', help='Regular expression to search for')
45
+ parser.add_argument('paths', nargs='*', help='Optional list of one or more paths to search')
46
+
47
+ return parser.parse_args()
48
+
49
+ ################################################################################
50
+
51
+ def git_grep(args, path, pattern):
52
+ """ Grep a git """
53
+
54
+ if path == '.':
55
+ path = ''
56
+ elif path[0:2] == './':
57
+ path = path[2:]
58
+
59
+ grep_options = {'color': True, 'extended_regexp': True}
60
+
61
+ if args.text:
62
+ grep_options['text'] = True
63
+
64
+ if args.ignore_case:
65
+ grep_options['ignore_case'] = True
66
+
67
+ if args.word_regexp:
68
+ grep_options['word_regexp'] = True
69
+
70
+ if args.invert_match:
71
+ grep_options['invert_match'] = True
72
+
73
+ if args.fixed_strings:
74
+ grep_options['fixed_strings'] = True
75
+
76
+ if args.line_number:
77
+ grep_options['line_number'] = True
78
+
79
+ if args.files_without_matches:
80
+ grep_options['files_without_matches'] = True
81
+
82
+ if args.files_with_matches:
83
+ grep_options['files_with_matches'] = True
84
+
85
+ if args.only_matching:
86
+ grep_options['only_matching'] = True
87
+
88
+ if path:
89
+ output, status = git.grep(pattern, git_dir=os.path.join(path, '.git'), work_tree=path, options=grep_options, wildcards=args.wildcard)
90
+ else:
91
+ output, status = git.grep(pattern, options=grep_options, wildcards=args.wildcard)
92
+
93
+ if status > 1:
94
+ colour.error(output)
95
+ elif status == 0:
96
+ for out in output.split('\n'):
97
+ if out:
98
+ bin_match = BINARY_RE.match(out)
99
+ if bin_match:
100
+ match_path = os.path.join(path, bin_match.group(2))
101
+ colour.write(f'[BOLD:{match_path}]: Binary file match')
102
+ else:
103
+ subdir = os.path.join(path, out.split(':', 1)[0])
104
+ data = out.split(':', 1)[1]
105
+
106
+ colour.write(f'[BLUE:{subdir}]: {data.strip()}')
107
+
108
+ ################################################################################
109
+
110
+ def git_grep_path(args, path):
111
+ """ Look for git working trees under the specified path and grep them """
112
+
113
+ for root, dirs, _ in os.walk(path, followlinks=args.follow):
114
+ if '.git' in dirs:
115
+ git_grep(args, root, args.pattern)
116
+
117
+ ################################################################################
118
+
119
+ def main():
120
+ """ If we are in a repo, just run git grep, otherwise, hunt for
121
+ repos and git grep them. """
122
+
123
+ args = parse_command_line()
124
+
125
+ if not args.paths:
126
+ # No paths specified so if the current directory is in a working tree
127
+ # just run git grep, otherwise, look for working trees in subdirectories
128
+
129
+ if git.working_tree():
130
+ git_grep(args, '.', args.pattern)
131
+ else:
132
+ args.paths = ['.']
133
+
134
+ if args.paths:
135
+ for path in args.paths:
136
+ git_grep_path(args, path)
137
+
138
+ ################################################################################
139
+
140
+ def ggrep():
141
+ """Entry point"""
142
+
143
+ try:
144
+ main()
145
+
146
+ except KeyboardInterrupt:
147
+ sys.exit(1)
148
+ except BrokenPipeError:
149
+ sys.exit(2)
150
+
151
+ ################################################################################
152
+
153
+ if __name__ == '__main__':
154
+ ggrep()