skilleter-thingy 0.1.28__py3-none-any.whl → 0.1.30__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.

@@ -14,6 +14,7 @@ import sys
14
14
  import logging
15
15
  import argparse
16
16
  import re
17
+ import datetime
17
18
 
18
19
  from enum import Enum
19
20
 
@@ -126,15 +127,24 @@ def media_sync(args):
126
127
  continue
127
128
 
128
129
  date_match = filetype_re.fullmatch(os.path.basename(sourcefile))
129
- if not date_match:
130
- logging.debug('Ignoring %s - unable to extract date from filename', sourcefile)
131
- continue
130
+ if date_match:
131
+ year = date_match.group(2)
132
+ month = date_match.group(3)
133
+ day = date_match.group(4)
134
+
135
+ default_dest_dir = f'{dest_dir}/{year}/{year}-{month}-{day}'
136
+ else:
137
+ logging.debug('Ignoring %s - unable to extract date from filename - using last-modified date', sourcefile)
138
+
139
+ timestamp = os.path.getmtime(sourcefile)
140
+ last_modified_date = datetime.datetime.fromtimestamp(timestamp)
141
+
142
+ year = last_modified_date.year
143
+ month = last_modified_date.month
144
+ day = last_modified_date.day
132
145
 
133
- year = date_match.group(2)
134
- month = date_match.group(3)
135
- day = date_match.group(4)
146
+ default_dest_dir = f'{dest_dir}/{year:04}/{year:04}-{month:02}-{day:02}'
136
147
 
137
- default_dest_dir = f'{dest_dir}/{year}/{year}-{month}-{day}'
138
148
  dest_dir_pattern = f'{default_dest_dir}*'
139
149
 
140
150
  dest_dirs = [path for path in glob.glob(dest_dir_pattern) if os.path.isdir(path)]
@@ -317,6 +317,8 @@ def add_new_repo(args, config, repo):
317
317
 
318
318
  abs_repo_path = absolute_repo_path(args, repo)
319
319
 
320
+ added = repo not in config
321
+
320
322
  config[repo] = {}
321
323
 
322
324
  default_branch = git.branch(path=abs_repo_path)
@@ -335,7 +337,10 @@ def add_new_repo(args, config, repo):
335
337
  config[repo]['repo name'] = os.path.basename(repo)
336
338
 
337
339
  if not args.quiet:
338
- colour.write(f'Added [BLUE:{repo}] with default branch [BLUE:{default_branch}]')
340
+ if added:
341
+ colour.write(f'Added [BLUE:{repo}] with default branch [BLUE:{default_branch}]')
342
+ else:
343
+ colour.write(f'Reset [BLUE:{repo}] with default branch [BLUE:{default_branch}]')
339
344
 
340
345
  ################################################################################
341
346
 
@@ -472,9 +477,21 @@ def mg_add(args, config, console):
472
477
  location = args.parameters[1]
473
478
 
474
479
  if os.path.exists(location):
475
- colour.error(f'"[BLUE:{location}]" already exists', prefix=True)
480
+ if os.path.isdir(os.path.join(location, '.git')):
481
+ remotes = git.remotes(path=location)
482
+
483
+ for remote in remotes:
484
+ if repo.endswith('.git') and repo == remotes[remote]:
485
+ break
486
+ elif f'{repo}.git' == remotes[remote]:
487
+ break
488
+ else:
489
+ colour.error(f'"[BLUE:{location}]" already exists and was not cloned from [BLUE:{repo}]', prefix=True)
490
+ else:
491
+ colour.error(f'"[BLUE:{location}]" already exists and is not a Git working tree')
476
492
 
477
- git.clone(repo, path=location)
493
+ else:
494
+ git.clone(repo, path=location)
478
495
 
479
496
  # Add to the configuration
480
497
 
@@ -198,6 +198,17 @@ def error(txt, newline=True, stream=sys.stderr, status=1, prefix=False):
198
198
 
199
199
  ################################################################################
200
200
 
201
+ def warning(txt, newline=True, stream=sys.stderr, prefix=False):
202
+ """ Write a warning message to the specified stream (defaulting to
203
+ stderr). Prefix the output with 'WARNING:' in red if prefix==True """
204
+
205
+ if prefix:
206
+ write('[RED:WARNING]: ', newline=False, stream=stream, )
207
+
208
+ write(txt, newline, stream)
209
+
210
+ ################################################################################
211
+
201
212
  if __name__ == '__main__':
202
213
  write('Foreground: [RED]red [GREEN]green [BLACK]black [NORMAL]normal')
203
214
  write('Background: [BRED]red [BGREEN]green [BBLACK]black [NORMAL]normal')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: skilleter_thingy
3
- Version: 0.1.28
3
+ Version: 0.1.30
4
4
  Summary: A collection of useful utilities, mainly aimed at making Git more friendly
5
5
  Author-email: John Skilleter <john@skilleter.org.uk>
6
6
  Project-URL: Home, https://skilleter.org.uk
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.1
2
+ Name: skilleter_thingy
3
+ Version: 0.0.49
4
+ Summary: A collection of useful utilities, mainly aimed at making Git more friendly
5
+ Author-email: John Skilleter <john@skilleter.org.uk>
6
+ Project-URL: Home, https://skilleter.org.uk
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: imagehash
14
+ Requires-Dist: inotify
15
+ Requires-Dist: pillow
16
+ Requires-Dist: psutil
17
+ Requires-Dist: pyaml
18
+ Requires-Dist: pygit2
19
+ Requires-Dist: python-dateutil
20
+ Requires-Dist: requests
21
+
22
+ # Thingy
23
+
24
+ Licence: GPL v3
25
+
26
+ Author: John Skilleter v0.99
27
+
28
+ Collection of shell utilities and configuration stuff for Linux and MacOS. Untested on other operating systems.
29
+
30
+ Permanently (for the forseeable future!) in a beta stage - usable, with a few rough edges, and probably with bugs when used in way I'm not expecting!
31
+
32
+ The following commands are documented in detail in the help output that can be displayed by running the command with the '--help' option.
33
+
34
+ This README just contains a summary of the functionality of each command.
35
+
36
+ # General Commands
37
+
38
+ ## addpath
39
+
40
+ Update a $PATH-type variable by adding or removing entries.
41
+
42
+ ## borger
43
+
44
+ Wrapper for the borg backup utility to make it easier to use with a fixed set of options.
45
+
46
+ ## console-colours
47
+
48
+ Display all available colours in the console.
49
+
50
+ ## diskspacecheck
51
+
52
+ Check how much free space is available on all filesystems, ignoring read-only filesystems, /dev and tmpfs.
53
+
54
+ Issue a warning if any are above 90% used.
55
+
56
+ ## docker-purge
57
+
58
+ Stop or kill docker instances and/or remove docker images.
59
+
60
+ ## ffind
61
+
62
+ Simple file find utility
63
+
64
+ Implements the functionality of the find command that is regularly used in a simpler fashion and ignores all the options that nobody ever uses.
65
+
66
+ ## gl
67
+
68
+ ### gphotosync
69
+
70
+ Utility for syncing photos from Google Photos to local storage
71
+
72
+ ## linecount
73
+
74
+ Count lines of code in a directory tree organised by file type.
75
+
76
+ ## moviemover
77
+
78
+ Search for files matching a wildcard in a directory tree and move them to an equivalent location in a different tree
79
+
80
+ ## phototidier
81
+
82
+ Perform various tidying operations on a directory full of photos:
83
+
84
+ * Remove leading '$' and '_' from filenames
85
+ * Move files in hidden directories up 1 level
86
+ * If the EXIF data in a photo indicates that it was taken on date that doesn't match the name of the directory it is stored in (in YYYY-MM-DD format) then it is moved to the correct directory, creating it if necessary.
87
+
88
+ All move/rename operations are carried out safely with the file being moved having
89
+ a numeric suffix added to the name if it conflicts with an existing file.
90
+
91
+ ## photodupe
92
+
93
+ ## py-audit
94
+
95
+ Query api.osv.dev to determine whether a specified version of a particular Python package is subject to known security vulnerabilities
96
+
97
+ ## readable
98
+
99
+ Pipe for converting colour combinations to make them readable on a light background
100
+
101
+ ## remdir
102
+
103
+ Recursively delete empty directories
104
+
105
+ ## rmdupe
106
+
107
+ Search for duplicate files
108
+
109
+ ## rpylint
110
+
111
+ Run pylint on all the Python source files in the current tree
112
+
113
+ ## s3-sync
114
+
115
+ Synchronise files from S3 to local storage.
116
+
117
+ ## splitpics
118
+
119
+ Copy a directory full of pictures to a destination, creating subdiretories with a fixed number of pictures in each in the destination directory for use with FAT filesystems and digital photo frames.
120
+
121
+ ## strreplace
122
+
123
+ Simple search and replace utility for those times when trying to escape characters in a regexp to use sed is more hassle than it is worth.
124
+
125
+ ## sysmon
126
+
127
+ ## tfm
128
+
129
+ Console-based file-manager, similar to Midnight Commander but better.
130
+
131
+ ## tfparse
132
+
133
+ Read JSON Terraform output and convert back to human-readable text
134
+ This allows multiple errors and warnings to be reported as there's
135
+ no way of doing this directly from Terraform
136
+
137
+ ## trimpath
138
+
139
+ Intelligently trim a path to fit a given width (used by gitprompt)
140
+
141
+ ## window-rename
142
+
143
+ ## xchmod
144
+
145
+ WIP: Command to run chmod only on files that need it (only modifies files that don't have the required permissions already).
146
+
147
+ Currently implements a *very* restricted set of functionality.
148
+
149
+ ## yamlcheck
150
+
151
+ YAML validator - checks that a file is valid YAML (use yamllint to verify that it is nicely-formatted YAML).
152
+
153
+ # Git Utilities
154
+
155
+ ## ggit
156
+
157
+ Run a git command in all repos under the current directory
158
+
159
+ ## ggrep
160
+
161
+ Run 'git grep' in all repos under the current directory
162
+
163
+ ## gitprompt
164
+
165
+ Output a string containing colour-coded shell nesting level, current directory and git working tree status (used in the shell prompt).
166
+
167
+ ## git ca
168
+
169
+ Improved version of 'git commit --amend'. Updates files that are already in the commit and, optionally, adds and commits additional files.
170
+
171
+ ## git cleanup
172
+
173
+ List or delete branches that have already been merged and delete tracking branches that are no longer on ther remote.
174
+
175
+ ## git co
176
+
177
+ ## git mr
178
+
179
+ ## git parent
180
+
181
+ ## git update
182
+
183
+ Update the repo from the remote, rebase branches against their parents, optionally run git cleanup
184
+
185
+ ## git wt
186
+
187
+ Output the top level directory of the git working tree or return an error if we are not in a git working tree.
188
+
189
+ ## git review
190
+
191
+ ## venv-create
192
+
193
+ Create a script to create/update a virtual environment and run a python script in it.
@@ -23,9 +23,9 @@ skilleter_thingy/gitcmp_helper.py,sha256=NgQ0BZfa4TVA-XV6YKvrm5147boWUpGw-jDPUsk
23
23
  skilleter_thingy/gitprompt.py,sha256=SzSMd0EGI7ftPko80Q2PipwbVA-qjU1jsmdpmTCM5GI,8912
24
24
  skilleter_thingy/gl.py,sha256=9zbGpKxw6lX9RghLkdy-Q5sZlqtbB3uGFO04qTu1dH8,5954
25
25
  skilleter_thingy/linecount.py,sha256=ehTN6VD76i4U5k6dXuYoiqSRHI67_BP-bziklNAJSKY,4309
26
- skilleter_thingy/localphotosync.py,sha256=WF0TcCvLfl7cVOLzYYQK_t2WebLfQ-5FM6UB3r7Fpvw,5952
26
+ skilleter_thingy/localphotosync.py,sha256=mK3rRewRBh4Fa3SAkFDudl5QLqvjrrozJnIMHNrj4nw,6382
27
27
  skilleter_thingy/moviemover.py,sha256=QzUAWQzQ1AWWREIhl-VMaLo2h8MMhOekBnao5jGWV1s,4470
28
- skilleter_thingy/multigit.py,sha256=0OCg45ma70YWnsXGonevc2v5PQHEaW3eshKkI-eUiWQ,34512
28
+ skilleter_thingy/multigit.py,sha256=rnQ0YGkEy6H54PRt8nCt-G02LGy-wiKRJVk8ovR_pTw,35179
29
29
  skilleter_thingy/photodupe.py,sha256=2hw4EhDKH37_BgdXKkPm9GrftfIORmubQi38Yn0b4Mg,4084
30
30
  skilleter_thingy/phototidier.py,sha256=BOu-cKHMivDlBqlRqv7sL3J6Ix1K2dxWWNcderldyZo,7818
31
31
  skilleter_thingy/py_audit.py,sha256=4CAdqBAIIVcpTCn_7dGm56bdfGpUtUJofqTGZomClkY,4417
@@ -44,7 +44,7 @@ skilleter_thingy/window_rename.py,sha256=dCBgZqih_3YKHt35hsOAhARFp3QxOi8w8huC63s
44
44
  skilleter_thingy/xchmod.py,sha256=T89xiH_po0nvH5T1AGgQOD5yhjKd9-LcHcmez3IORww,4604
45
45
  skilleter_thingy/yamlcheck.py,sha256=FXylZ5NtHirDlPVhVEUZUZkTugVR-g51BbjaN06akAc,2868
46
46
  skilleter_thingy/thingy/__init__.py,sha256=rVPTxm8L5w52U0YdTd7r_D44SBP7pS3JCJtsf0iIsow,110
47
- skilleter_thingy/thingy/colour.py,sha256=1rDxU8NwCQQUUx5cOb-9ndp_XO39uQUlZJLrFO6lGPg,7567
47
+ skilleter_thingy/thingy/colour.py,sha256=mxHDpbUYad6xDsOKWco7CL0Nk3J5VKV_IZ3T5VjXwOI,7978
48
48
  skilleter_thingy/thingy/dc_curses.py,sha256=fuuQPR11zV_akAhygL_cAhVLC5YAgKgowzlITVbETE8,8539
49
49
  skilleter_thingy/thingy/dc_defaults.py,sha256=ahcteQvoWZrO5iTU68zkIY1Zex6iX5uR5ubwI4CCYBk,6170
50
50
  skilleter_thingy/thingy/dc_util.py,sha256=Df73imXhHx3HzcPHiRcHAoea0e3HURdLcrolUsMhOFs,1783
@@ -61,9 +61,10 @@ skilleter_thingy/thingy/run.py,sha256=6SNKWF01fSxzB10GMU9ajraXYZqAL1w0PXkqjJdr1U
61
61
  skilleter_thingy/thingy/tfm_pane.py,sha256=XTTpSm71CyQyGmlVLuCthioOwech0jhUiFUXb-chS_Q,19792
62
62
  skilleter_thingy/thingy/tidy.py,sha256=AQ2RawsZJg6WHrgayi_ZptFL9occ7suSdCHbU3P-cys,5971
63
63
  skilleter_thingy/thingy/venv_template.py,sha256=SsVNvSwojd8NnFeQaZPCRQYTNdwJRplpZpygbUEXRnY,1015
64
- skilleter_thingy-0.1.28.dist-info/licenses/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
65
- skilleter_thingy-0.1.28.dist-info/METADATA,sha256=RjIkDjog59L5uWr-RaSGqVhsDFdF1Bg2XA--iSmG068,30430
66
- skilleter_thingy-0.1.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
67
- skilleter_thingy-0.1.28.dist-info/entry_points.txt,sha256=mklrWFvNKw9Hyem9RG3x0PoVYjlx2fDnJ3xWMTMOmfs,2258
68
- skilleter_thingy-0.1.28.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
69
- skilleter_thingy-0.1.28.dist-info/RECORD,,
64
+ skilleter_thingy-0.1.30.dist-info/licenses/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
65
+ skilleter_thingy-0.1.30.dist-info/METADATA,sha256=hDRbrKxebem0Pnh5PTxhpeEYmRHcA9kMxLi5aXeKk3g,30430
66
+ skilleter_thingy-0.1.30.dist-info/PKG-INFO 2,sha256=BryF-1KGwXobPiiN60EmDKuqAtIBSPadlgmJ72xZhMk,5313
67
+ skilleter_thingy-0.1.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
68
+ skilleter_thingy-0.1.30.dist-info/entry_points.txt,sha256=mklrWFvNKw9Hyem9RG3x0PoVYjlx2fDnJ3xWMTMOmfs,2258
69
+ skilleter_thingy-0.1.30.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
70
+ skilleter_thingy-0.1.30.dist-info/RECORD,,