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.
- {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/METADATA +1 -1
- skilleter_thingy-0.0.39.dist-info/RECORD +6 -0
- skilleter_thingy-0.0.39.dist-info/top_level.txt +1 -0
- skilleter_thingy/__init__.py +0 -6
- skilleter_thingy/addpath.py +0 -107
- skilleter_thingy/borger.py +0 -269
- skilleter_thingy/console_colours.py +0 -63
- skilleter_thingy/diskspacecheck.py +0 -67
- skilleter_thingy/docker_purge.py +0 -113
- skilleter_thingy/ffind.py +0 -536
- skilleter_thingy/ggit.py +0 -90
- skilleter_thingy/ggrep.py +0 -154
- skilleter_thingy/git_br.py +0 -180
- skilleter_thingy/git_ca.py +0 -142
- skilleter_thingy/git_cleanup.py +0 -287
- skilleter_thingy/git_co.py +0 -220
- skilleter_thingy/git_common.py +0 -61
- skilleter_thingy/git_hold.py +0 -154
- skilleter_thingy/git_mr.py +0 -92
- skilleter_thingy/git_parent.py +0 -77
- skilleter_thingy/git_review.py +0 -1428
- skilleter_thingy/git_update.py +0 -385
- skilleter_thingy/git_wt.py +0 -96
- skilleter_thingy/gitcmp_helper.py +0 -322
- skilleter_thingy/gitprompt.py +0 -274
- skilleter_thingy/gl.py +0 -174
- skilleter_thingy/gphotosync.py +0 -610
- skilleter_thingy/linecount.py +0 -155
- skilleter_thingy/moviemover.py +0 -133
- skilleter_thingy/photodupe.py +0 -136
- skilleter_thingy/phototidier.py +0 -248
- skilleter_thingy/py_audit.py +0 -131
- skilleter_thingy/readable.py +0 -270
- skilleter_thingy/remdir.py +0 -126
- skilleter_thingy/rmdupe.py +0 -550
- skilleter_thingy/rpylint.py +0 -91
- skilleter_thingy/splitpics.py +0 -99
- skilleter_thingy/strreplace.py +0 -82
- skilleter_thingy/sysmon.py +0 -435
- skilleter_thingy/tfm.py +0 -920
- skilleter_thingy/tfparse.py +0 -101
- skilleter_thingy/thingy/__init__.py +0 -0
- skilleter_thingy/thingy/colour.py +0 -213
- skilleter_thingy/thingy/dc_curses.py +0 -278
- skilleter_thingy/thingy/dc_defaults.py +0 -221
- skilleter_thingy/thingy/dc_util.py +0 -50
- skilleter_thingy/thingy/dircolors.py +0 -308
- skilleter_thingy/thingy/docker.py +0 -95
- skilleter_thingy/thingy/files.py +0 -142
- skilleter_thingy/thingy/git.py +0 -1371
- skilleter_thingy/thingy/git2.py +0 -1307
- skilleter_thingy/thingy/gitlab.py +0 -193
- skilleter_thingy/thingy/logger.py +0 -112
- skilleter_thingy/thingy/path.py +0 -156
- skilleter_thingy/thingy/popup.py +0 -87
- skilleter_thingy/thingy/process.py +0 -112
- skilleter_thingy/thingy/run.py +0 -334
- skilleter_thingy/thingy/tfm_pane.py +0 -595
- skilleter_thingy/thingy/tidy.py +0 -160
- skilleter_thingy/trimpath.py +0 -84
- skilleter_thingy/window_rename.py +0 -92
- skilleter_thingy/xchmod.py +0 -125
- skilleter_thingy/yamlcheck.py +0 -89
- skilleter_thingy-0.0.37.dist-info/RECORD +0 -66
- skilleter_thingy-0.0.37.dist-info/top_level.txt +0 -1
- {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/LICENSE +0 -0
- {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/WHEEL +0 -0
- {skilleter_thingy-0.0.37.dist-info → skilleter_thingy-0.0.39.dist-info}/entry_points.txt +0 -0
skilleter_thingy/thingy/files.py
DELETED
|
@@ -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)))
|