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

Files changed (68) hide show
  1. {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/METADATA +1 -1
  2. skilleter_thingy-0.0.39.dist-info/RECORD +6 -0
  3. skilleter_thingy-0.0.39.dist-info/top_level.txt +1 -0
  4. skilleter_thingy/__init__.py +0 -6
  5. skilleter_thingy/addpath.py +0 -107
  6. skilleter_thingy/borger.py +0 -269
  7. skilleter_thingy/console_colours.py +0 -63
  8. skilleter_thingy/diskspacecheck.py +0 -67
  9. skilleter_thingy/docker_purge.py +0 -113
  10. skilleter_thingy/ffind.py +0 -536
  11. skilleter_thingy/ggit.py +0 -90
  12. skilleter_thingy/ggrep.py +0 -154
  13. skilleter_thingy/git_br.py +0 -180
  14. skilleter_thingy/git_ca.py +0 -142
  15. skilleter_thingy/git_cleanup.py +0 -287
  16. skilleter_thingy/git_co.py +0 -220
  17. skilleter_thingy/git_common.py +0 -61
  18. skilleter_thingy/git_hold.py +0 -154
  19. skilleter_thingy/git_mr.py +0 -92
  20. skilleter_thingy/git_parent.py +0 -77
  21. skilleter_thingy/git_review.py +0 -1428
  22. skilleter_thingy/git_update.py +0 -385
  23. skilleter_thingy/git_wt.py +0 -96
  24. skilleter_thingy/gitcmp_helper.py +0 -322
  25. skilleter_thingy/gitprompt.py +0 -274
  26. skilleter_thingy/gl.py +0 -174
  27. skilleter_thingy/gphotosync.py +0 -610
  28. skilleter_thingy/linecount.py +0 -155
  29. skilleter_thingy/moviemover.py +0 -133
  30. skilleter_thingy/photodupe.py +0 -136
  31. skilleter_thingy/phototidier.py +0 -248
  32. skilleter_thingy/py_audit.py +0 -131
  33. skilleter_thingy/readable.py +0 -270
  34. skilleter_thingy/remdir.py +0 -126
  35. skilleter_thingy/rmdupe.py +0 -550
  36. skilleter_thingy/rpylint.py +0 -91
  37. skilleter_thingy/splitpics.py +0 -99
  38. skilleter_thingy/strreplace.py +0 -82
  39. skilleter_thingy/sysmon.py +0 -435
  40. skilleter_thingy/tfm.py +0 -920
  41. skilleter_thingy/tfparse.py +0 -101
  42. skilleter_thingy/thingy/__init__.py +0 -0
  43. skilleter_thingy/thingy/colour.py +0 -213
  44. skilleter_thingy/thingy/dc_curses.py +0 -278
  45. skilleter_thingy/thingy/dc_defaults.py +0 -221
  46. skilleter_thingy/thingy/dc_util.py +0 -50
  47. skilleter_thingy/thingy/dircolors.py +0 -308
  48. skilleter_thingy/thingy/docker.py +0 -95
  49. skilleter_thingy/thingy/files.py +0 -142
  50. skilleter_thingy/thingy/git.py +0 -1371
  51. skilleter_thingy/thingy/git2.py +0 -1307
  52. skilleter_thingy/thingy/gitlab.py +0 -193
  53. skilleter_thingy/thingy/logger.py +0 -112
  54. skilleter_thingy/thingy/path.py +0 -156
  55. skilleter_thingy/thingy/popup.py +0 -87
  56. skilleter_thingy/thingy/process.py +0 -112
  57. skilleter_thingy/thingy/run.py +0 -334
  58. skilleter_thingy/thingy/tfm_pane.py +0 -595
  59. skilleter_thingy/thingy/tidy.py +0 -160
  60. skilleter_thingy/trimpath.py +0 -84
  61. skilleter_thingy/window_rename.py +0 -92
  62. skilleter_thingy/xchmod.py +0 -125
  63. skilleter_thingy/yamlcheck.py +0 -89
  64. skilleter_thingy-0.0.37.dist-info/RECORD +0 -66
  65. skilleter_thingy-0.0.37.dist-info/top_level.txt +0 -1
  66. {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/LICENSE +0 -0
  67. {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/WHEEL +0 -0
  68. {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/entry_points.txt +0 -0
@@ -1,142 +0,0 @@
1
- #! /usr/bin/env python3
2
-
3
- ################################################################################
4
- """ Thingy file handling functions
5
-
6
- Copyright (C) 2017-18 John Skilleter
7
-
8
- High-level file access functions not provided by the Python libraries
9
- """
10
- ################################################################################
11
-
12
- import os
13
- import shutil
14
-
15
- # TODO: Convert to use thingy.proc
16
- import thingy.process as process
17
-
18
- ################################################################################
19
-
20
- def is_binary_file(filename):
21
- """ Return True if there is a strong likelihood that the specified file
22
- is binary. """
23
-
24
- return file_type(filename, mime=True).endswith('binary')
25
-
26
- ################################################################################
27
-
28
- def file_type(filename, mime=False):
29
- """ Return a textual description of the file type """
30
-
31
- # The file utility does not return an error if the file does not exist or
32
- # is not a file, so we have to do that.
33
-
34
- if not os.path.isfile(filename) or not os.access(filename, os.R_OK):
35
- raise IOError('Unable to access %s' % filename)
36
-
37
- cmd = ['file', '--brief']
38
-
39
- if mime:
40
- cmd.append('--mime')
41
-
42
- cmd.append(filename)
43
-
44
- return process.run(cmd)[0]
45
-
46
- ################################################################################
47
-
48
- def format_size(size, always_suffix=False):
49
- """ Convert a memory/disk size into appropriately-scaled units in bytes,
50
- MiB, GiB, TiB as a string """
51
-
52
- # Keep all the maths positive
53
-
54
- if size < 0:
55
- size = -size
56
- sign = '-'
57
- else:
58
- sign = ''
59
-
60
- # Default divisor and number of decimal places output
61
-
62
- div = 1
63
-
64
- # Step through the multipliers
65
-
66
- for units in (' bytes' if always_suffix else '', ' KiB', ' MiB', ' GiB', ' TiB'):
67
- # If we can't scale up to this multiplier quit the loop
68
-
69
- if size // div < 1024:
70
- break
71
-
72
- # Increase the divisor and set the number of decimal places
73
- # to 1 (set to 0 when we don't have a divisor).
74
-
75
- div *= 1024
76
-
77
- # Calculate the size in 10ths so the we get the first digit after
78
- # the decimal point, doing all the work in the integer domain to
79
- # avoid rounding errors.
80
-
81
- size_x_10 = (size * 10) // div
82
-
83
- # If the decimal part would be '.0' don't output it
84
-
85
- if size_x_10 % 10 == 0:
86
- return '%s%d%s' % (sign, size_x_10 // 10, units)
87
-
88
- return '%s%d.%d%s' % (sign, size_x_10 // 10, size_x_10 % 10, units)
89
-
90
- ################################################################################
91
-
92
- def backup(filename, extension='bak', copyfile=True):
93
- """ Create a backup of a file by copying or renaming it into a file with extension
94
- .bak, deleting any existing file with that name """
95
-
96
- # Do nothing if the file does not exist
97
-
98
- if not os.path.isfile(filename):
99
- return
100
-
101
- # Split on the dot characters
102
-
103
- filename_comp = filename.split('.')
104
-
105
- # Replace the extension with the specified on (or 'bak' by
106
- # default) or add it if the filename did not have an extension.
107
-
108
- if len(filename_comp) > 1:
109
- filename_comp[-1] = extension
110
- else:
111
- filename_comp.append(extension)
112
-
113
- backupname = '.'.join(filename_comp)
114
-
115
- # Remove any existing backup file
116
-
117
- if os.path.isfile(backupname):
118
- os.unlink(backupname)
119
-
120
- # Create the backup by copying or renaming the file
121
-
122
- if copyfile:
123
- shutil.copyfile(filename, backupname)
124
- else:
125
- os.rename(filename, backupname)
126
-
127
- ################################################################################
128
- # Test code
129
-
130
- if __name__ == "__main__":
131
- print('Is /bin/sh binary: %s' % is_binary_file('/bin/sh'))
132
- print('Is files.py binary: %s' % is_binary_file('thingy/files.py'))
133
- print('')
134
-
135
- for mimeflag in (False, True):
136
- print('/bin/sh is: %s' % file_type('/bin/sh', mimeflag))
137
- print('/bin/dash is: %s' % file_type('/bin/dash', mimeflag))
138
- print('git-ca is: %s' % file_type('git-ca', mimeflag))
139
- print('')
140
-
141
- for sizevalue in (0, 1, 999, 1024, 1025, 1.3 * 1024, 2**32 - 1, 2**64 + 2**49):
142
- print('%24d is %s' % (sizevalue, format_size(sizevalue)))