skilleter-thingy 0.1.18__tar.gz → 0.1.19__tar.gz

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 (75) hide show
  1. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/PKG-INFO +1 -1
  2. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/pyproject.toml +1 -1
  3. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/ffind.py +2 -2
  4. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/ggit.py +1 -1
  5. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_br.py +2 -2
  6. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_common.py +2 -2
  7. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_hold.py +6 -6
  8. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_parent.py +2 -2
  9. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_review.py +14 -10
  10. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_wt.py +5 -5
  11. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/gitcmp_helper.py +6 -1
  12. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/gphotosync.py +3 -3
  13. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/localphotosync.py +2 -2
  14. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/multigit.py +29 -33
  15. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/colour.py +6 -2
  16. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/trimpath.py +5 -4
  17. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy.egg-info/PKG-INFO +1 -1
  18. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/LICENSE +0 -0
  19. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/README.md +0 -0
  20. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/setup.cfg +0 -0
  21. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/__init__.py +0 -0
  22. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/addpath.py +0 -0
  23. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/borger.py +0 -0
  24. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/console_colours.py +0 -0
  25. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/diskspacecheck.py +0 -0
  26. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/docker_purge.py +0 -0
  27. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/ggrep.py +0 -0
  28. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_ca.py +0 -0
  29. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_cleanup.py +0 -0
  30. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_co.py +0 -0
  31. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_mr.py +0 -0
  32. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_retag.py +0 -0
  33. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/git_update.py +0 -0
  34. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/gitprompt.py +0 -0
  35. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/gl.py +0 -0
  36. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/linecount.py +0 -0
  37. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/moviemover.py +0 -0
  38. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/photodupe.py +0 -0
  39. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/phototidier.py +0 -0
  40. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/py_audit.py +0 -0
  41. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/readable.py +0 -0
  42. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/remdir.py +0 -0
  43. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/rmdupe.py +0 -0
  44. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/rpylint.py +0 -0
  45. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/splitpics.py +0 -0
  46. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/strreplace.py +0 -0
  47. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/sysmon.py +0 -0
  48. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/tfm.py +0 -0
  49. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/tfparse.py +0 -0
  50. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/__init__.py +0 -0
  51. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/dc_curses.py +0 -0
  52. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/dc_defaults.py +0 -0
  53. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/dc_util.py +0 -0
  54. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/dircolors.py +0 -0
  55. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/docker.py +0 -0
  56. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/files.py +0 -0
  57. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/git.py +0 -0
  58. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/git2.py +0 -0
  59. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/gitlab.py +0 -0
  60. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/path.py +0 -0
  61. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/popup.py +0 -0
  62. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/process.py +0 -0
  63. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/run.py +0 -0
  64. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/tfm_pane.py +0 -0
  65. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/tidy.py +0 -0
  66. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/thingy/venv_template.py +0 -0
  67. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/venv_create.py +0 -0
  68. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/window_rename.py +0 -0
  69. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/xchmod.py +0 -0
  70. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy/yamlcheck.py +0 -0
  71. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy.egg-info/SOURCES.txt +0 -0
  72. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy.egg-info/dependency_links.txt +0 -0
  73. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy.egg-info/entry_points.txt +0 -0
  74. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy.egg-info/requires.txt +0 -0
  75. {skilleter_thingy-0.1.18 → skilleter_thingy-0.1.19}/skilleter_thingy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: skilleter_thingy
3
- Version: 0.1.18
3
+ Version: 0.1.19
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
@@ -7,7 +7,7 @@ name = "skilleter_thingy"
7
7
 
8
8
  # Version must be incremented to install updated Thingy
9
9
 
10
- version = "0.1.18"
10
+ version = "0.1.19"
11
11
 
12
12
  authors = [
13
13
  {name="John Skilleter", email="john@skilleter.org.uk"},
@@ -380,10 +380,10 @@ def validate_arguments(args):
380
380
 
381
381
  if args.git:
382
382
  if git.working_tree() is None:
383
- colour.error('[RED:ERROR]: The current directory is not inside a git working tree')
383
+ colour.error('The current directory is not inside a git working tree', prefix=True)
384
384
 
385
385
  if args.dir:
386
- colour.error('[RED:ERROR]: Git does not track directories, so you cannot search for them in a git working tree')
386
+ colour.error('Git does not track directories, so you cannot search for them in a git working tree', prefix=True)
387
387
 
388
388
  if args.verbose:
389
389
  print(f'Searching directory "{args.path}" for matches with "{args.patterns}"')
@@ -55,7 +55,7 @@ def main():
55
55
  try:
56
56
  os.chdir(args.path)
57
57
  except FileNotFoundError:
58
- colour.error(f'[RED:ERROR]: Invalid path [BLUE:{args.path}]')
58
+ colour.error(f'Invalid path [BLUE:{args.path}]', prefix=True)
59
59
 
60
60
  # If the current directory is in a working tree and below the top-level
61
61
  # directory then we run the git command here as well as in subdirectories
@@ -39,7 +39,7 @@ def parse_command_line():
39
39
  args = parser.parse_args()
40
40
 
41
41
  if args.delete and not args.branches:
42
- colour.error('[RED:ERROR]: You must specify the branches to delete')
42
+ colour.error('You must specify the branches to delete', prefix=True)
43
43
 
44
44
  return args
45
45
 
@@ -172,7 +172,7 @@ def git_br():
172
172
  except BrokenPipeError:
173
173
  sys.exit(2)
174
174
  except git.GitError as exc:
175
- colour.error(f'[RED:ERROR]: {exc.msg}', status=exc.status)
175
+ colour.error(exc.msg, status=exc.status, prefix=True)
176
176
 
177
177
  ################################################################################
178
178
 
@@ -27,12 +27,12 @@ def main():
27
27
  args = parser.parse_args()
28
28
 
29
29
  if args.long and args.short:
30
- colour.error('[RED:ERROR]: The [BLUE:--long] and [BLUE:--short] options cannot be used together')
30
+ colour.error('The [BLUE:--long] and [BLUE:--short] options cannot be used together', prefix=True)
31
31
 
32
32
  try:
33
33
  ancestor = git.find_common_ancestor(args.commit1, args.commit2)
34
34
  except git.GitError as exc:
35
- colour.error(f'[RED:ERROR]: {exc}', status=exc.status)
35
+ colour.error(exc, status=exc.status, prefix=True)
36
36
 
37
37
  if args.short:
38
38
  print(ancestor)
@@ -48,13 +48,13 @@ def archive_branches(branches):
48
48
 
49
49
  for branch in branches:
50
50
  if not git.isbranch(branch):
51
- colour.error(f'[RED:ERROR:] Branch {branch} does not exist')
51
+ colour.error(f'Branch {branch} does not exist', prefix=True)
52
52
 
53
53
  if archive_tag_name(branch) in tags:
54
- colour.error(f'[RED:ERROR:] An archive tag already exists for branch {branch}')
54
+ colour.error(f'An archive tag already exists for branch {branch}', prefix=True)
55
55
 
56
56
  if branch == current_branch:
57
- colour.error('[RED:ERROR:] Cannot archive the current branch')
57
+ colour.error('Cannot archive the current branch', prefix=True)
58
58
 
59
59
  for branch in branches:
60
60
  tag_name = archive_tag_name(branch)
@@ -96,7 +96,7 @@ def restore_archive_branches(branches):
96
96
 
97
97
  for branch in branches:
98
98
  if archive_tag_name(branch) not in tags:
99
- colour.error(f'[RED:ERROR:] Archive branch {branch} does not exist')
99
+ colour.error(f'Archive branch {branch} does not exist', prefix=True)
100
100
 
101
101
  archive_tag_names = []
102
102
 
@@ -123,10 +123,10 @@ def main():
123
123
  args = parser.parse_args()
124
124
 
125
125
  if args.list and args.restore:
126
- colour.error('[RED:ERROR:] The list and restore options cannot be specified together')
126
+ colour.error('The list and restore options cannot be specified together', prefix=True)
127
127
 
128
128
  if not args.branches and not args.list:
129
- colour.error('[RED:ERROR:] No branches specified')
129
+ colour.error('No branches specified', prefix=True)
130
130
 
131
131
  if args.list:
132
132
  list_archive_branches(args.branches)
@@ -48,7 +48,7 @@ def main():
48
48
  parents.append(more)
49
49
 
50
50
  except git.GitError as exc:
51
- colour.error(f'[RED:ERROR:] {exc.msg}', status=exc.status)
51
+ colour.error(exc.msg, status=exc.status, prefix=True)
52
52
 
53
53
  if parents:
54
54
  if args.verbose:
@@ -59,7 +59,7 @@ def main():
59
59
  else:
60
60
  print(', '.join(parents))
61
61
  else:
62
- colour.error('[RED:Could not determine parent branch]\n')
62
+ colour.error('Could not determine parent branch\n', prefix=True)
63
63
 
64
64
  ################################################################################
65
65
 
@@ -228,7 +228,11 @@ class GitReview():
228
228
 
229
229
  # Move to the top-level directory in the working tree
230
230
 
231
- self.current_dir = os.getcwd()
231
+ try:
232
+ self.current_dir = os.getcwd()
233
+ except FileNotFoundError:
234
+ raise GitReviewError('Unable to locate current directory')
235
+
232
236
  self.working_tree_dir = git.working_tree()
233
237
 
234
238
  if not self.working_tree_dir:
@@ -1309,13 +1313,13 @@ def parse_command_line():
1309
1313
  # Make sure that we're actually in a git working tree
1310
1314
 
1311
1315
  if not git.working_tree():
1312
- colour.error('[RED:ERROR] Not a git repository')
1316
+ colour.error('Not a git repository', prefix=True)
1313
1317
 
1314
1318
  # -C/--change is shorthand for '--commit HEAD^'
1315
1319
 
1316
1320
  if args.change:
1317
1321
  if args.commits:
1318
- colour.error('[RED:ERROR] The -C/--change option does not take parameters')
1322
+ colour.error('The -C/--change option does not take parameters', prefix=True)
1319
1323
 
1320
1324
  args.commits = ['HEAD^']
1321
1325
 
@@ -1345,7 +1349,7 @@ def parse_command_line():
1345
1349
  paths.append(entry)
1346
1350
  parsing_commits = False
1347
1351
  else:
1348
- colour.error(f'[RED:ERROR] Invalid path/commit: {entry}')
1352
+ colour.error(f'Invalid path/commit: {entry}', prefix=True)
1349
1353
 
1350
1354
  args.commits = commits
1351
1355
  args.paths = paths
@@ -1353,13 +1357,13 @@ def parse_command_line():
1353
1357
  # Validate the commits & paths
1354
1358
 
1355
1359
  if len(args.commits) > 2:
1356
- colour.error('[RED:ERROR]: No more than 2 commits can be specified')
1360
+ colour.error('No more than 2 commits can be specified', prefix=True)
1357
1361
 
1358
1362
  if (args.branch or args.commit) and args.commits:
1359
- colour.error('[RED:ERROR]: Additional commits should not be specified in conjunction with the -b/--branch option')
1363
+ colour.error('Additional commits should not be specified in conjunction with the -b/--branch option', prefix=True)
1360
1364
 
1361
1365
  if args.commit and args.branch:
1362
- colour.error('[RED:ERROR]: The -c/--commit and -b/--branch options are mutually exclusive')
1366
+ colour.error('The -c/--commit and -b/--branch options are mutually exclusive', prefix=True)
1363
1367
 
1364
1368
  # If the -c/--commit option is used, then review against its parent
1365
1369
  # If the -b/--branch option is used, then review against the oldest common ancestor
@@ -1369,7 +1373,7 @@ def parse_command_line():
1369
1373
  try:
1370
1374
  args.commits = [git.find_common_ancestor('HEAD', args.branch)]
1371
1375
  except git.GitError as exc:
1372
- colour.error(f'[ERROR]: {exc}', status=exc.status)
1376
+ colour.error(exc, status=exc.status, prefix=True)
1373
1377
 
1374
1378
  elif args.commit:
1375
1379
  args.commits = ['%s^' % args.commit, args.commit]
@@ -1387,9 +1391,9 @@ def parse_command_line():
1387
1391
  if len(matches) == 1:
1388
1392
  args.commits[i] = matches[0]
1389
1393
  else:
1390
- colour.error(f'[RED:ERROR]: Multiple commits match {entry}')
1394
+ colour.error(f'Multiple commits match {entry}', prefix=True)
1391
1395
  else:
1392
- colour.error(f'[RED:ERROR] {entry} is not a valid commit ID')
1396
+ colour.error(f'{entry} is not a valid commit ID', prefix=True)
1393
1397
 
1394
1398
  # Things work easier if we always have two commits to compare
1395
1399
 
@@ -26,15 +26,15 @@ def main():
26
26
  parser = argparse.ArgumentParser(description='Report top-level directory of the current git working tree.')
27
27
  parser.add_argument('--parent', '-p', action='store_true',
28
28
  help='If we are already at the top of the working tree, check if the parent directory is in a working tree and output the top-level directory of that tree.')
29
- parser.add_argument('--dir', '-d', action='store', default=os.getcwd(),
29
+ parser.add_argument('--dir', '-d', action='store', default=None,
30
30
  help='Find the location of the top-level directory in the working tree starting at the specified directory')
31
31
 
32
32
  args = parser.parse_args()
33
33
 
34
- start_dir = os.path.abspath(args.dir)
35
-
36
- if not os.path.isdir(start_dir):
37
- sys.stderr.write(f'Unable to locate directory {args.dir}\n')
34
+ try:
35
+ start_dir = os.path.abspath(args.dir or os.getcwd())
36
+ except FileNotFoundError:
37
+ sys.stderr.write('Unable to determine initial directory\n')
38
38
  sys.exit(1)
39
39
 
40
40
  # Search for a .git directory in the current or parent directories
@@ -169,7 +169,12 @@ def main():
169
169
 
170
170
  # Determine the best way of reporting the path to the file
171
171
 
172
- working_tree_path = os.getcwd()
172
+ try:
173
+ working_tree_path = os.getcwd()
174
+ except FileNotFoundError:
175
+ sys.stderr.write('Unable to get current working directory')
176
+ sys.exit(2)
177
+
173
178
  current_path = os.path.join(working_tree_path, os.getenv('GIT_SUBDIR', ''))
174
179
 
175
180
  current_file_path = os.path.relpath(args.file_path if args.new_name is None else args.new_name, current_path)
@@ -94,7 +94,7 @@ def parse_yyyymm(datestr):
94
94
  date_match = YYYY_MM_re.fullmatch(datestr)
95
95
 
96
96
  if not date_match:
97
- colour.error(f'ERROR: Invalid date: {datestr}')
97
+ colour.error(f'Invalid date: {datestr}', prefix=True)
98
98
 
99
99
  return datetime.date(int(date_match.group(1)), int(date_match.group(2)), day=1)
100
100
 
@@ -387,9 +387,9 @@ def update_cache(args, year, month):
387
387
 
388
388
  subprocess.run(cmd, check=True)
389
389
  except subprocess.CalledProcessError:
390
- colour.error(f'[RED:ERROR]: Failed to sync Google photos for month [BLUE:{month}] of year [BLUE:{year}]')
390
+ colour.error(f'Failed to sync Google photos for month [BLUE:{month}] of year [BLUE:{year}]', prefix=True)
391
391
  except FileNotFoundError as exc:
392
- colour.error('f[RED:ERROR]: {exc}')
392
+ colour.error(exc, prefix=True)
393
393
 
394
394
  ################################################################################
395
395
 
@@ -73,7 +73,7 @@ def parse_yyyymm(datestr):
73
73
  date_match = YYYY_MM_re.fullmatch(datestr)
74
74
 
75
75
  if not date_match:
76
- colour.error(f'ERROR: Invalid date: {datestr}')
76
+ colour.error(f'Invalid date: {datestr}', prefix=True)
77
77
 
78
78
  return datetime.date(int(date_match.group(1)), int(date_match.group(2)), day=1)
79
79
 
@@ -97,7 +97,7 @@ def parse_command_line():
97
97
  args = parser.parse_args()
98
98
 
99
99
  if not args.path:
100
- colour.error('You must specify a source directory')
100
+ colour.error('You must specify a source directory', prefix=True)
101
101
 
102
102
  # Configure debugging
103
103
 
@@ -133,14 +133,6 @@ class Arguments():
133
133
 
134
134
  ################################################################################
135
135
 
136
- def error(msg, status=1):
137
- """Quit with an error"""
138
-
139
- colour.write(f'[RED:ERROR:] {msg}\n', stream=sys.stderr)
140
- sys.exit(status)
141
-
142
- ################################################################################
143
-
144
136
  def verbose(args, msg):
145
137
  """Output a message to stderr if running verbosely"""
146
138
 
@@ -174,7 +166,11 @@ def find_configuration(default_config_file):
174
166
  if '/' in default_config_file:
175
167
  config_file = default_config_file
176
168
  else:
177
- config_path = os.getcwd()
169
+ try:
170
+ config_path = os.getcwd()
171
+ except FileNotFoundError:
172
+ colour.error('Unable to determine current directory', prefix=True)
173
+
178
174
  config_file = os.path.join(config_path, default_config_file)
179
175
 
180
176
  while not os.path.isfile(config_file) and config_path != '/':
@@ -314,10 +310,10 @@ def mg_clone(args, config, console):
314
310
  # Sanity checks
315
311
 
316
312
  if not args.parameters:
317
- error('The "clone" subcommand takes 1 or 2 parameters - the repo to clone and, optionally, the branch to check out')
313
+ colour.error('The "clone" subcommand takes 1 or 2 parameters - the repo to clone and, optionally, the branch to check out', prefix=True)
318
314
 
319
315
  if args.branched or args.modified:
320
- error('The "modified" and "branched" options cannot be used with the "clone" subcommand')
316
+ colour.error('The "modified" and "branched" options cannot be used with the "clone" subcommand', prefix=True)
321
317
 
322
318
  # Destination directory is the last portion of the repo URL with the extension removed
323
319
 
@@ -325,9 +321,9 @@ def mg_clone(args, config, console):
325
321
 
326
322
  if os.path.exists(directory):
327
323
  if os.path.isdir(directory):
328
- error(f'The "[BLUE:{directory}]" directory already exists')
324
+ colour.error(f'The "[BLUE:{directory}]" directory already exists', prefix=True)
329
325
  else:
330
- error(f'[BLUE:{directory}]" already exists')
326
+ colour.error(f'[BLUE:{directory}]" already exists', prefix=True)
331
327
 
332
328
  # Clone the repo and chdir into it
333
329
 
@@ -349,7 +345,7 @@ def mg_clone(args, config, console):
349
345
  args.configuration_file = args.default_configuration_file
350
346
 
351
347
  if not os.path.isfile(args.configuration_file):
352
- error(f'Cannot find the configuration file: [BOLD:{args.default_configuration_file}]')
348
+ colour.error(f'Cannot find the configuration file: [BOLD:{args.default_configuration_file}]', prefix=True)
353
349
 
354
350
  config.read(args.configuration_file)
355
351
 
@@ -383,7 +379,7 @@ def mg_init(args, config, console):
383
379
  # Sanity checks
384
380
 
385
381
  if args.modified or args.branched or args.tag or args.subdirectories:
386
- error('The "--tag", "--modified" "--sub", and "--branched" options cannot be used with the "init" subcommand')
382
+ colour.error('The "--tag", "--modified" "--sub", and "--branched" options cannot be used with the "init" subcommand', prefix=True)
387
383
 
388
384
  # Search for .git directories and add any that aren't already in the configuration
389
385
 
@@ -405,7 +401,7 @@ def mg_init(args, config, console):
405
401
  default_branch = git.branch(path=abs_repo_path)
406
402
 
407
403
  if not default_branch:
408
- error(f'Unable to determine default branch in [BLUE:{repo}]')
404
+ colour.error(f'Unable to determine default branch in [BLUE:{repo}]', prefix=True)
409
405
 
410
406
  config[repo]['default branch'] = default_branch
411
407
 
@@ -451,12 +447,12 @@ def mg_dir(args, config, console):
451
447
  verbose(args, f'dir: Parameters: {", ".join(args.parameters)}')
452
448
 
453
449
  if len(args.parameters) > 1:
454
- error('The +dir command takes no more than one parameter - the name of the working tree to search for')
450
+ colour.error('The +dir command takes no more than one parameter - the name of the working tree to search for', prefix=True)
455
451
 
456
452
  # TODO: mg_dir _should_ use these options
457
453
 
458
454
  if args.modified or args.branched or args.tag or args.subdirectories:
459
- error('The "--tag", "--modified" "--sub", and "--branched" options cannot be used with the "dir" subcommand')
455
+ colour.error('The "--tag", "--modified" "--sub", and "--branched" options cannot be used with the "dir" subcommand', prefix=True)
460
456
 
461
457
  # If a parameter is specified, look for matches, otherwise just return the location of the
462
458
  # configuration file
@@ -490,7 +486,7 @@ def mg_dir(args, config, console):
490
486
  destination = destinations
491
487
 
492
488
  if not destination:
493
- error(f'No matches with [BLUE:{search_name}]')
489
+ colour.error(f'No matches with [BLUE:{search_name}]', prefix=True)
494
490
 
495
491
  colour.write("\n".join([relative_repo_path(args, d) for d in destination]))
496
492
 
@@ -505,7 +501,7 @@ def mg_tag(args, config, console):
505
501
  _ = console
506
502
 
507
503
  if len(args.parameters) > 1:
508
- error('The +tag command takes no more than one parameter')
504
+ colour.error('The +tag command takes no more than one parameter', prefix=True)
509
505
 
510
506
  for repo in select_git_repos(args, config):
511
507
  try:
@@ -529,7 +525,7 @@ def mg_untag(args, config, console):
529
525
  _ = console
530
526
 
531
527
  if len(args.parameters) > 1:
532
- error('The +tag command takes no more than one parameter')
528
+ colour.error('The +tag command takes no more than one parameter', prefix=True)
533
529
 
534
530
  for repo in select_git_repos(args, config):
535
531
  try:
@@ -551,7 +547,7 @@ def mg_config(args, config, console):
551
547
  _ = console
552
548
 
553
549
  if len(args.parameters):
554
- error('The +config command does not take parameters')
550
+ colour.error('The +config command does not take parameters', prefix=True)
555
551
 
556
552
  colour.write(os.path.relpath(args.configuration_file))
557
553
 
@@ -614,28 +610,28 @@ def parse_command_line():
614
610
 
615
611
  elif param in ('config', 'c'):
616
612
  if params:
617
- error('--config - missing configuration file parameter')
613
+ colour.error('--config - missing configuration file parameter', prefix=True)
618
614
  else:
619
615
  try:
620
616
  args.default_configuration_file = arg_list.pop(0)
621
617
  except IndexError:
622
- error('--config - missing configuration file parameter')
618
+ colour.error('--config - missing configuration file parameter', prefix=True)
623
619
 
624
620
  elif param in ('repos', 'r'):
625
621
  if params:
626
- error('--repos - missing repo parameter')
622
+ colour.error('--repos - missing repo parameter', prefix=True)
627
623
  try:
628
624
  args.repos.append(arg_list.pop(0))
629
625
  except IndexError:
630
- error('--repos - missing repo parameter')
626
+ colour.error('--repos - missing repo parameter', prefix=True)
631
627
 
632
628
  elif param in ('tag', 't'):
633
629
  if params:
634
- error('--tag - missing tag parameter')
630
+ colour.error('--tag - missing tag parameter', prefix=True)
635
631
  try:
636
632
  args.tag.append(arg_list.pop(0))
637
633
  except IndexError:
638
- error('--tag - missing tag parameter')
634
+ colour.error('--tag - missing tag parameter', prefix=True)
639
635
 
640
636
  elif param in ('modified', 'm'):
641
637
  args.modified = True
@@ -654,7 +650,7 @@ def parse_command_line():
654
650
  sys.exit(0)
655
651
 
656
652
  else:
657
- error(f'Invalid option: "{param}"')
653
+ colour.error(f'Invalid option: "{param}"', prefix=True)
658
654
 
659
655
  # After the options, we either have a multigit command (prefixed with '+') or a git command
660
656
  # followed by parameter
@@ -670,7 +666,7 @@ def parse_command_line():
670
666
  args.internal_command = False
671
667
 
672
668
  except IndexError:
673
- error('Missing command')
669
+ colour.error('Missing command', prefix=True)
674
670
 
675
671
  # Save the command parameters
676
672
 
@@ -702,7 +698,7 @@ def main():
702
698
  args = parse_command_line()
703
699
 
704
700
  if args.internal_command and args.command not in COMMANDS:
705
- error(f'Invalid command "{args.command}"')
701
+ colour.error(f'Invalid command "{args.command}"', prefix=True)
706
702
 
707
703
  # If the configuration file exists, read it
708
704
 
@@ -717,7 +713,7 @@ def main():
717
713
  if args.command == 'init':
718
714
  args.configuration_file = os.path.abspath(args.default_configuration_file)
719
715
  else:
720
- error('Cannot locate configuration file')
716
+ colour.error('Cannot locate configuration file', prefix=True)
721
717
 
722
718
  if args.configuration_file and os.path.isfile(args.configuration_file):
723
719
  config.read(args.configuration_file)
@@ -736,7 +732,7 @@ def main():
736
732
  # Everything except '+init' and '+clone' requires the configuration file
737
733
 
738
734
  if args.command not in ('init', 'clone') and args.configuration_file is None:
739
- error('Configuration file not found')
735
+ colour.error('Configuration file not found', prefix=True)
740
736
 
741
737
  COMMANDS[args.command](args, config, console)
742
738
 
@@ -184,9 +184,13 @@ def write(txt=None, newline=True, stream=sys.stdout, indent=0, strip=False, clea
184
184
 
185
185
  ################################################################################
186
186
 
187
- def error(txt, newline=True, stream=sys.stderr, status=1):
187
+ def error(txt, newline=True, stream=sys.stderr, status=1, prefix=False):
188
188
  """ Write an error message to the specified stream (defaulting to
189
- stderr) and exit with the specified status code (defaulting to 1) """
189
+ stderr) and exit with the specified status code (defaulting to 1)
190
+ Prefix the output with 'ERROR:' in red if prefix==True """
191
+
192
+ if prefix:
193
+ write('[RED:ERROR]: ', newline=False, stream=stream, )
190
194
 
191
195
  write(txt, newline, stream)
192
196
 
@@ -52,10 +52,11 @@ def main():
52
52
 
53
53
  # Set the path, defaulting to the current directory
54
54
 
55
- if args.path:
56
- full_path = args.path
57
- else:
58
- full_path = os.getcwd()
55
+ try:
56
+ full_path = args.path or os.getcwd()
57
+ except FileNotFoundError:
58
+ logging.critical('Unable to locate directory')
59
+ sys.exit(1)
59
60
 
60
61
  trimmed = path.trimpath(full_path, trim_width)
61
62
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: skilleter_thingy
3
- Version: 0.1.18
3
+ Version: 0.1.19
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