| Hash | Commit message | Author | Date | Files | + | - |
1 | commit d81d38e87fb959f5e3cca64fec4d06e56b0ab565 |
2 | Author: Connor Etherington <[email protected]> |
3 | Date: Sat Jul 29 06:29:45 2023 +0200 |
4 | |
5 | Auto-Commit Update 29.07.2023 - 06:29:45 |
6 | --- |
7 | .gitignore | 1 + |
8 | LICENSE | 24 ++++++++++ |
9 | PKGBUILD | 23 ++++++++++ |
10 | README.md | 11 +++++ |
11 | ptrack.egg-info/PKG-INFO | 1 + |
12 | ptrack.egg-info/SOURCES.txt | 3 ++ |
13 | ptrack/__pycache__/__init__.cpython-310.pyc | Bin 731 -> 0 bytes |
14 | ptrack/__pycache__/main.cpython-310.pyc | Bin 5541 -> 0 bytes |
15 | ptrack/main.py | 69 ++-------------------------- |
16 | ptrack/methods.py | 67 +++++++++++++++++++++++++++ |
17 | 10 files changed, 133 insertions(+), 66 deletions(-) |
18 | |
19 | diff --git a/.gitignore b/.gitignore |
20 | new file mode 100644 |
21 | index 0000000..d7f7a42 |
22 | --- /dev/null |
23 | +++ b/.gitignore |
24 | @@ -0,0 +1 @@ |
25 | +.mypy_cache |
26 | diff --git a/LICENSE b/LICENSE |
27 | new file mode 100644 |
28 | index 0000000..b147493 |
29 | --- /dev/null |
30 | +++ b/LICENSE |
31 | @@ -0,0 +1,24 @@ |
32 | +MIT/X Consortium License |
33 | + |
34 | +Creator /Maintainer : |
35 | +© Connor Etherington <[email protected]> |
36 | +--------------------------------------------------------------------------- |
37 | + |
38 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
39 | +of this software and associated documentation files (the "Software"), to deal |
40 | +in the Software without restriction, including without limitation the rights |
41 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
42 | +copies of the Software, and to permit persons to whom the Software is |
43 | +furnished to do so, subject to the following conditions: |
44 | + |
45 | +THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN ALL |
46 | +COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. |
47 | + |
48 | + |
49 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
50 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
51 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
52 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
53 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
54 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
55 | +SOFTWARE. |
56 | diff --git a/PKGBUILD b/PKGBUILD |
57 | new file mode 100644 |
58 | index 0000000..71a99c2 |
59 | --- /dev/null |
60 | +++ b/PKGBUILD |
61 | @@ -0,0 +1,23 @@ |
62 | +# Maintainer: Connor Etherington <[email protected]> |
63 | +# --- |
64 | +pkgname=ptrack |
65 | +pkgver=0.1.0 |
66 | +pkgrel=1 |
67 | +pkgdesc="A simple CLI utility for asthetically tracking progress when copying or moving files" |
68 | +arch=(any) |
69 | +url="https://gitlab.com/a4to/${pkgname}" |
70 | +license=('MIT') |
71 | +depends=('python3 python-argparse python-rich python-argcomplete python-setuptools') |
72 | +source=("git+$url.git") |
73 | +sha256sums=('SKIP') |
74 | + |
75 | +package() { |
76 | + |
77 | + cd "$srcdir/${pkgname}-${pkgver}-${pkgrel}-${arch}" || |
78 | + cd "$srcdir/${pkgname}" |
79 | + |
80 | + python3 ./setup.py install --root="$pkgdir" --optimize=1 |
81 | + install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" |
82 | + install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md" |
83 | + |
84 | +} |
85 | diff --git a/README.md b/README.md |
86 | new file mode 100644 |
87 | index 0000000..650dcf4 |
88 | --- /dev/null |
89 | +++ b/README.md |
90 | @@ -0,0 +1,11 @@ |
91 | + |
92 | +usage: ptrack [-h] [-v] [-c] [-m] |
93 | + |
94 | +A simple CLI utility for asthetically tracking progress when copying or moving files. |
95 | + |
96 | +options: |
97 | + -h, --help show this help message and exit |
98 | + -v, --verbose verbose output |
99 | + -c, --copy copy files (You can use `ptc` instead of `ptrack -c`) |
100 | + -m, --move move files (You can use `ptm` instead of `ptrack -m`) |
101 | + |
102 | diff --git a/ptrack.egg-info/PKG-INFO b/ptrack.egg-info/PKG-INFO |
103 | index 7da1525..e347788 100644 |
104 | --- a/ptrack.egg-info/PKG-INFO |
105 | +++ b/ptrack.egg-info/PKG-INFO |
106 | @@ -4,3 +4,4 @@ Version: 0.1.0 |
107 | Summary: A simple CLI utility for asthetically tracking progress when copying or moving files. |
108 | Author: Connor Etherington |
109 | Author-email: [email protected] |
110 | +License-File: LICENSE |
111 | diff --git a/ptrack.egg-info/SOURCES.txt b/ptrack.egg-info/SOURCES.txt |
112 | index f85fb63..086a784 100644 |
113 | --- a/ptrack.egg-info/SOURCES.txt |
114 | +++ b/ptrack.egg-info/SOURCES.txt |
115 | @@ -1,6 +1,9 @@ |
116 | +LICENSE |
117 | +README.md |
118 | setup.py |
119 | ptrack/__init__.py |
120 | ptrack/main.py |
121 | +ptrack/methods.py |
122 | ptrack.egg-info/PKG-INFO |
123 | ptrack.egg-info/SOURCES.txt |
124 | ptrack.egg-info/dependency_links.txt |
125 | diff --git a/ptrack/__pycache__/__init__.cpython-310.pyc b/ptrack/__pycache__/__init__.cpython-310.pyc |
126 | deleted file mode 100644 |
127 | index d544d60..0000000 |
128 | Binary files a/ptrack/__pycache__/__init__.cpython-310.pyc and /dev/null differ |
129 | diff --git a/ptrack/__pycache__/main.cpython-310.pyc b/ptrack/__pycache__/main.cpython-310.pyc |
130 | deleted file mode 100644 |
131 | index c3479bd..0000000 |
132 | Binary files a/ptrack/__pycache__/main.cpython-310.pyc and /dev/null differ |
133 | diff --git a/ptrack/main.py b/ptrack/main.py |
134 | old mode 100755 |
135 | new mode 100644 |
136 | index bddf173..e52edf0 |
137 | --- a/ptrack/main.py |
138 | +++ b/ptrack/main.py |
139 | @@ -1,66 +1,16 @@ |
140 | import os |
141 | import sys |
142 | +import ptrack |
143 | +from ptrack.methods import format_file_size, regular_copy, verbose_copy, hlp |
144 | from rich.progress import Progress, BarColumn, TextColumn, TimeRemainingColumn, FileSizeColumn |
145 | from rich.console import Console |
146 | import shutil |
147 | -import ptrack |
148 | |
149 | verbose = ptrack.verbose |
150 | argCopy = ptrack.copy |
151 | argMove = ptrack.move |
152 | |
153 | |
154 | -def format_file_size(file_size): |
155 | - if file_size >= 1024 * 1024 * 1024: |
156 | - return f"{file_size / (1024*1024*1024):.2f} GB" |
157 | - elif file_size >= 1024 * 1024: |
158 | - return f"{file_size / (1024*1024):.2f} MB" |
159 | - elif file_size >= 1024: |
160 | - return f"{file_size / 1024:.2f} kB" |
161 | - else: |
162 | - return f"{file_size} bytes" |
163 | - |
164 | - |
165 | -def regular_copy(src, dst, console, task, progress): |
166 | - with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: |
167 | - while True: |
168 | - buf = fsrc.read(1024*1024) |
169 | - if not buf: |
170 | - break |
171 | - fdst.write(buf) |
172 | - progress.update(task, advance=len(buf)) |
173 | - progress.refresh() |
174 | - |
175 | - |
176 | -def verbose_copy(src, dst, console, current, total_files): |
177 | - |
178 | - file_size = os.path.getsize(src) |
179 | - |
180 | - with Progress( |
181 | - BarColumn(bar_width=50), |
182 | - "[progress.percentage]{task.percentage:>3.0f}%", |
183 | - TimeRemainingColumn(), |
184 | - "[#ea2a6f][[/#ea2a6f]", |
185 | - FileSizeColumn(), |
186 | - "[#ea2a6f]/[/#ea2a6f]", |
187 | - TextColumn(f"[bold cyan]{format_file_size(file_size)}[/bold cyan]"), |
188 | - "[#ea2a6f]][/#ea2a6f]", |
189 | - f"({current} of {total_files})", |
190 | - console=console, |
191 | - auto_refresh=False |
192 | - ) as progress: |
193 | - task = progress.add_task("", total=file_size, file_size=format_file_size(file_size)) |
194 | - |
195 | - with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: |
196 | - while not progress.finished: |
197 | - buf = fsrc.read(1024*1024) |
198 | - if not buf: |
199 | - break |
200 | - fdst.write(buf) |
201 | - progress.update(task, advance=len(buf)) |
202 | - progress.refresh() |
203 | - |
204 | - |
205 | def run(process): |
206 | console = Console() |
207 | |
208 | @@ -158,20 +108,6 @@ def move(): |
209 | shutil.rmtree(src_path) |
210 | |
211 | |
212 | -def hlp(): |
213 | - print(""" |
214 | -usage: ptrack [-h] [-v] [-c] [-m] |
215 | - |
216 | -A simple CLI utility for asthetically tracking progress when copying or moving files. |
217 | - |
218 | -options: |
219 | - -h, --help show this help message and exit |
220 | - -v, --verbose verbose output |
221 | - -c, --copy copy files (You can use `ptc` instead of `ptrack -c`) |
222 | - -m, --move move files (You can use `ptm` instead of `ptrack -m`) |
223 | -""") |
224 | - |
225 | - |
226 | def main(): |
227 | if argMove: |
228 | move() |
229 | @@ -180,5 +116,6 @@ def main(): |
230 | else: |
231 | hlp() |
232 | |
233 | + |
234 | if __name__ == "__main__": |
235 | main() |
236 | diff --git a/ptrack/methods.py b/ptrack/methods.py |
237 | new file mode 100644 |
238 | index 0000000..1c5e851 |
239 | --- /dev/null |
240 | +++ b/ptrack/methods.py |
241 | @@ -0,0 +1,67 @@ |
242 | +import os |
243 | +from rich.progress import Progress, BarColumn, TextColumn, TimeRemainingColumn, FileSizeColumn |
244 | + |
245 | + |
246 | +def format_file_size(file_size): |
247 | + if file_size >= 1024 * 1024 * 1024: |
248 | + return f"{file_size / (1024*1024*1024):.2f} GB" |
249 | + elif file_size >= 1024 * 1024: |
250 | + return f"{file_size / (1024*1024):.2f} MB" |
251 | + elif file_size >= 1024: |
252 | + return f"{file_size / 1024:.2f} kB" |
253 | + else: |
254 | + return f"{file_size} bytes" |
255 | + |
256 | + |
257 | +def regular_copy(src, dst, console, task, progress): |
258 | + with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: |
259 | + while True: |
260 | + buf = fsrc.read(1024*1024) |
261 | + if not buf: |
262 | + break |
263 | + fdst.write(buf) |
264 | + progress.update(task, advance=len(buf)) |
265 | + progress.refresh() |
266 | + |
267 | + |
268 | +def verbose_copy(src, dst, console, current, total_files): |
269 | + |
270 | + file_size = os.path.getsize(src) |
271 | + |
272 | + with Progress( |
273 | + BarColumn(bar_width=50), |
274 | + "[progress.percentage]{task.percentage:>3.0f}%", |
275 | + TimeRemainingColumn(), |
276 | + "[#ea2a6f][[/#ea2a6f]", |
277 | + FileSizeColumn(), |
278 | + "[#ea2a6f]/[/#ea2a6f]", |
279 | + TextColumn(f"[bold cyan]{format_file_size(file_size)}[/bold cyan]"), |
280 | + "[#ea2a6f]][/#ea2a6f]", |
281 | + f"({current} of {total_files})", |
282 | + console=console, |
283 | + auto_refresh=False |
284 | + ) as progress: |
285 | + task = progress.add_task("", total=file_size, file_size=format_file_size(file_size)) |
286 | + |
287 | + with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: |
288 | + while not progress.finished: |
289 | + buf = fsrc.read(1024*1024) |
290 | + if not buf: |
291 | + break |
292 | + fdst.write(buf) |
293 | + progress.update(task, advance=len(buf)) |
294 | + progress.refresh() |
295 | + |
296 | + |
297 | +def hlp(): |
298 | + print(""" |
299 | +usage: ptrack [-h] [-v] [-c] [-m] |
300 | + |
301 | +A simple CLI utility for asthetically tracking progress when copying or moving files. |
302 | + |
303 | +options: |
304 | + -h, --help show this help message and exit |
305 | + -v, --verbose verbose output |
306 | + -c, --copy copy files (You can use `ptc` instead of `ptrack -c`) |
307 | + -m, --move move files (You can use `ptm` instead of `ptrack -m`) |
308 | +""") |