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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libjam
3
- Version: 0.0.18
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
- responsible for handling command-line arguments
28
+ Responsible for handling command-line arguments.
29
29
 
30
30
  ### Drawer
31
- responsible for file operations
31
+ Responsible for file operations.
32
32
 
33
33
  ### Typewriter
34
- responsible for transforming and printing text
34
+ Responsible for transforming and printing text.
35
35
 
36
36
  ### Clipboard
37
- responsible for working with lists
37
+ Responsible for working with lists.
38
38
 
39
39
  ### Notebook
40
- responsible for configuration
40
+ Responsible for configuration.
41
41
 
42
42
  ### Flashcard
43
- responsible for getting user input from the command line
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
- responsible for handling command-line arguments
14
+ Responsible for handling command-line arguments.
15
15
 
16
16
  ### Drawer
17
- responsible for file operations
17
+ Responsible for file operations.
18
18
 
19
19
  ### Typewriter
20
- responsible for transforming and printing text
20
+ Responsible for transforming and printing text.
21
21
 
22
22
  ### Clipboard
23
- responsible for working with lists
23
+ Responsible for working with lists.
24
24
 
25
25
  ### Notebook
26
- responsible for configuration
26
+ Responsible for configuration.
27
27
 
28
28
  ### Flashcard
29
- responsible for getting user input from the command line
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 give a path to folder
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 give a path to file.
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 true if path exists.
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 size of given file/folder, in bytes.
373
- def get_file_size(self, path: str):
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':
@@ -14,7 +14,7 @@ include = [
14
14
 
15
15
  [project]
16
16
  name = "libjam"
17
- version = "0.0.18"
17
+ version = "0.0.19"
18
18
  authors = [
19
19
  { name="Philipp Kosarev", email="philipp.kosarev@gmail.com" },
20
20
  ]
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