-
Notifications
You must be signed in to change notification settings - Fork 0
/
mksnap.py
70 lines (60 loc) · 2.2 KB
/
mksnap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- encoding: utf-8 -*-
"""
Auto-generate snapcraft.yaml.
"""
import sys
from pathlib import Path
from subprocess import check_output # nosec
sys.path.insert(1, str(Path(__file__).parent.parent))
import tqdm # NOQA
snap_yml = r"""name: tqdm
summary: A fast, extensible CLI progress bar
description: |
https://tqdm.github.io
`tqdm` means "progress" in Arabic (taqadum, تقدّم) and is an
abbreviation for "I love you so much" in Spanish (te quiero demasiado).
Instantly make your loops show a smart progress meter and stats - just
replace any pipe "`|`" with "`| tqdm |`", and you're done!
```sh
$ seq 9999999 | tqdm --bytes | wc -l
75.2MB [00:00, 217MB/s]
9999999
$ 7z a -bd -r backup.7z docs/ | grep Compressing | \
tqdm --total $(find docs/ -type f | wc -l) --unit files >> backup.log
100%|███████████████████████████████▉| 8014/8014 [01:37<00:00, 82.29files/s]
```
Overhead is low -- about 60ns per iteration.
In addition to its low overhead, `tqdm` uses smart algorithms to predict
the remaining time and to skip unnecessary iteration displays, which
allows for a negligible overhead in most cases.
`tqdm` works on any platform (Linux, Windows, Mac, FreeBSD, NetBSD,
Solaris/SunOS), in any console or in a GUI, and is also friendly with
IPython/Jupyter notebooks.
`tqdm` does not require any dependencies, just
an environment supporting `carriage return \r` and
`line feed \n` control characters.
grade: stable
confinement: strict
base: core22
icon: logo.png
version: '{version}'
license: MPL-2.0
parts:
tqdm:
plugin: python
source: .
source-commit: '{commit}'
python-packages: [.]
build-packages: [git]
override-build: |
craftctl default
cp $SNAPCRAFT_PART_BUILD/tqdm/completion.sh $SNAPCRAFT_PART_INSTALL/
apps:
tqdm:
command: bin/tqdm
completer: completion.sh
""".format(version=tqdm.__version__, commit=check_output([
'git', 'describe', '--always']).decode('utf-8').strip()) # nosec
if __name__ == "__main__":
(Path(__file__).resolve().parent.parent / 'snapcraft.yaml').write_text(
snap_yml.decode('utf-8') if hasattr(snap_yml, 'decode') else snap_yml, encoding='utf-8')