skilleter-thingy 0.3.14__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.
- skilleter_thingy/__init__.py +0 -0
- skilleter_thingy/addpath.py +107 -0
- skilleter_thingy/console_colours.py +63 -0
- skilleter_thingy/ffind.py +535 -0
- skilleter_thingy/ggit.py +88 -0
- skilleter_thingy/ggrep.py +155 -0
- skilleter_thingy/git_br.py +186 -0
- skilleter_thingy/git_ca.py +147 -0
- skilleter_thingy/git_cleanup.py +297 -0
- skilleter_thingy/git_co.py +227 -0
- skilleter_thingy/git_common.py +68 -0
- skilleter_thingy/git_hold.py +162 -0
- skilleter_thingy/git_parent.py +84 -0
- skilleter_thingy/git_retag.py +67 -0
- skilleter_thingy/git_review.py +1450 -0
- skilleter_thingy/git_update.py +398 -0
- skilleter_thingy/git_wt.py +72 -0
- skilleter_thingy/gitcmp_helper.py +328 -0
- skilleter_thingy/gitprompt.py +293 -0
- skilleter_thingy/linecount.py +154 -0
- skilleter_thingy/multigit.py +915 -0
- skilleter_thingy/py_audit.py +133 -0
- skilleter_thingy/remdir.py +127 -0
- skilleter_thingy/rpylint.py +98 -0
- skilleter_thingy/strreplace.py +82 -0
- skilleter_thingy/test.py +34 -0
- skilleter_thingy/tfm.py +948 -0
- skilleter_thingy/tfparse.py +101 -0
- skilleter_thingy/trimpath.py +82 -0
- skilleter_thingy/venv_create.py +47 -0
- skilleter_thingy/venv_template.py +47 -0
- skilleter_thingy/xchmod.py +124 -0
- skilleter_thingy/yamlcheck.py +89 -0
- skilleter_thingy-0.3.14.dist-info/METADATA +606 -0
- skilleter_thingy-0.3.14.dist-info/RECORD +39 -0
- skilleter_thingy-0.3.14.dist-info/WHEEL +5 -0
- skilleter_thingy-0.3.14.dist-info/entry_points.txt +31 -0
- skilleter_thingy-0.3.14.dist-info/licenses/LICENSE +619 -0
- skilleter_thingy-0.3.14.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
################################################################################
|
|
4
|
+
""" Thingy addpath command
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2018 John Skilleter
|
|
7
|
+
|
|
8
|
+
Update a $PATH-type variable by adding or removing entries.
|
|
9
|
+
|
|
10
|
+
Intended to be used as in:
|
|
11
|
+
|
|
12
|
+
export PATH=$(addpath $PATH --add /opt/bin)
|
|
13
|
+
"""
|
|
14
|
+
################################################################################
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import os
|
|
18
|
+
import argparse
|
|
19
|
+
|
|
20
|
+
################################################################################
|
|
21
|
+
|
|
22
|
+
def pathmod(pathentries, separator, pathlist, prefix=False, suffix=False, delete=False, force=False):
|
|
23
|
+
""" Modify a path.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
# Only do something if the list of paths to add exists
|
|
27
|
+
|
|
28
|
+
if pathlist:
|
|
29
|
+
# Join the list path entries together then split them into individual entries
|
|
30
|
+
# Allows for a list of entries in the form ['a:b:c', 'd', 'e']
|
|
31
|
+
|
|
32
|
+
paths = separator.join(pathlist).split(separator)
|
|
33
|
+
|
|
34
|
+
# Process each entry
|
|
35
|
+
|
|
36
|
+
for entry in paths:
|
|
37
|
+
# Do nothing (except delete) if the path does not exist and we aren't forcing
|
|
38
|
+
|
|
39
|
+
if not entry or (not os.path.isdir(entry) and not (force or delete)):
|
|
40
|
+
continue
|
|
41
|
+
|
|
42
|
+
# If we are removing or adding/moving an entry remove any existing entry
|
|
43
|
+
|
|
44
|
+
if (delete or prefix or suffix) and entry in pathentries:
|
|
45
|
+
pathentries.remove(entry)
|
|
46
|
+
|
|
47
|
+
# Prefix or suffix the entry
|
|
48
|
+
|
|
49
|
+
if not delete and entry not in pathentries:
|
|
50
|
+
if suffix:
|
|
51
|
+
pathentries.append(entry)
|
|
52
|
+
else:
|
|
53
|
+
pathentries.insert(0, entry)
|
|
54
|
+
|
|
55
|
+
return pathentries
|
|
56
|
+
|
|
57
|
+
################################################################################
|
|
58
|
+
|
|
59
|
+
def main():
|
|
60
|
+
""" Main function - handles command line, outputs result to stdout """
|
|
61
|
+
|
|
62
|
+
parser = argparse.ArgumentParser(description='Add or remove entries from a path list (e.g. as used by the PATH environment variable)')
|
|
63
|
+
parser.add_argument('--add', action='append', help='Add an entry to the front of the path (do nothing if it is already present in the path)')
|
|
64
|
+
parser.add_argument('--prefix', action='append', help='Add an entry to the front of the path (or move it there if it is already present)')
|
|
65
|
+
parser.add_argument('--suffix', action='append', help='Add an entry to the end of the path (or move it there if it is already present)')
|
|
66
|
+
parser.add_argument('--remove', action='append', help='Remove an entry from the path (do nothing if it is not present')
|
|
67
|
+
parser.add_argument('--force', default=False, help='Add entries even if a corresponding directory does not exist')
|
|
68
|
+
parser.add_argument('--separator', action='store', default=':', help='Override the default path separator')
|
|
69
|
+
parser.add_argument('path', nargs=1, help='The path to modify')
|
|
70
|
+
|
|
71
|
+
args = parser.parse_args()
|
|
72
|
+
|
|
73
|
+
# Split the given path into component parts
|
|
74
|
+
|
|
75
|
+
pathsplit = [pathentry for pathentry in args.path[0].split(args.separator) if pathentry]
|
|
76
|
+
|
|
77
|
+
# Process the additions, suffixations, prefixanisms and deletes.
|
|
78
|
+
|
|
79
|
+
pathmod(pathsplit, args.separator, args.add)
|
|
80
|
+
pathmod(pathsplit, args.separator, args.prefix, prefix=True)
|
|
81
|
+
pathmod(pathsplit, args.separator, args.suffix, suffix=True)
|
|
82
|
+
pathmod(pathsplit, args.separator, args.remove, delete=True)
|
|
83
|
+
|
|
84
|
+
# Glue the path back together
|
|
85
|
+
|
|
86
|
+
pathjoin = args.separator.join(pathsplit)
|
|
87
|
+
|
|
88
|
+
# Output the updated path to stdout
|
|
89
|
+
|
|
90
|
+
print(pathjoin)
|
|
91
|
+
|
|
92
|
+
################################################################################
|
|
93
|
+
|
|
94
|
+
def addpath():
|
|
95
|
+
"""Entry point"""
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
main()
|
|
99
|
+
except KeyboardInterrupt:
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
except BrokenPipeError:
|
|
102
|
+
sys.exit(2)
|
|
103
|
+
|
|
104
|
+
################################################################################
|
|
105
|
+
|
|
106
|
+
if __name__ == '__main__':
|
|
107
|
+
addpath()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
################################################################################
|
|
4
|
+
""" Output all console colours
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2017-18 John Skilleter
|
|
7
|
+
|
|
8
|
+
Licence: GPL v3 or later
|
|
9
|
+
"""
|
|
10
|
+
################################################################################
|
|
11
|
+
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from skilleter_modules import colour
|
|
15
|
+
|
|
16
|
+
################################################################################
|
|
17
|
+
|
|
18
|
+
def main():
|
|
19
|
+
""" Main function - draw the colour grid """
|
|
20
|
+
|
|
21
|
+
# Extended ANSI colour are slightly weird.
|
|
22
|
+
# Colours 0-15 are the standard basic colours
|
|
23
|
+
# Colours 16-231 form a 6x6x6 colour cube
|
|
24
|
+
# Colours 232-255 are greyscale range with colours 0 and 15 as black and white
|
|
25
|
+
|
|
26
|
+
for code in range(0, 256):
|
|
27
|
+
if code in (8, 16) or (code > 16 and (code - 16) % 6 == 0):
|
|
28
|
+
colour.write('')
|
|
29
|
+
|
|
30
|
+
if (code - 16) % 36 == 0:
|
|
31
|
+
colour.write('')
|
|
32
|
+
|
|
33
|
+
# Set the foreground code to be white for dark backgrounds
|
|
34
|
+
|
|
35
|
+
foreground = 15 if code in (0, 1, 4, 5, 8, 12) \
|
|
36
|
+
or (16 <= code <= 33) \
|
|
37
|
+
or (52 <= code <= 69) \
|
|
38
|
+
or (88 <= code <= 105) \
|
|
39
|
+
or (124 <= code <= 135) \
|
|
40
|
+
or (160 <= code <= 171) \
|
|
41
|
+
or (196 <= code <= 201) \
|
|
42
|
+
or (232 <= code <= 243) else 0
|
|
43
|
+
|
|
44
|
+
colour.write('[B%d][%d] %3d [NORMAL] ' % (code, foreground, code), newline=False)
|
|
45
|
+
|
|
46
|
+
print()
|
|
47
|
+
|
|
48
|
+
################################################################################
|
|
49
|
+
|
|
50
|
+
def console_colours():
|
|
51
|
+
"""Entry point"""
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
main()
|
|
55
|
+
except KeyboardInterrupt:
|
|
56
|
+
sys.exit(1)
|
|
57
|
+
except BrokenPipeError:
|
|
58
|
+
sys.exit(2)
|
|
59
|
+
|
|
60
|
+
################################################################################
|
|
61
|
+
|
|
62
|
+
if __name__ == '__main__':
|
|
63
|
+
console_colours()
|