libjam 0.0.18__tar.gz → 0.0.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.
- {libjam-0.0.18 → libjam-0.0.19}/PKG-INFO +7 -7
- {libjam-0.0.18 → libjam-0.0.19}/README.md +6 -6
- {libjam-0.0.18 → libjam-0.0.19}/libjam/drawer.py +33 -5
- {libjam-0.0.18 → libjam-0.0.19}/pyproject.toml +1 -1
- {libjam-0.0.18 → libjam-0.0.19}/.gitignore +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/LICENSE +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/build.sh +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/example.py +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/libjam/__init__.py +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/libjam/captain.py +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/libjam/clipboard.py +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/libjam/flashcard.py +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/libjam/notebook.py +0 -0
- {libjam-0.0.18 → libjam-0.0.19}/libjam/typewriter.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: libjam
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.19
|
4
4
|
Summary: A library jam for Python.
|
5
5
|
Project-URL: Homepage, https://github.com/philippkosarev/libjam
|
6
6
|
Project-URL: Issues, https://github.com/philippkosarev/libjam/issues
|
@@ -25,22 +25,22 @@ pip install libjam
|
|
25
25
|
libjam consists of of 6 modules:
|
26
26
|
|
27
27
|
### Captain
|
28
|
-
|
28
|
+
Responsible for handling command-line arguments.
|
29
29
|
|
30
30
|
### Drawer
|
31
|
-
|
31
|
+
Responsible for file operations.
|
32
32
|
|
33
33
|
### Typewriter
|
34
|
-
|
34
|
+
Responsible for transforming and printing text.
|
35
35
|
|
36
36
|
### Clipboard
|
37
|
-
|
37
|
+
Responsible for working with lists.
|
38
38
|
|
39
39
|
### Notebook
|
40
|
-
|
40
|
+
Responsible for configuration.
|
41
41
|
|
42
42
|
### Flashcard
|
43
|
-
|
43
|
+
Responsible for getting user input from the command line.
|
44
44
|
|
45
45
|
## Example project
|
46
46
|
```python
|
@@ -11,22 +11,22 @@ pip install libjam
|
|
11
11
|
libjam consists of of 6 modules:
|
12
12
|
|
13
13
|
### Captain
|
14
|
-
|
14
|
+
Responsible for handling command-line arguments.
|
15
15
|
|
16
16
|
### Drawer
|
17
|
-
|
17
|
+
Responsible for file operations.
|
18
18
|
|
19
19
|
### Typewriter
|
20
|
-
|
20
|
+
Responsible for transforming and printing text.
|
21
21
|
|
22
22
|
### Clipboard
|
23
|
-
|
23
|
+
Responsible for working with lists.
|
24
24
|
|
25
25
|
### Notebook
|
26
|
-
|
26
|
+
Responsible for configuration.
|
27
27
|
|
28
28
|
### Flashcard
|
29
|
-
|
29
|
+
Responsible for getting user input from the command line.
|
30
30
|
|
31
31
|
## Example project
|
32
32
|
```python
|
@@ -45,19 +45,19 @@ class Drawer:
|
|
45
45
|
path = realpath(path)
|
46
46
|
return outpath(path)
|
47
47
|
|
48
|
-
# Returns True if
|
48
|
+
# Returns True if given a path to a folder.
|
49
49
|
def is_folder(self, path: str):
|
50
50
|
if path == '':
|
51
51
|
return False
|
52
52
|
path = realpath(path)
|
53
53
|
return os.path.isdir(path)
|
54
54
|
|
55
|
-
# Returns True if
|
55
|
+
# Returns True if given a path to a file.
|
56
56
|
def is_file(self, path: str):
|
57
57
|
path = realpath(path)
|
58
58
|
return os.path.isfile(path)
|
59
59
|
|
60
|
-
# Returns
|
60
|
+
# Returns True if path exists.
|
61
61
|
def exists(self, path: str):
|
62
62
|
path = realpath(path)
|
63
63
|
is_file = self.is_folder(path)
|
@@ -369,8 +369,8 @@ class Drawer:
|
|
369
369
|
temp = str(tempfile.gettempdir())
|
370
370
|
return outpath(temp)
|
371
371
|
|
372
|
-
# Returns the
|
373
|
-
def
|
372
|
+
# Returns the weight of given file/folder, in bytes.
|
373
|
+
def get_filesize(self, path: str):
|
374
374
|
path = realpath(path)
|
375
375
|
try:
|
376
376
|
if self.is_file(path):
|
@@ -385,6 +385,34 @@ class Drawer:
|
|
385
385
|
typewriter.print('Program aborted while gathering size of files.')
|
386
386
|
sys.exit(1)
|
387
387
|
|
388
|
+
# Given a number of bytes, returns a human readable filesize as a tuple.
|
389
|
+
# Tuple format: (value: int, short_unit_name: str, long_unit_name: str)
|
390
|
+
# Example tuple: (6.986356, 'mb', 'megabytes')
|
391
|
+
def get_readable_filesize(self, filesize: int):
|
392
|
+
if filesize > 1000 ** 7:
|
393
|
+
value = filesize / 1000 ** 7
|
394
|
+
return (value, 'zb', 'zettabytes')
|
395
|
+
elif filesize > 1000 ** 6:
|
396
|
+
value = filesize / 1000 ** 6
|
397
|
+
return (value, 'eb', 'exabytes')
|
398
|
+
elif filesize > 1000 ** 5:
|
399
|
+
value = filesize / 1000 ** 5
|
400
|
+
return (value, 'pb', 'petabytes')
|
401
|
+
elif filesize > 1000 ** 4:
|
402
|
+
value = filesize / 1000 ** 4
|
403
|
+
return (value, 'tb', 'terabytes')
|
404
|
+
elif filesize > 1000 ** 3:
|
405
|
+
value = filesize / 1000 ** 3
|
406
|
+
return (value, 'gb', 'gigabytes')
|
407
|
+
elif filesize > 1000 ** 2:
|
408
|
+
value = filesize / 1000 ** 2
|
409
|
+
return (value, 'mb', 'megabytes')
|
410
|
+
elif filesize > 1000:
|
411
|
+
value = filesize / 1000 ** 1
|
412
|
+
return (value, 'kb', 'kilobytes')
|
413
|
+
else:
|
414
|
+
return (filesize, 'b', 'bytes')
|
415
|
+
|
388
416
|
def open(self, path: str):
|
389
417
|
path = realpath(path)
|
390
418
|
if PLATFORM == 'Linux':
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|