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.
- skilleter_thingy/__init__.py +0 -0
- skilleter_thingy/addpath.py +107 -0
- skilleter_thingy/aws.py +548 -0
- skilleter_thingy/borger.py +269 -0
- skilleter_thingy/colour.py +213 -0
- skilleter_thingy/console_colours.py +63 -0
- skilleter_thingy/dc_curses.py +278 -0
- skilleter_thingy/dc_defaults.py +221 -0
- skilleter_thingy/dc_util.py +50 -0
- skilleter_thingy/dircolors.py +308 -0
- skilleter_thingy/diskspacecheck.py +67 -0
- skilleter_thingy/docker.py +95 -0
- skilleter_thingy/docker_purge.py +113 -0
- skilleter_thingy/ffind.py +536 -0
- skilleter_thingy/files.py +142 -0
- skilleter_thingy/ggit.py +90 -0
- skilleter_thingy/ggrep.py +154 -0
- skilleter_thingy/git.py +1368 -0
- skilleter_thingy/git2.py +1307 -0
- skilleter_thingy/git_br.py +180 -0
- skilleter_thingy/git_ca.py +142 -0
- skilleter_thingy/git_cleanup.py +287 -0
- skilleter_thingy/git_co.py +220 -0
- skilleter_thingy/git_common.py +61 -0
- skilleter_thingy/git_hold.py +154 -0
- skilleter_thingy/git_mr.py +92 -0
- skilleter_thingy/git_parent.py +77 -0
- skilleter_thingy/git_review.py +1416 -0
- skilleter_thingy/git_update.py +385 -0
- skilleter_thingy/git_wt.py +96 -0
- skilleter_thingy/gitcmp_helper.py +322 -0
- skilleter_thingy/gitlab.py +193 -0
- skilleter_thingy/gitprompt.py +274 -0
- skilleter_thingy/gl.py +174 -0
- skilleter_thingy/gphotosync.py +610 -0
- skilleter_thingy/linecount.py +155 -0
- skilleter_thingy/logger.py +112 -0
- skilleter_thingy/moviemover.py +133 -0
- skilleter_thingy/path.py +156 -0
- skilleter_thingy/photodupe.py +110 -0
- skilleter_thingy/phototidier.py +248 -0
- skilleter_thingy/popup.py +87 -0
- skilleter_thingy/process.py +112 -0
- skilleter_thingy/py_audit.py +131 -0
- skilleter_thingy/readable.py +270 -0
- skilleter_thingy/remdir.py +126 -0
- skilleter_thingy/rmdupe.py +550 -0
- skilleter_thingy/rpylint.py +91 -0
- skilleter_thingy/run.py +334 -0
- skilleter_thingy/s3_sync.py +383 -0
- skilleter_thingy/splitpics.py +99 -0
- skilleter_thingy/strreplace.py +82 -0
- skilleter_thingy/sysmon.py +435 -0
- skilleter_thingy/tfm.py +920 -0
- skilleter_thingy/tfm_pane.py +595 -0
- skilleter_thingy/tfparse.py +101 -0
- skilleter_thingy/tidy.py +160 -0
- skilleter_thingy/trimpath.py +84 -0
- skilleter_thingy/window_rename.py +92 -0
- skilleter_thingy/xchmod.py +125 -0
- skilleter_thingy/yamlcheck.py +89 -0
- skilleter_thingy-0.0.22.dist-info/LICENSE +619 -0
- skilleter_thingy-0.0.22.dist-info/METADATA +22 -0
- skilleter_thingy-0.0.22.dist-info/RECORD +67 -0
- skilleter_thingy-0.0.22.dist-info/WHEEL +5 -0
- skilleter_thingy-0.0.22.dist-info/entry_points.txt +43 -0
- skilleter_thingy-0.0.22.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
""" Convert colour highlighting codes from the LS_COLORS environment variable
|
|
4
|
+
used by ls to curses
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
################################################################################
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
import os
|
|
11
|
+
import glob
|
|
12
|
+
import fnmatch
|
|
13
|
+
import curses
|
|
14
|
+
import stat
|
|
15
|
+
|
|
16
|
+
################################################################################
|
|
17
|
+
|
|
18
|
+
class CursesDircolors:
|
|
19
|
+
""" Convert dircolors codes to curses colours """
|
|
20
|
+
|
|
21
|
+
# Convert standard foreground and background codes to curses equivalents
|
|
22
|
+
|
|
23
|
+
ANSI_CONVERT_FORE = {
|
|
24
|
+
30: curses.COLOR_BLACK,
|
|
25
|
+
31: curses.COLOR_RED,
|
|
26
|
+
32: curses.COLOR_GREEN,
|
|
27
|
+
33: curses.COLOR_YELLOW,
|
|
28
|
+
34: curses.COLOR_BLUE,
|
|
29
|
+
35: curses.COLOR_MAGENTA,
|
|
30
|
+
36: curses.COLOR_CYAN,
|
|
31
|
+
37: curses.COLOR_WHITE,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ANSI_CONVERT_BACK = {
|
|
35
|
+
40: curses.COLOR_BLACK,
|
|
36
|
+
41: curses.COLOR_RED,
|
|
37
|
+
42: curses.COLOR_GREEN,
|
|
38
|
+
43: curses.COLOR_YELLOW,
|
|
39
|
+
44: curses.COLOR_BLUE,
|
|
40
|
+
45: curses.COLOR_MAGENTA,
|
|
41
|
+
46: curses.COLOR_CYAN,
|
|
42
|
+
47: curses.COLOR_WHITE,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Convert attribute codes to their meanings
|
|
46
|
+
# TODO: Attributes not handled yet
|
|
47
|
+
|
|
48
|
+
ANSI_CONVERT_ATTR = {
|
|
49
|
+
0: 0,
|
|
50
|
+
1: curses.A_BOLD,
|
|
51
|
+
4: curses.A_UNDERLINE,
|
|
52
|
+
5: curses.A_BLINK,
|
|
53
|
+
7: curses.A_BLINK,
|
|
54
|
+
8: curses.A_INVIS,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Default colour
|
|
58
|
+
|
|
59
|
+
DEFAULT_ATTR = {'attr': [], 'fore': -1, 'back': -1}
|
|
60
|
+
|
|
61
|
+
################################################################################
|
|
62
|
+
|
|
63
|
+
def __init__(self, reserved=0):
|
|
64
|
+
# Create the lookup tables associating special type codes or wildcards
|
|
65
|
+
# with colour pairs.
|
|
66
|
+
|
|
67
|
+
self.colour_pairs = [[-1, -1]]
|
|
68
|
+
|
|
69
|
+
self.wildcard_highlight = {}
|
|
70
|
+
self.special_highlight = {}
|
|
71
|
+
|
|
72
|
+
self.reserved = reserved
|
|
73
|
+
|
|
74
|
+
self.init_ls_colours()
|
|
75
|
+
|
|
76
|
+
################################################################################
|
|
77
|
+
|
|
78
|
+
def curses_alloc_pair(self, attr):
|
|
79
|
+
""" Given a set of attributes return the equivalent curses colour pair,
|
|
80
|
+
creating a new one if a matching one doesn't already exsit """
|
|
81
|
+
|
|
82
|
+
# TODO: Take account of attributes as well as colours
|
|
83
|
+
|
|
84
|
+
colours = [attr['fore'], attr['back']]
|
|
85
|
+
|
|
86
|
+
# Get an existing colour pair that uses the same colours or create
|
|
87
|
+
# a new one if one doesn't exist
|
|
88
|
+
|
|
89
|
+
if colours in self.colour_pairs:
|
|
90
|
+
pair_index = self.colour_pairs.index(colours) + self.reserved
|
|
91
|
+
else:
|
|
92
|
+
pair_index = len(self.colour_pairs) + self.reserved
|
|
93
|
+
self.colour_pairs.append(colours)
|
|
94
|
+
curses.init_pair(pair_index, attr['fore'], attr['back'])
|
|
95
|
+
|
|
96
|
+
return pair_index
|
|
97
|
+
|
|
98
|
+
################################################################################
|
|
99
|
+
|
|
100
|
+
def curses_colour(self, code):
|
|
101
|
+
""" Return a cursors colour pair index for the specified dircolor colour
|
|
102
|
+
code string. """
|
|
103
|
+
|
|
104
|
+
# Default attribute
|
|
105
|
+
|
|
106
|
+
attr = {'attr': [], 'fore': -1, 'back': -1}
|
|
107
|
+
|
|
108
|
+
# Non-zero if processing multi-value colour code
|
|
109
|
+
|
|
110
|
+
special = 0
|
|
111
|
+
special_item = None
|
|
112
|
+
|
|
113
|
+
# We trigger a ValueError and fail on anything that's wrong in the code
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
# Split into fields and convert to integer values
|
|
117
|
+
|
|
118
|
+
codes = [int(c) for c in code.split(';')]
|
|
119
|
+
|
|
120
|
+
for entry in codes:
|
|
121
|
+
# Process 2nd entry in a special colour sequence - must have value of 5
|
|
122
|
+
|
|
123
|
+
if special == 1:
|
|
124
|
+
if entry != 5:
|
|
125
|
+
raise ValueError
|
|
126
|
+
special = 2
|
|
127
|
+
|
|
128
|
+
# Process 3rd entry in a special colour sequence - must be the colour
|
|
129
|
+
# code between 0 and 255
|
|
130
|
+
|
|
131
|
+
elif special == 2:
|
|
132
|
+
if entry < 0 or entry > 255:
|
|
133
|
+
raise ValueError
|
|
134
|
+
|
|
135
|
+
attr[special_item] = entry
|
|
136
|
+
special = 0
|
|
137
|
+
|
|
138
|
+
# Normal foreground colour
|
|
139
|
+
|
|
140
|
+
elif entry in self.ANSI_CONVERT_FORE:
|
|
141
|
+
attr['fore'] = self.ANSI_CONVERT_FORE[entry]
|
|
142
|
+
|
|
143
|
+
# Normal background colour
|
|
144
|
+
|
|
145
|
+
elif entry in self.ANSI_CONVERT_BACK:
|
|
146
|
+
attr['back'] = self.ANSI_CONVERT_BACK[entry]
|
|
147
|
+
|
|
148
|
+
# Special foreground colour in the form 38;5;VALUE
|
|
149
|
+
|
|
150
|
+
elif entry == 38:
|
|
151
|
+
special = 1
|
|
152
|
+
special_item = 'fore'
|
|
153
|
+
|
|
154
|
+
# Special background colour in the form 48;5;VALUE
|
|
155
|
+
|
|
156
|
+
elif entry == 48:
|
|
157
|
+
special = 1
|
|
158
|
+
special_item = 'back'
|
|
159
|
+
|
|
160
|
+
# Attribute (underline, bold, etc.)
|
|
161
|
+
|
|
162
|
+
elif entry in self.ANSI_CONVERT_ATTR:
|
|
163
|
+
attr['attr'].append(self.ANSI_CONVERT_ATTR[entry])
|
|
164
|
+
|
|
165
|
+
# Anything else is an error
|
|
166
|
+
|
|
167
|
+
else:
|
|
168
|
+
raise ValueError
|
|
169
|
+
|
|
170
|
+
except ValueError:
|
|
171
|
+
print(f'Invalid colour specification: "{code}"')
|
|
172
|
+
sys.exit(1)
|
|
173
|
+
|
|
174
|
+
# Allocate a colour pair for the colour combination and return it
|
|
175
|
+
|
|
176
|
+
return self.curses_alloc_pair(attr)
|
|
177
|
+
|
|
178
|
+
################################################################################
|
|
179
|
+
|
|
180
|
+
def init_ls_colours(self):
|
|
181
|
+
""" Generate tables matching special file types (fifos, sockets, etc.) and
|
|
182
|
+
wildcards to curses colour pairs """
|
|
183
|
+
|
|
184
|
+
colour_data = os.environ.get('LS_COLORS', '').split(':')
|
|
185
|
+
|
|
186
|
+
# Iterate through the highlighters, create/get a colour pair corresponding
|
|
187
|
+
# to the colour codes and save one of the tables.
|
|
188
|
+
|
|
189
|
+
for item in colour_data:
|
|
190
|
+
item = item.strip()
|
|
191
|
+
if '=' in item:
|
|
192
|
+
code, colour = item.split('=')
|
|
193
|
+
|
|
194
|
+
colour_pair = self.curses_colour(colour)
|
|
195
|
+
|
|
196
|
+
if len(code) == 2 and '*' not in code and '.' not in code:
|
|
197
|
+
self.special_highlight[code] = colour_pair
|
|
198
|
+
else:
|
|
199
|
+
self.wildcard_highlight[code] = colour_pair
|
|
200
|
+
|
|
201
|
+
################################################################################
|
|
202
|
+
|
|
203
|
+
def get_colour(self, filename, filemode=None):
|
|
204
|
+
""" Get the curses colour for a filename, returns 0 if no highlighting
|
|
205
|
+
is needed """
|
|
206
|
+
|
|
207
|
+
if filemode:
|
|
208
|
+
if stat.S_ISDIR(filemode):
|
|
209
|
+
if 'di' in self.special_highlight:
|
|
210
|
+
return self.special_highlight['di']
|
|
211
|
+
elif stat.S_ISLNK(filemode):
|
|
212
|
+
destfile = os.readlink(filename)
|
|
213
|
+
|
|
214
|
+
if os.path.exists(destfile):
|
|
215
|
+
if 'ln' in self.special_highlight:
|
|
216
|
+
return self.special_highlight['ln']
|
|
217
|
+
elif 'or' in self.special_highlight:
|
|
218
|
+
return self.special_highlight['or']
|
|
219
|
+
|
|
220
|
+
elif stat.S_ISBLK(filemode):
|
|
221
|
+
if 'bd' in self.special_highlight:
|
|
222
|
+
return self.special_highlight['bd']
|
|
223
|
+
elif stat.S_ISCHR(filemode):
|
|
224
|
+
if 'cd' in self.special_highlight:
|
|
225
|
+
return self.special_highlight['cd']
|
|
226
|
+
|
|
227
|
+
if filemode & stat.S_IXUSR:
|
|
228
|
+
if 'ex' in self.special_highlight:
|
|
229
|
+
return self.special_highlight['ex']
|
|
230
|
+
|
|
231
|
+
for entry in self.wildcard_highlight:
|
|
232
|
+
if fnmatch.fnmatch(filename, entry):
|
|
233
|
+
colour = self.wildcard_highlight[entry]
|
|
234
|
+
break
|
|
235
|
+
else:
|
|
236
|
+
colour = 0
|
|
237
|
+
|
|
238
|
+
return colour
|
|
239
|
+
|
|
240
|
+
################################################################################
|
|
241
|
+
|
|
242
|
+
def get_colour_pair(self, filename, filemode=None):
|
|
243
|
+
""" Get the curses colour pair for a filename, optionally specifying the
|
|
244
|
+
file mode (as per os.stat()) """
|
|
245
|
+
|
|
246
|
+
return curses.color_pair(self.get_colour(filename, filemode))
|
|
247
|
+
|
|
248
|
+
################################################################################
|
|
249
|
+
|
|
250
|
+
def _test_code(stdscr):
|
|
251
|
+
""" Entry point """
|
|
252
|
+
|
|
253
|
+
curses.start_color()
|
|
254
|
+
curses.use_default_colors()
|
|
255
|
+
|
|
256
|
+
# Initialise colours
|
|
257
|
+
|
|
258
|
+
dc = CursesDircolors()
|
|
259
|
+
|
|
260
|
+
# Demo code to list files specified by the first command line argument
|
|
261
|
+
# highlighted appropriately
|
|
262
|
+
|
|
263
|
+
y = 0
|
|
264
|
+
for filename in glob.glob(sys.argv[1]):
|
|
265
|
+
colour = dc.get_colour(filename)
|
|
266
|
+
|
|
267
|
+
stdscr.addstr(y, 0, filename, curses.color_pair(colour))
|
|
268
|
+
|
|
269
|
+
y += 1
|
|
270
|
+
if y > 30:
|
|
271
|
+
break
|
|
272
|
+
|
|
273
|
+
stdscr.getch()
|
|
274
|
+
|
|
275
|
+
################################################################################
|
|
276
|
+
|
|
277
|
+
if __name__ == "__main__":
|
|
278
|
+
curses.wrapper(_test_code)
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
""" Default dircolors data, and the reference .dircolors file.
|
|
2
|
+
Generated from dircolors in GNU coreutils version 8.31 """
|
|
3
|
+
|
|
4
|
+
__all__ = ['DEFAULT_DIRCOLORS', 'DEFAULT_LS_COLORS']
|
|
5
|
+
|
|
6
|
+
# the output of `dircolors -p`
|
|
7
|
+
DEFAULT_DIRCOLORS = r"""
|
|
8
|
+
# Configuration file for dircolors, a utility to help you set the
|
|
9
|
+
# LS_COLORS environment variable used by GNU ls with the --color option.
|
|
10
|
+
# Copyright (C) 1996-2019 Free Software Foundation, Inc.
|
|
11
|
+
# Copying and distribution of this file, with or without modification,
|
|
12
|
+
# are permitted provided the copyright notice and this notice are preserved.
|
|
13
|
+
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
|
|
14
|
+
# slackware version of dircolors) are recognized but ignored.
|
|
15
|
+
# Below are TERM entries, which can be a glob patterns, to match
|
|
16
|
+
# against the TERM environment variable to determine if it is colorizable.
|
|
17
|
+
TERM Eterm
|
|
18
|
+
TERM ansi
|
|
19
|
+
TERM *color*
|
|
20
|
+
TERM con[0-9]*x[0-9]*
|
|
21
|
+
TERM cons25
|
|
22
|
+
TERM console
|
|
23
|
+
TERM cygwin
|
|
24
|
+
TERM dtterm
|
|
25
|
+
TERM gnome
|
|
26
|
+
TERM hurd
|
|
27
|
+
TERM jfbterm
|
|
28
|
+
TERM konsole
|
|
29
|
+
TERM kterm
|
|
30
|
+
TERM linux
|
|
31
|
+
TERM linux-c
|
|
32
|
+
TERM mlterm
|
|
33
|
+
TERM putty
|
|
34
|
+
TERM rxvt*
|
|
35
|
+
TERM screen*
|
|
36
|
+
TERM st
|
|
37
|
+
TERM terminator
|
|
38
|
+
TERM tmux*
|
|
39
|
+
TERM vt100
|
|
40
|
+
TERM xterm*
|
|
41
|
+
# Below are the color init strings for the basic file types.
|
|
42
|
+
# One can use codes for 256 or more colors supported by modern terminals.
|
|
43
|
+
# The default color codes use the capabilities of an 8 color terminal
|
|
44
|
+
# with some additional attributes as per the following codes:
|
|
45
|
+
# Attribute codes:
|
|
46
|
+
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
|
47
|
+
# Text color codes:
|
|
48
|
+
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
|
49
|
+
# Background color codes:
|
|
50
|
+
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
|
51
|
+
#NORMAL 00 # no color code at all
|
|
52
|
+
#FILE 00 # regular file: use no color at all
|
|
53
|
+
RESET 0 # reset to "normal" color
|
|
54
|
+
DIR 01;34 # directory
|
|
55
|
+
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
|
|
56
|
+
# numerical value, the color is as for the file pointed to.)
|
|
57
|
+
MULTIHARDLINK 00 # regular file with more than one link
|
|
58
|
+
FIFO 40;33 # pipe
|
|
59
|
+
SOCK 01;35 # socket
|
|
60
|
+
DOOR 01;35 # door
|
|
61
|
+
BLK 40;33;01 # block device driver
|
|
62
|
+
CHR 40;33;01 # character device driver
|
|
63
|
+
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
|
|
64
|
+
MISSING 00 # ... and the files they point to
|
|
65
|
+
SETUID 37;41 # file that is setuid (u+s)
|
|
66
|
+
SETGID 30;43 # file that is setgid (g+s)
|
|
67
|
+
CAPABILITY 30;41 # file with capability
|
|
68
|
+
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
|
|
69
|
+
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
|
|
70
|
+
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
|
|
71
|
+
# This is for files with execute permission:
|
|
72
|
+
EXEC 01;32
|
|
73
|
+
# List any file extensions like '.gz' or '.tar' that you would like ls
|
|
74
|
+
# to colorize below. Put the extension, a space, and the color init string.
|
|
75
|
+
# (and any comments you want to add after a '#')
|
|
76
|
+
# If you use DOS-style suffixes, you may want to uncomment the following:
|
|
77
|
+
#.cmd 01;32 # executables (bright green)
|
|
78
|
+
#.exe 01;32
|
|
79
|
+
#.com 01;32
|
|
80
|
+
#.btm 01;32
|
|
81
|
+
#.bat 01;32
|
|
82
|
+
# Or if you want to colorize scripts even if they do not have the
|
|
83
|
+
# executable bit actually set.
|
|
84
|
+
#.sh 01;32
|
|
85
|
+
#.csh 01;32
|
|
86
|
+
# archives or compressed (bright red)
|
|
87
|
+
.tar 01;31
|
|
88
|
+
.tgz 01;31
|
|
89
|
+
.arc 01;31
|
|
90
|
+
.arj 01;31
|
|
91
|
+
.taz 01;31
|
|
92
|
+
.lha 01;31
|
|
93
|
+
.lz4 01;31
|
|
94
|
+
.lzh 01;31
|
|
95
|
+
.lzma 01;31
|
|
96
|
+
.tlz 01;31
|
|
97
|
+
.txz 01;31
|
|
98
|
+
.tzo 01;31
|
|
99
|
+
.t7z 01;31
|
|
100
|
+
.zip 01;31
|
|
101
|
+
.z 01;31
|
|
102
|
+
.dz 01;31
|
|
103
|
+
.gz 01;31
|
|
104
|
+
.lrz 01;31
|
|
105
|
+
.lz 01;31
|
|
106
|
+
.lzo 01;31
|
|
107
|
+
.xz 01;31
|
|
108
|
+
.zst 01;31
|
|
109
|
+
.tzst 01;31
|
|
110
|
+
.bz2 01;31
|
|
111
|
+
.bz 01;31
|
|
112
|
+
.tbz 01;31
|
|
113
|
+
.tbz2 01;31
|
|
114
|
+
.tz 01;31
|
|
115
|
+
.deb 01;31
|
|
116
|
+
.rpm 01;31
|
|
117
|
+
.jar 01;31
|
|
118
|
+
.war 01;31
|
|
119
|
+
.ear 01;31
|
|
120
|
+
.sar 01;31
|
|
121
|
+
.rar 01;31
|
|
122
|
+
.alz 01;31
|
|
123
|
+
.ace 01;31
|
|
124
|
+
.zoo 01;31
|
|
125
|
+
.cpio 01;31
|
|
126
|
+
.7z 01;31
|
|
127
|
+
.rz 01;31
|
|
128
|
+
.cab 01;31
|
|
129
|
+
.wim 01;31
|
|
130
|
+
.swm 01;31
|
|
131
|
+
.dwm 01;31
|
|
132
|
+
.esd 01;31
|
|
133
|
+
# image formats
|
|
134
|
+
.jpg 01;35
|
|
135
|
+
.jpeg 01;35
|
|
136
|
+
.mjpg 01;35
|
|
137
|
+
.mjpeg 01;35
|
|
138
|
+
.gif 01;35
|
|
139
|
+
.bmp 01;35
|
|
140
|
+
.pbm 01;35
|
|
141
|
+
.pgm 01;35
|
|
142
|
+
.ppm 01;35
|
|
143
|
+
.tga 01;35
|
|
144
|
+
.xbm 01;35
|
|
145
|
+
.xpm 01;35
|
|
146
|
+
.tif 01;35
|
|
147
|
+
.tiff 01;35
|
|
148
|
+
.png 01;35
|
|
149
|
+
.svg 01;35
|
|
150
|
+
.svgz 01;35
|
|
151
|
+
.mng 01;35
|
|
152
|
+
.pcx 01;35
|
|
153
|
+
.mov 01;35
|
|
154
|
+
.mpg 01;35
|
|
155
|
+
.mpeg 01;35
|
|
156
|
+
.m2v 01;35
|
|
157
|
+
.mkv 01;35
|
|
158
|
+
.webm 01;35
|
|
159
|
+
.ogm 01;35
|
|
160
|
+
.mp4 01;35
|
|
161
|
+
.m4v 01;35
|
|
162
|
+
.mp4v 01;35
|
|
163
|
+
.vob 01;35
|
|
164
|
+
.qt 01;35
|
|
165
|
+
.nuv 01;35
|
|
166
|
+
.wmv 01;35
|
|
167
|
+
.asf 01;35
|
|
168
|
+
.rm 01;35
|
|
169
|
+
.rmvb 01;35
|
|
170
|
+
.flc 01;35
|
|
171
|
+
.avi 01;35
|
|
172
|
+
.fli 01;35
|
|
173
|
+
.flv 01;35
|
|
174
|
+
.gl 01;35
|
|
175
|
+
.dl 01;35
|
|
176
|
+
.xcf 01;35
|
|
177
|
+
.xwd 01;35
|
|
178
|
+
.yuv 01;35
|
|
179
|
+
.cgm 01;35
|
|
180
|
+
.emf 01;35
|
|
181
|
+
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
|
|
182
|
+
.ogv 01;35
|
|
183
|
+
.ogx 01;35
|
|
184
|
+
# audio formats
|
|
185
|
+
.aac 00;36
|
|
186
|
+
.au 00;36
|
|
187
|
+
.flac 00;36
|
|
188
|
+
.m4a 00;36
|
|
189
|
+
.mid 00;36
|
|
190
|
+
.midi 00;36
|
|
191
|
+
.mka 00;36
|
|
192
|
+
.mp3 00;36
|
|
193
|
+
.mpc 00;36
|
|
194
|
+
.ogg 00;36
|
|
195
|
+
.ra 00;36
|
|
196
|
+
.wav 00;36
|
|
197
|
+
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
|
|
198
|
+
.oga 00;36
|
|
199
|
+
.opus 00;36
|
|
200
|
+
.spx 00;36
|
|
201
|
+
.xspf 00;36
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
# the above converted to LS_COLORS by dircolors, but with the trailing ':' stripped
|
|
205
|
+
DEFAULT_LS_COLORS = r"""
|
|
206
|
+
rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:
|
|
207
|
+
mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:
|
|
208
|
+
*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:
|
|
209
|
+
*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:
|
|
210
|
+
*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:
|
|
211
|
+
*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:
|
|
212
|
+
*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:
|
|
213
|
+
*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:
|
|
214
|
+
*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:
|
|
215
|
+
*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:
|
|
216
|
+
*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:
|
|
217
|
+
*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:
|
|
218
|
+
*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:
|
|
219
|
+
*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:
|
|
220
|
+
*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:
|
|
221
|
+
*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36""".replace('\n', '')
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# private utility functions for pydircolors
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2019 Allen Wild <allenwild93@gmail.com>
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
""" private/internal utility functions for pydircolors """
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
|
|
10
|
+
__all__ = ['stat_at', 'readlink_at']
|
|
11
|
+
|
|
12
|
+
def stat_at(file, cwd=None, follow_symlinks=False):
|
|
13
|
+
""" helper function to call os.stat on a file relative to a given directory.
|
|
14
|
+
cwd should be a string, and will be opened as read-only (then closed), or an integer
|
|
15
|
+
for an already-open directory file descriptor (which won't be closed).
|
|
16
|
+
os.open or os.stat may raise various errors, which are passed on. """
|
|
17
|
+
if isinstance(cwd, str):
|
|
18
|
+
dirfd = os.open(cwd, os.O_RDONLY)
|
|
19
|
+
need_to_close = True
|
|
20
|
+
elif cwd is None or isinstance(cwd, int):
|
|
21
|
+
dirfd = cwd
|
|
22
|
+
need_to_close = False
|
|
23
|
+
else:
|
|
24
|
+
raise ValueError('cwd must be str, int, or None')
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
return os.stat(file, dir_fd=dirfd, follow_symlinks=follow_symlinks)
|
|
28
|
+
finally:
|
|
29
|
+
if need_to_close:
|
|
30
|
+
os.close(dirfd)
|
|
31
|
+
|
|
32
|
+
def readlink_at(file, cwd=None):
|
|
33
|
+
""" helper function to call os.readlink on a file relative to a given directory.
|
|
34
|
+
cwd should be a string, and will be opened as read-only (then closed), or an integer
|
|
35
|
+
for an already-open directory file descriptor (which won't be closed).
|
|
36
|
+
os.open or os.readlink may raise various errors, which are passed on. """
|
|
37
|
+
if isinstance(cwd, str):
|
|
38
|
+
dirfd = os.open(cwd, os.O_RDONLY)
|
|
39
|
+
need_to_close = True
|
|
40
|
+
elif cwd is None or isinstance(cwd, int):
|
|
41
|
+
dirfd = cwd
|
|
42
|
+
need_to_close = False
|
|
43
|
+
else:
|
|
44
|
+
raise ValueError('cwd must be str, int, or None')
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
return os.readlink(file, dir_fd=dirfd)
|
|
48
|
+
finally:
|
|
49
|
+
if need_to_close:
|
|
50
|
+
os.close(dirfd)
|