skilleter-thingy 0.2.1__py3-none-any.whl → 0.2.3__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/ggit.py +0 -1
- skilleter_thingy/ggrep.py +0 -1
- skilleter_thingy/git_br.py +0 -7
- skilleter_thingy/git_ca.py +0 -8
- skilleter_thingy/git_cleanup.py +0 -11
- skilleter_thingy/git_co.py +3 -8
- skilleter_thingy/git_common.py +4 -12
- skilleter_thingy/git_hold.py +0 -9
- skilleter_thingy/git_mr.py +0 -11
- skilleter_thingy/git_parent.py +18 -23
- skilleter_thingy/git_retag.py +0 -10
- skilleter_thingy/git_retag.sync-conflict-20250928-192600-TVSLRWK.py +54 -0
- skilleter_thingy/git_review.py +0 -1
- skilleter_thingy/git_update.py +0 -1
- skilleter_thingy/git_wt.py +0 -2
- skilleter_thingy/gitprompt.py +0 -1
- skilleter_thingy/thingy/git.py +5 -18
- skilleter_thingy/thingy/git2.py +7 -20
- {skilleter_thingy-0.2.1.dist-info → skilleter_thingy-0.2.3.dist-info}/METADATA +1 -46
- skilleter_thingy-0.2.3.dist-info/PKG-INFO 2 +193 -0
- {skilleter_thingy-0.2.1.dist-info → skilleter_thingy-0.2.3.dist-info}/RECORD +25 -32
- {skilleter_thingy-0.2.1.dist-info → skilleter_thingy-0.2.3.dist-info}/entry_points.txt +0 -9
- skilleter_thingy/borger.py +0 -273
- skilleter_thingy/diskspacecheck.py +0 -67
- skilleter_thingy/localphotosync.py +0 -201
- skilleter_thingy/moviemover.py +0 -133
- skilleter_thingy/photodupe.py +0 -135
- skilleter_thingy/phototidier.py +0 -248
- skilleter_thingy/splitpics.py +0 -99
- skilleter_thingy/sysmon.py +0 -435
- skilleter_thingy/window_rename.py +0 -92
- {skilleter_thingy-0.2.1.dist-info → skilleter_thingy-0.2.3.dist-info}/WHEEL +0 -0
- {skilleter_thingy-0.2.1.dist-info → skilleter_thingy-0.2.3.dist-info}/licenses/LICENSE +0 -0
- {skilleter_thingy-0.2.1.dist-info → skilleter_thingy-0.2.3.dist-info}/top_level.txt +0 -0
skilleter_thingy/phototidier.py
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
""" Perform various tidying operations on a directory full of photos:
|
|
4
|
-
1. Remove leading '$' and '_' from filenames
|
|
5
|
-
2. Move files in hidden directories up 1 level
|
|
6
|
-
3. If the EXIF data in a photo indicates that it was taken on date that
|
|
7
|
-
doesn't match the name of the directory it is stored in (in YYYY-MM-DD format)
|
|
8
|
-
then it is moved to the correct directory, creating it if necessary.
|
|
9
|
-
|
|
10
|
-
All move/rename operations are carried out safely with the file being moved having
|
|
11
|
-
a numeric suffix added to the name if it conflicts with an existing file.
|
|
12
|
-
|
|
13
|
-
TODO: Ignore .stversions files
|
|
14
|
-
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
################################################################################
|
|
18
|
-
|
|
19
|
-
import argparse
|
|
20
|
-
import os
|
|
21
|
-
import sys
|
|
22
|
-
import pathlib
|
|
23
|
-
import re
|
|
24
|
-
|
|
25
|
-
from PIL import UnidentifiedImageError
|
|
26
|
-
from PIL import Image
|
|
27
|
-
from PIL.ExifTags import TAGS
|
|
28
|
-
|
|
29
|
-
import thingy.colour as colour
|
|
30
|
-
|
|
31
|
-
################################################################################
|
|
32
|
-
|
|
33
|
-
FILE_TYPES = ('.jpg', '.jpeg')
|
|
34
|
-
|
|
35
|
-
DATE_RE = re.compile(r'[0-9]{4}-[0-9]{2}-[0-9]{2}')
|
|
36
|
-
|
|
37
|
-
NUMBER_RE = re.compile(r'(.*) +\([0-9]+\).*')
|
|
38
|
-
|
|
39
|
-
################################################################################
|
|
40
|
-
|
|
41
|
-
def error(msg, status=1):
|
|
42
|
-
""" Exit with an error message """
|
|
43
|
-
|
|
44
|
-
print(msg)
|
|
45
|
-
|
|
46
|
-
sys.exit(status)
|
|
47
|
-
|
|
48
|
-
################################################################################
|
|
49
|
-
|
|
50
|
-
def parse_command_line():
|
|
51
|
-
""" Handle command line arguments """
|
|
52
|
-
|
|
53
|
-
parser = argparse.ArgumentParser(description='Re-organise photos into (hopefully) the correct folders.')
|
|
54
|
-
|
|
55
|
-
parser.add_argument('--dry-run', '-D', action='store_true', help='Report what files would be moved, without actually moving them')
|
|
56
|
-
parser.add_argument('path', nargs=1, help='Path to the picture storage directory')
|
|
57
|
-
|
|
58
|
-
args = parser.parse_args()
|
|
59
|
-
|
|
60
|
-
if not os.path.isdir(args.path[0]):
|
|
61
|
-
error(f'{args.path} is not a directory')
|
|
62
|
-
|
|
63
|
-
args.path = pathlib.Path(os.path.realpath(args.path[0]))
|
|
64
|
-
|
|
65
|
-
return args
|
|
66
|
-
|
|
67
|
-
################################################################################
|
|
68
|
-
|
|
69
|
-
def safe_rename(args, source_file, new_name):
|
|
70
|
-
""" Rename a file, adding a numeric suffix to avoid overwriting anything """
|
|
71
|
-
|
|
72
|
-
# If the destination file exists, add a numeric suffix to the new name
|
|
73
|
-
# until we find one that doesn't
|
|
74
|
-
|
|
75
|
-
index = 1
|
|
76
|
-
new_name_stem = new_name.stem
|
|
77
|
-
|
|
78
|
-
while new_name.exists():
|
|
79
|
-
new_name = new_name.with_name(f'{new_name_stem}-{index}{new_name.suffix}')
|
|
80
|
-
index += 1
|
|
81
|
-
|
|
82
|
-
colour.write(f'Rename [BLUE:{source_file}] to [BLUE:{new_name}]')
|
|
83
|
-
|
|
84
|
-
# Panic if the destination parent directory exists, but isn't actually a directory
|
|
85
|
-
|
|
86
|
-
if new_name.parent.exists and not new_name.parent.is_dir:
|
|
87
|
-
colour.write('[RED:WARNING]: Destination [BLUE:{new_name.parent}] exists, but is not a directory - [BLUE:{source_file}] will not be renamed')
|
|
88
|
-
return source_file
|
|
89
|
-
|
|
90
|
-
# Rename and return the new namem, creating the directory for it to go in, if necessary
|
|
91
|
-
|
|
92
|
-
if not args.dry_run:
|
|
93
|
-
new_name.parent.mkdir(parents=True, exist_ok=True)
|
|
94
|
-
|
|
95
|
-
source_file.rename(new_name)
|
|
96
|
-
|
|
97
|
-
return new_name
|
|
98
|
-
|
|
99
|
-
################################################################################
|
|
100
|
-
|
|
101
|
-
def get_exif_date(source_file):
|
|
102
|
-
""" Try an extract the daste when the photo was taken from the EXIF data
|
|
103
|
-
and return it in YYYY/YYYY-MM-DD format as the subdirectory where
|
|
104
|
-
the photo should be located """
|
|
105
|
-
|
|
106
|
-
# Get the EXIF data
|
|
107
|
-
|
|
108
|
-
try:
|
|
109
|
-
photo = Image.open(source_file)
|
|
110
|
-
except (OSError, UnidentifiedImageError):
|
|
111
|
-
colour.write(f'[RED:ERROR]: [BLUE:{source_file}] does not appear to be a valid image - ignoring EXIF data')
|
|
112
|
-
return None
|
|
113
|
-
|
|
114
|
-
exif = photo.getexif()
|
|
115
|
-
|
|
116
|
-
# Search for the original date/time tag
|
|
117
|
-
|
|
118
|
-
for tag_id in exif:
|
|
119
|
-
tag = TAGS.get(tag_id, tag_id)
|
|
120
|
-
|
|
121
|
-
if tag == 'DateTimeOriginal':
|
|
122
|
-
data = exif.get(tag_id)
|
|
123
|
-
if isinstance(data, bytes):
|
|
124
|
-
data = data.decode()
|
|
125
|
-
|
|
126
|
-
# Ignore dummy value
|
|
127
|
-
|
|
128
|
-
if data.startswith('0000:00:00'):
|
|
129
|
-
return None
|
|
130
|
-
|
|
131
|
-
# Convert to YYYY-MM-DD format, removing the time
|
|
132
|
-
|
|
133
|
-
date = f'{int(data[0:4]):04}-{int(data[5:7]):02}-{int(data[8:10]):02}'
|
|
134
|
-
|
|
135
|
-
return date
|
|
136
|
-
|
|
137
|
-
# No date tag found
|
|
138
|
-
|
|
139
|
-
return None
|
|
140
|
-
|
|
141
|
-
################################################################################
|
|
142
|
-
|
|
143
|
-
def fix_file(args, source_file):
|
|
144
|
-
""" Fix a file by moving or renaming it to fix naming or directory issues """
|
|
145
|
-
|
|
146
|
-
# Get the image date from the EXIF data
|
|
147
|
-
|
|
148
|
-
image_date = get_exif_date(source_file)
|
|
149
|
-
|
|
150
|
-
# If the file starts with $, ~, _ or ., rename it to remove it
|
|
151
|
-
|
|
152
|
-
while source_file.name[0] in ('$', '~', '_', '.'):
|
|
153
|
-
new_name = source_file.with_name(source_file.name[1:])
|
|
154
|
-
|
|
155
|
-
source_file = safe_rename(args, source_file, new_name)
|
|
156
|
-
|
|
157
|
-
# If filename contains '~' then truncate it
|
|
158
|
-
|
|
159
|
-
if '~' in source_file.name:
|
|
160
|
-
new_name = source_file.with_name(source_file.name.split('~')[0] + source_file.suffix)
|
|
161
|
-
|
|
162
|
-
source_file = safe_rename(args, source_file, new_name)
|
|
163
|
-
|
|
164
|
-
# If the directory name starts with . or $ move the file up 1 level
|
|
165
|
-
|
|
166
|
-
while source_file.parts[-2][0] in ('$', '.'):
|
|
167
|
-
new_name = source_file.parent.parent / source_file.name
|
|
168
|
-
|
|
169
|
-
source_file = safe_rename(args, source_file, new_name)
|
|
170
|
-
|
|
171
|
-
# If the filename has a number in parentheses, then remove it
|
|
172
|
-
|
|
173
|
-
num_match = NUMBER_RE.fullmatch(source_file.stem)
|
|
174
|
-
if num_match:
|
|
175
|
-
new_name = source_file.parent / (num_match.group(1) + source_file.suffix)
|
|
176
|
-
|
|
177
|
-
source_file = safe_rename(args, source_file, new_name)
|
|
178
|
-
|
|
179
|
-
# See if the date in the EXIF data matches the directory name prefix
|
|
180
|
-
# and move it to the correct location if it doesn't
|
|
181
|
-
|
|
182
|
-
if image_date:
|
|
183
|
-
image_year = image_date.split('-')[0]
|
|
184
|
-
|
|
185
|
-
image_path = args.path / image_year / image_date
|
|
186
|
-
|
|
187
|
-
# If the file isn't already in a directory with the correct year and date
|
|
188
|
-
# move it to one that it
|
|
189
|
-
|
|
190
|
-
if not str(source_file.parent).startswith(str(image_path)):
|
|
191
|
-
# If the source directory has a description after the date, append that
|
|
192
|
-
# to the destination directory
|
|
193
|
-
# Otherwise, if the source directory doesn't have a date, append the whole
|
|
194
|
-
# directory name.
|
|
195
|
-
|
|
196
|
-
source_parent_dir = source_file.parts[-2]
|
|
197
|
-
|
|
198
|
-
if DATE_RE.match(source_parent_dir):
|
|
199
|
-
if len(source_parent_dir) > 10:
|
|
200
|
-
image_path = args.path / image_year / f'{image_date}{source_parent_dir[10:]}'
|
|
201
|
-
else:
|
|
202
|
-
image_path = args.path / image_year / f'{image_date} - {source_parent_dir}'
|
|
203
|
-
|
|
204
|
-
source_file = safe_rename(args, source_file, image_path / source_file.name)
|
|
205
|
-
|
|
206
|
-
################################################################################
|
|
207
|
-
|
|
208
|
-
def main():
|
|
209
|
-
""" Entry point """
|
|
210
|
-
|
|
211
|
-
args = parse_command_line()
|
|
212
|
-
|
|
213
|
-
# Disable the maximum image size in PIL
|
|
214
|
-
|
|
215
|
-
Image.MAX_IMAGE_PIXELS = None
|
|
216
|
-
|
|
217
|
-
# Find matching files in the source tree
|
|
218
|
-
|
|
219
|
-
print(f'Searching {args.path} with extension matching {", ".join(FILE_TYPES)}')
|
|
220
|
-
|
|
221
|
-
all_matches = args.path.glob('**/*')
|
|
222
|
-
|
|
223
|
-
matches = [file for file in all_matches if file.suffix.lower() in FILE_TYPES and file.is_file()]
|
|
224
|
-
|
|
225
|
-
print(f'Found {len(matches)} matching files')
|
|
226
|
-
|
|
227
|
-
for source_file in matches:
|
|
228
|
-
if '.stversions' not in source_file.parts:
|
|
229
|
-
fix_file(args, source_file)
|
|
230
|
-
|
|
231
|
-
################################################################################
|
|
232
|
-
|
|
233
|
-
def phototidier():
|
|
234
|
-
"""Entry point"""
|
|
235
|
-
|
|
236
|
-
try:
|
|
237
|
-
main()
|
|
238
|
-
|
|
239
|
-
except KeyboardInterrupt:
|
|
240
|
-
sys.exit(1)
|
|
241
|
-
|
|
242
|
-
except BrokenPipeError:
|
|
243
|
-
sys.exit(2)
|
|
244
|
-
|
|
245
|
-
################################################################################
|
|
246
|
-
|
|
247
|
-
if __name__ == '__main__':
|
|
248
|
-
phototidier()
|
skilleter_thingy/splitpics.py
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
################################################################################
|
|
4
|
-
""" Copy a directory full of pictures to a destination, creating subdiretories
|
|
5
|
-
with N pictures in each in the destination directory
|
|
6
|
-
"""
|
|
7
|
-
################################################################################
|
|
8
|
-
|
|
9
|
-
import os
|
|
10
|
-
import glob
|
|
11
|
-
import argparse
|
|
12
|
-
|
|
13
|
-
from PIL import Image
|
|
14
|
-
|
|
15
|
-
################################################################################
|
|
16
|
-
# Constants
|
|
17
|
-
|
|
18
|
-
DEFAULT_SOURCE_DIR = '/storage/Starred Photos/'
|
|
19
|
-
DEFAULT_DEST_DIR = '/media/jms/48A7-BE16'
|
|
20
|
-
DEFAULT_MAX_SIZE = 3840
|
|
21
|
-
|
|
22
|
-
################################################################################
|
|
23
|
-
|
|
24
|
-
def parse_command_line():
|
|
25
|
-
""" Parse the command line """
|
|
26
|
-
|
|
27
|
-
parser = argparse.ArgumentParser(description='Copy a collection of pictures to a set of numbered directories')
|
|
28
|
-
|
|
29
|
-
parser.add_argument('--pics', type=int, help='Number of pictures per directory (default is not to use numbered subdirectories)', default=None)
|
|
30
|
-
parser.add_argument('--max-size', type=int, help='Maximum size for each image in pixels (default=%d, images will be resized if larger)' %
|
|
31
|
-
DEFAULT_MAX_SIZE, default=DEFAULT_MAX_SIZE)
|
|
32
|
-
parser.add_argument('source', nargs=1, help='Source directory', default=DEFAULT_SOURCE_DIR)
|
|
33
|
-
parser.add_argument('destination', nargs=1, help='Destination directory', default=DEFAULT_DEST_DIR)
|
|
34
|
-
|
|
35
|
-
args = parser.parse_args()
|
|
36
|
-
|
|
37
|
-
return args
|
|
38
|
-
|
|
39
|
-
################################################################################
|
|
40
|
-
|
|
41
|
-
def copy_images(args):
|
|
42
|
-
""" Copy the images """
|
|
43
|
-
|
|
44
|
-
dir_num = -1
|
|
45
|
-
|
|
46
|
-
pictures = glob.glob(os.path.join(args.source[0], '*'))
|
|
47
|
-
dest_dir = args.destination[0]
|
|
48
|
-
|
|
49
|
-
if not os.path.isdir(dest_dir):
|
|
50
|
-
os.makedirs(dest_dir)
|
|
51
|
-
|
|
52
|
-
for index, picture in enumerate(pictures):
|
|
53
|
-
picture_name = os.path.basename(picture)
|
|
54
|
-
|
|
55
|
-
# Create the new directory in the destination every N pcitures
|
|
56
|
-
|
|
57
|
-
if args.pics and index % args.pics == 0:
|
|
58
|
-
dir_num += 1
|
|
59
|
-
dest_dir = os.path.join(args.destination[0], '%05d' % dir_num)
|
|
60
|
-
if not os.path.isdir(dest_dir):
|
|
61
|
-
os.makedirs(dest_dir)
|
|
62
|
-
|
|
63
|
-
print('%d/%d: Copying %s to %s' % (index + 1, len(pictures), picture, dest_dir))
|
|
64
|
-
|
|
65
|
-
# Resize the image if neccessary
|
|
66
|
-
|
|
67
|
-
image = Image.open(picture)
|
|
68
|
-
|
|
69
|
-
if args.max_size and (image.width > args.max_size or image.height > args.max_size):
|
|
70
|
-
if image.width > image.height:
|
|
71
|
-
scale = image.width / args.max_size
|
|
72
|
-
else:
|
|
73
|
-
scale = image.height / args.max_size
|
|
74
|
-
|
|
75
|
-
new_size = (round(image.width / scale), round(image.height / scale))
|
|
76
|
-
|
|
77
|
-
print(' Resizing from %d x %d to %d x %d' % (image.width, image.height, new_size[0], new_size[1]))
|
|
78
|
-
|
|
79
|
-
image.resize(new_size)
|
|
80
|
-
|
|
81
|
-
# Write the image
|
|
82
|
-
|
|
83
|
-
destination = os.path.join(dest_dir, picture_name)
|
|
84
|
-
|
|
85
|
-
image.save(destination)
|
|
86
|
-
|
|
87
|
-
################################################################################
|
|
88
|
-
|
|
89
|
-
def splitpics():
|
|
90
|
-
"""Entry point"""
|
|
91
|
-
|
|
92
|
-
args = parse_command_line()
|
|
93
|
-
|
|
94
|
-
copy_images(args)
|
|
95
|
-
|
|
96
|
-
################################################################################
|
|
97
|
-
|
|
98
|
-
if __name__ == '__main__':
|
|
99
|
-
splitpics()
|