libjam 0.0.6__py3-none-any.whl → 0.0.8__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.
- libjam/drawer.py +16 -1
- libjam/notebook.py +11 -3
- {libjam-0.0.6.dist-info → libjam-0.0.8.dist-info}/METADATA +7 -1
- {libjam-0.0.6.dist-info → libjam-0.0.8.dist-info}/RECORD +6 -6
- {libjam-0.0.6.dist-info → libjam-0.0.8.dist-info}/WHEEL +0 -0
- {libjam-0.0.6.dist-info → libjam-0.0.8.dist-info}/licenses/LICENSE +0 -0
libjam/drawer.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# Imports
|
2
2
|
import os, sys, shutil, send2trash, platform, tempfile, pathlib
|
3
|
-
import zipfile, patoolib, rarfile
|
3
|
+
import zipfile, patoolib, rarfile, subprocess
|
4
4
|
from .typewriter import Typewriter
|
5
5
|
from .clipboard import Clipboard
|
6
6
|
typewriter = Typewriter()
|
7
7
|
clipboard = Clipboard()
|
8
8
|
|
9
|
+
PLATFORM = platform.system()
|
10
|
+
|
9
11
|
# Internal functions
|
10
12
|
joinpath = os.path.join
|
11
13
|
def realpath(path: str or list):
|
@@ -348,6 +350,7 @@ class Drawer:
|
|
348
350
|
try:
|
349
351
|
size = 0
|
350
352
|
if self.is_file(path):
|
353
|
+
path = realpath(path)
|
351
354
|
size += os.path.getsize(path)
|
352
355
|
elif self.is_folder(path):
|
353
356
|
subfiles = self.get_files_recursive(path)
|
@@ -357,3 +360,15 @@ class Drawer:
|
|
357
360
|
except KeyboardInterrupt:
|
358
361
|
typewriter.print('Program aborted while gathering size of files.')
|
359
362
|
sys.exit(1)
|
363
|
+
|
364
|
+
def open_path(self, path: str):
|
365
|
+
path = realpath(path)
|
366
|
+
if PLATFORM == 'Linux':
|
367
|
+
subprocess.run(['xdg-open', path])
|
368
|
+
elif PLATFORM == 'Windows':
|
369
|
+
subprocess.run(['start', path])
|
370
|
+
elif PLATFORM == 'Darwin':
|
371
|
+
subprocess.run(['open', path])
|
372
|
+
else:
|
373
|
+
return 1
|
374
|
+
return 0
|
libjam/notebook.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Imports
|
2
|
-
import os, tomllib, configparser, json
|
2
|
+
import os, tomllib, configparser, json, ast
|
3
3
|
from .drawer import Drawer
|
4
4
|
|
5
5
|
# Jam classes
|
@@ -63,6 +63,7 @@ class Notebook:
|
|
63
63
|
data[section] = keys
|
64
64
|
return data
|
65
65
|
|
66
|
+
# Writes an ini file from a given dict to a given path.
|
66
67
|
def write_ini(self, ini_file: str, contents: dict):
|
67
68
|
if drawer.is_file(ini_file) is False:
|
68
69
|
return None
|
@@ -77,10 +78,17 @@ class Notebook:
|
|
77
78
|
with open(ini_file, 'w') as file:
|
78
79
|
parser.write(file)
|
79
80
|
|
81
|
+
# Reads a given json file as a dictionary.
|
80
82
|
def read_json(self, json_file: str):
|
81
83
|
if drawer.is_file(json_file) is False:
|
82
84
|
return None
|
83
85
|
json_file = os.path.normpath(json_file)
|
84
|
-
|
85
|
-
|
86
|
+
json_string = open(json_file, 'r').read()
|
87
|
+
try:
|
88
|
+
data = json.loads(json_string)
|
89
|
+
except json.decoder.JSONDecodeError:
|
90
|
+
json_string = json_string.replace('\n', ' ')
|
91
|
+
data = ast.literal_eval(json_string)
|
92
|
+
except:
|
93
|
+
data = None
|
86
94
|
return data
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: libjam
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
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
|
@@ -15,6 +15,12 @@ Description-Content-Type: text/markdown
|
|
15
15
|
# libjam
|
16
16
|
A library jam for Python.
|
17
17
|
|
18
|
+
## Installing
|
19
|
+
libjam is available on [pypi](https://pypi.org/project/libjam/), and can be installed using pip.
|
20
|
+
```
|
21
|
+
pip install libjam
|
22
|
+
```
|
23
|
+
|
18
24
|
## Modules
|
19
25
|
libjam consists of of 6 modules:
|
20
26
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
libjam/__init__.py,sha256=iLE2y9r0Sfe3oIeoFHKwFIyLL6d_KcLP7fINd7pPAlY,145
|
2
2
|
libjam/captain.py,sha256=igx-ecKJBI_vBN-pW7KmSEnmYMIHQEb9tFzpy5qHmI8,5636
|
3
3
|
libjam/clipboard.py,sha256=5HxlO8ztLJPlnSCq4PncGvY4JGc9C4J2uHcepjC6zmg,3496
|
4
|
-
libjam/drawer.py,sha256=
|
4
|
+
libjam/drawer.py,sha256=z7cGoRuLlC56LkVoQd1tQkigI-3hEo89b_9Q82f01ls,11447
|
5
5
|
libjam/flashcard.py,sha256=ulV4KPC3BRWLxwkQ87vsY0aM38nYpzOjUOISxTIRVDg,437
|
6
|
-
libjam/notebook.py,sha256=
|
6
|
+
libjam/notebook.py,sha256=2Fr9pMPqvnbNzsQn3bG9PSv-ZjKDBJCHqq78jOAjYfE,3100
|
7
7
|
libjam/typewriter.py,sha256=waKY1sDxGzI2ZT5dSzFmLGbaNTIpEM5Zhg_OlPFUAng,3730
|
8
|
-
libjam-0.0.
|
9
|
-
libjam-0.0.
|
10
|
-
libjam-0.0.
|
11
|
-
libjam-0.0.
|
8
|
+
libjam-0.0.8.dist-info/METADATA,sha256=ad2TDwkFLixtR3-zX8bpO36uwpT99uge1DzPxA-MLZ0,2140
|
9
|
+
libjam-0.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
libjam-0.0.8.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
11
|
+
libjam-0.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|