libjam 0.0.15__tar.gz → 0.0.17__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.15 → libjam-0.0.17}/PKG-INFO +1 -1
- libjam-0.0.17/build.sh +33 -0
- {libjam-0.0.15 → libjam-0.0.17}/libjam/drawer.py +6 -7
- {libjam-0.0.15 → libjam-0.0.17}/libjam/notebook.py +21 -26
- {libjam-0.0.15 → libjam-0.0.17}/libjam/typewriter.py +5 -2
- {libjam-0.0.15 → libjam-0.0.17}/pyproject.toml +1 -1
- libjam-0.0.15/build.sh +0 -8
- {libjam-0.0.15 → libjam-0.0.17}/.gitignore +0 -0
- {libjam-0.0.15 → libjam-0.0.17}/LICENSE +0 -0
- {libjam-0.0.15 → libjam-0.0.17}/README.md +0 -0
- {libjam-0.0.15 → libjam-0.0.17}/libjam/__init__.py +0 -0
- {libjam-0.0.15 → libjam-0.0.17}/libjam/captain.py +0 -0
- {libjam-0.0.15 → libjam-0.0.17}/libjam/clipboard.py +0 -0
- {libjam-0.0.15 → libjam-0.0.17}/libjam/flashcard.py +0 -0
libjam-0.0.17/build.sh
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#! /bin/bash
|
2
|
+
|
3
|
+
# Functions
|
4
|
+
function Ask {
|
5
|
+
while true; do
|
6
|
+
read -p "$* [y/N]: " yn
|
7
|
+
case $yn in
|
8
|
+
[Yy]*) return 0 ;;
|
9
|
+
[Nn]*) return 1 ;;
|
10
|
+
*) return 1 ;;
|
11
|
+
esac
|
12
|
+
done
|
13
|
+
}
|
14
|
+
|
15
|
+
function Build {
|
16
|
+
echo "Deleting 'dist' directory..."
|
17
|
+
rm ./dist -r
|
18
|
+
echo "Building..."
|
19
|
+
python3 -m build
|
20
|
+
}
|
21
|
+
|
22
|
+
function Publish {
|
23
|
+
python3 -m twine upload --repository pypi dist/*
|
24
|
+
}
|
25
|
+
|
26
|
+
function Update {
|
27
|
+
pip install --upgrade libjam
|
28
|
+
}
|
29
|
+
|
30
|
+
# Running
|
31
|
+
Build
|
32
|
+
Ask "Publish new version to PyPi?" && Publish &&
|
33
|
+
Ask "Update libjam?" && Update
|
@@ -88,15 +88,14 @@ class Drawer:
|
|
88
88
|
absolute_files.append(file)
|
89
89
|
return outpath(absolute_files)
|
90
90
|
|
91
|
-
# Returns a list of files in a given folder
|
91
|
+
# Returns a list of files in a given folder.
|
92
92
|
def get_files(self, path: str):
|
93
|
-
|
94
|
-
unfiltered_files = self.get_all(path)
|
93
|
+
everything = self.get_all(path)
|
95
94
|
files = []
|
96
|
-
for
|
97
|
-
if self.is_file:
|
98
|
-
files.append(
|
99
|
-
return
|
95
|
+
for item in everything:
|
96
|
+
if self.is_file(item):
|
97
|
+
files.append(item)
|
98
|
+
return files
|
100
99
|
|
101
100
|
# Returns a list of folders in a given folder
|
102
101
|
def get_folders(self, path: str):
|
@@ -8,9 +8,17 @@ drawer = Drawer()
|
|
8
8
|
# Deals with configs and reading/writing files
|
9
9
|
class Notebook:
|
10
10
|
|
11
|
+
# Reads a text file and returns a string.
|
12
|
+
def read_file(self, path):
|
13
|
+
if drawer.is_folder(path):
|
14
|
+
raise FileExistsError(f"Attempted to read folder '{path}' as a text file.")
|
15
|
+
elif drawer.is_file(path) is False:
|
16
|
+
raise FileNotFoundError(f"File '{path}' not found.")
|
17
|
+
return open(path, 'r').read()
|
18
|
+
|
11
19
|
# Checking if config exists, and creating one if it does not
|
12
20
|
def check_config(self, config_template_file: str, config_file: str):
|
13
|
-
config_template =
|
21
|
+
config_template = self.read_file(config_template_file)
|
14
22
|
config_folder = drawer.get_parent(config_file)
|
15
23
|
if drawer.is_folder(config_folder) is False:
|
16
24
|
drawer.make_folder(config_folder)
|
@@ -23,33 +31,24 @@ class Notebook:
|
|
23
31
|
|
24
32
|
# parsing a toml config
|
25
33
|
def read_toml(self, config_file: str):
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
if type(path) == str:
|
35
|
-
data[category][item] = drawer.absolute_path(path)
|
36
|
-
return data
|
37
|
-
except:
|
38
|
-
print(f"Encountered error reading '{config_file}'")
|
39
|
-
print(f"Contents of '{config_file}':")
|
40
|
-
print(data)
|
41
|
-
return None
|
34
|
+
data = self.read_file(config_file)
|
35
|
+
data = tomllib.loads(data)
|
36
|
+
for category in data:
|
37
|
+
for item in data.get(category):
|
38
|
+
path = data.get(category).get(item)
|
39
|
+
if type(path) == str:
|
40
|
+
data[category][item] = drawer.absolute_path(path)
|
41
|
+
return data
|
42
42
|
|
43
43
|
# Reads ini file and returns its contents in the form of a dict.
|
44
44
|
# allow_duplicates is only to be used as a last resort due to the performance
|
45
45
|
# impact and inaccuracy in results.
|
46
46
|
def read_ini(self, ini_file: str, allow_duplicates=False):
|
47
|
-
|
48
|
-
|
49
|
-
ini_file = drawer.absolute_path(ini_file)
|
47
|
+
# Checking file
|
48
|
+
data = self.read_file(ini_file)
|
50
49
|
parser = configparser.ConfigParser(inline_comment_prefixes=('#', ';'))
|
51
50
|
try:
|
52
|
-
parser.
|
51
|
+
parser.read_string(data)
|
53
52
|
except configparser.DuplicateSectionError:
|
54
53
|
if allow_duplicates is True:
|
55
54
|
ini_string = open(ini_file, 'r').read()
|
@@ -92,7 +91,6 @@ class Notebook:
|
|
92
91
|
def write_ini(self, ini_file: str, contents: dict):
|
93
92
|
if drawer.is_file(ini_file) is False:
|
94
93
|
return None
|
95
|
-
ini_file = drawer.absolute_path(ini_file)
|
96
94
|
parser = configparser.ConfigParser()
|
97
95
|
for section in contents:
|
98
96
|
for var_name in contents.get(section):
|
@@ -106,10 +104,7 @@ class Notebook:
|
|
106
104
|
# Reads a given json file as a dictionary.
|
107
105
|
# Returns None if file doesn't exist.
|
108
106
|
def read_json(self, json_file: str):
|
109
|
-
|
110
|
-
return None
|
111
|
-
json_file = drawer.absolute_path(json_file)
|
112
|
-
json_string = open(json_file, 'r').read()
|
107
|
+
json_string = self.read_file(json_file)
|
113
108
|
json_string = json_string.replace('null', 'None')
|
114
109
|
# Trying the sane method
|
115
110
|
try:
|
@@ -83,7 +83,10 @@ class Typewriter:
|
|
83
83
|
# Adding spaces
|
84
84
|
current_text = 0
|
85
85
|
for text in column:
|
86
|
-
|
86
|
+
if current_column == len(columns) - 1:
|
87
|
+
spaces = ''
|
88
|
+
else:
|
89
|
+
spaces = ' ' * ((column_width - len(text)) + 1)
|
87
90
|
columns[current_column][current_text] = text + spaces
|
88
91
|
current_text += 1
|
89
92
|
current_column += 1
|
@@ -121,4 +124,4 @@ class Typewriter:
|
|
121
124
|
for text in row:
|
122
125
|
output += text
|
123
126
|
# Returning string
|
124
|
-
return output
|
127
|
+
return output.rstrip()
|
libjam-0.0.15/build.sh
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|