MapleX 2.2.0.dev2__tar.gz → 3.0.0a1__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.
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/LICENSE +1 -1
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/MANIFEST.in +3 -0
- maplex-3.0.0a1/PKG-INFO +200 -0
- maplex-3.0.0a1/README.md +178 -0
- maplex-3.0.0a1/logErrorOutputSample.png +0 -0
- maplex-3.0.0a1/logOutputSample.png +0 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/pyproject.toml +7 -4
- maplex-3.0.0a1/readmes/LoggingTips.md +1 -0
- maplex-3.0.0a1/readmes/README_ConsoleColors.md +50 -0
- maplex-3.0.0a1/readmes/README_Exceptions.md +57 -0
- maplex-3.0.0a1/readmes/README_Json.md +93 -0
- maplex-3.0.0a1/readmes/README_Logger.md +158 -0
- maplex-2.2.0.dev2/README.md → maplex-3.0.0a1/readmes/README_MapleTree.md +275 -170
- maplex-3.0.0a1/src/MapleX.egg-info/PKG-INFO +200 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/MapleX.egg-info/SOURCES.txt +13 -1
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/maplex/__init__.py +13 -2
- maplex-3.0.0a1/src/maplex/json.py +206 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/maplex/mapleColors.py +1 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/maplex/mapleExceptions.py +35 -0
- maplex-3.0.0a1/src/maplex/mapleLogger.py +815 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/maplex/mapleTreeEditor.py +344 -27
- maplex-3.0.0a1/tests/test_logger_unittest.py +76 -0
- maplex-3.0.0a1/tests/test_maplejson_unittest.py +49 -0
- maplex-3.0.0a1/tests/test_mapletree_unittest.py +442 -0
- maplex-2.2.0.dev2/PKG-INFO +0 -921
- maplex-2.2.0.dev2/src/MapleX.egg-info/PKG-INFO +0 -921
- maplex-2.2.0.dev2/src/maplex/mapleLogger.py +0 -399
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/setup.cfg +0 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/MapleX.egg-info/dependency_links.txt +0 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/MapleX.egg-info/requires.txt +0 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/MapleX.egg-info/top_level.txt +0 -0
- {maplex-2.2.0.dev2 → maplex-3.0.0a1}/src/maplex/utils.py +0 -0
maplex-3.0.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: MapleX
|
|
3
|
+
Version: 3.0.0a1
|
|
4
|
+
Summary: A Python library for simple logging, json file operations, Maple file format operations, and console color utilities.
|
|
5
|
+
Author: Ryuji Hazama
|
|
6
|
+
Project-URL: PyPI, https://pypi.org/project/MapleX/
|
|
7
|
+
Project-URL: Homepage, https://github.com/Ryuji-Hazama
|
|
8
|
+
Project-URL: Repository, https://github.com/Ryuji-Hazama/MapleTree
|
|
9
|
+
Project-URL: Issues, https://github.com/Ryuji-Hazama/MapleTree/issues
|
|
10
|
+
Project-URL: YouTube, https://www.youtube.com/@ryujihazama
|
|
11
|
+
Project-URL: Instagram, https://www.instagram.com/ryujihazama/
|
|
12
|
+
Keywords: logging,logger,json,file operations,maple file format,console colors
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: cryptography>=46.0.3
|
|
20
|
+
Requires-Dist: pydantic>=2.12.5
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# MapleX
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+

|
|
27
|
+

|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
MapleX is a Python library for simple logging, json file operations, Maple file format operations, and console color utilities.
|
|
31
|
+
|
|
32
|
+
***You can install the package from pip with the following command.***
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install MapleX
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Logger Class
|
|
39
|
+
|
|
40
|
+
Logger is a logging object for Python applications. It outputs application logs to log files and to console (standard output).
|
|
41
|
+
|
|
42
|
+
Easy and simple enough to use, yet highly practical. The best logging library for beginners and for personal projects.
|
|
43
|
+
|
|
44
|
+
### Beginner Friendly
|
|
45
|
+
|
|
46
|
+
#### Color Highlited Output
|
|
47
|
+
|
|
48
|
+
The output will be color-highlighted for better analysis based on the log level. (Not tested on macOS, and you need Windows Terminal for Windows OS)
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
#### Outputs Stack Trace
|
|
53
|
+
|
|
54
|
+
You can use a function to outputs error message and the stack trace at once.
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
### Logger Sample
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import maplex
|
|
62
|
+
|
|
63
|
+
logger = maplex.getLogger("FunctionName")
|
|
64
|
+
logger.info("Hello there!")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This outputs to the console:
|
|
68
|
+
|
|
69
|
+
```console
|
|
70
|
+
[INFO ][FunctionName] <module>(4) Hello there!
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Also outputs to the log file:
|
|
74
|
+
|
|
75
|
+
```log
|
|
76
|
+
(PsNo) yyyy-MM-dd HH:mm:ss.fff [INFO ][FunctionName] <module>(4) Hello there!
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_Logger.md)
|
|
80
|
+
|
|
81
|
+
[Logging Tips](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/LoggingTips.md)
|
|
82
|
+
|
|
83
|
+
## MapleJson
|
|
84
|
+
|
|
85
|
+
MapleJson class is a library class for converting data between `dict` data and JSON-formatted file data.
|
|
86
|
+
|
|
87
|
+
You can read, write, and also encrypt a JSON file as a `dict` data.
|
|
88
|
+
|
|
89
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_Json.md)
|
|
90
|
+
|
|
91
|
+
## Maple File Format
|
|
92
|
+
|
|
93
|
+
Maple is a file system that I created when I was a child. It's like a combination of the INI file and the Jason file. I made this format that is easy to read and write for both humans and machines.
|
|
94
|
+
|
|
95
|
+
### Basic Format
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
All data before MAPLE\n will be ignored
|
|
99
|
+
|
|
100
|
+
MAPLE
|
|
101
|
+
# Maple data must start with "MAPLE"
|
|
102
|
+
|
|
103
|
+
*MAPLE_TIME
|
|
104
|
+
yyyy/MM/dd HH:mm:ss.fffffff
|
|
105
|
+
# Encoded time or optional time in the method parameter
|
|
106
|
+
|
|
107
|
+
H *STATUS
|
|
108
|
+
# File status
|
|
109
|
+
ADT yyyy/MM/dd HH:mm:ss.fffffff
|
|
110
|
+
RDT yyyy/MM/dd HH:mm:ss.fffffff
|
|
111
|
+
CNT {int}
|
|
112
|
+
H #*
|
|
113
|
+
ADT is the most recent edited time
|
|
114
|
+
RDT is the second most recent edited time (before ADT)
|
|
115
|
+
CNT is the data count (Optional)
|
|
116
|
+
E *#
|
|
117
|
+
E
|
|
118
|
+
H *Header
|
|
119
|
+
# Headers include '*' are system headers
|
|
120
|
+
E
|
|
121
|
+
H Data Headers
|
|
122
|
+
H Sub Data Header
|
|
123
|
+
CMT Comments
|
|
124
|
+
# This is also a comment
|
|
125
|
+
Tags Properties
|
|
126
|
+
# Propaties cannot include 'CRLF.'
|
|
127
|
+
Tags2 Properties
|
|
128
|
+
# You cannot use the same tags in a Header except CMT and NTE in H NOTES
|
|
129
|
+
H Sub Data Header
|
|
130
|
+
Tags Propaties
|
|
131
|
+
# You can use the same tag in the child header,
|
|
132
|
+
# which is already used in the parents' header
|
|
133
|
+
E
|
|
134
|
+
E
|
|
135
|
+
H *NOTES NOTES_HEADER
|
|
136
|
+
# Note's header
|
|
137
|
+
NTE {strimg}
|
|
138
|
+
NTE ...
|
|
139
|
+
# Notes' main strings for the multi-line data
|
|
140
|
+
# COMMENTS IN THE "*NOTES" BLOCK WILL BE DELETED WHEN SAVING!
|
|
141
|
+
E
|
|
142
|
+
H #*
|
|
143
|
+
This is a comment block.
|
|
144
|
+
Starts with "H #*"
|
|
145
|
+
and ends with "E *#"
|
|
146
|
+
E *#
|
|
147
|
+
E
|
|
148
|
+
H Data Headers2
|
|
149
|
+
E
|
|
150
|
+
# "\nEOF\n" must be needed for all data
|
|
151
|
+
EOF
|
|
152
|
+
|
|
153
|
+
All datas after "\nEOF\n" will be ignored
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_MapleTree.md#maple-file)
|
|
157
|
+
|
|
158
|
+
## MapleTree Class
|
|
159
|
+
|
|
160
|
+
MapleTree class is a Python library for reading, editing, and writeing the Maple formatted file from the Python code.
|
|
161
|
+
You can also automatically encrypt the file data using the library functions.
|
|
162
|
+
|
|
163
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_MapleTree.md#mapletree-class)
|
|
164
|
+
|
|
165
|
+
## Exceptions
|
|
166
|
+
|
|
167
|
+
Excption classes are the specialized classes for MapleX to make your debugging easier.
|
|
168
|
+
|
|
169
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_Exceptions.md#exceptions)
|
|
170
|
+
|
|
171
|
+
## Console Colors
|
|
172
|
+
|
|
173
|
+
ConsoleColors class is a class library for color-highlighting the standard output.
|
|
174
|
+
|
|
175
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_ConsoleColors.md)
|
|
176
|
+
|
|
177
|
+
## Install MapleX
|
|
178
|
+
|
|
179
|
+
### From PyPI
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
[python[3] -m] pip install MapleX [--upgrade] [--break-system-packages]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- `--upgrade` option for upgrade from older version.
|
|
186
|
+
- `--break-system-package` option for Python on Linux OS outside the `venv`. ***This might brak the system Python package dependencies.***
|
|
187
|
+
|
|
188
|
+
### Build the Package by Yourself
|
|
189
|
+
|
|
190
|
+
Run `python[3] -m build`
|
|
191
|
+
|
|
192
|
+
or
|
|
193
|
+
|
|
194
|
+
Run `python[3] setup.py sdist bdist_wheel`
|
|
195
|
+
|
|
196
|
+
### Unit test
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
python[3] -m unittest discover -s tests
|
|
200
|
+
```
|
maplex-3.0.0a1/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# MapleX
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
MapleX is a Python library for simple logging, json file operations, Maple file format operations, and console color utilities.
|
|
9
|
+
|
|
10
|
+
***You can install the package from pip with the following command.***
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install MapleX
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Logger Class
|
|
17
|
+
|
|
18
|
+
Logger is a logging object for Python applications. It outputs application logs to log files and to console (standard output).
|
|
19
|
+
|
|
20
|
+
Easy and simple enough to use, yet highly practical. The best logging library for beginners and for personal projects.
|
|
21
|
+
|
|
22
|
+
### Beginner Friendly
|
|
23
|
+
|
|
24
|
+
#### Color Highlited Output
|
|
25
|
+
|
|
26
|
+
The output will be color-highlighted for better analysis based on the log level. (Not tested on macOS, and you need Windows Terminal for Windows OS)
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
#### Outputs Stack Trace
|
|
31
|
+
|
|
32
|
+
You can use a function to outputs error message and the stack trace at once.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
### Logger Sample
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import maplex
|
|
40
|
+
|
|
41
|
+
logger = maplex.getLogger("FunctionName")
|
|
42
|
+
logger.info("Hello there!")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This outputs to the console:
|
|
46
|
+
|
|
47
|
+
```console
|
|
48
|
+
[INFO ][FunctionName] <module>(4) Hello there!
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Also outputs to the log file:
|
|
52
|
+
|
|
53
|
+
```log
|
|
54
|
+
(PsNo) yyyy-MM-dd HH:mm:ss.fff [INFO ][FunctionName] <module>(4) Hello there!
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_Logger.md)
|
|
58
|
+
|
|
59
|
+
[Logging Tips](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/LoggingTips.md)
|
|
60
|
+
|
|
61
|
+
## MapleJson
|
|
62
|
+
|
|
63
|
+
MapleJson class is a library class for converting data between `dict` data and JSON-formatted file data.
|
|
64
|
+
|
|
65
|
+
You can read, write, and also encrypt a JSON file as a `dict` data.
|
|
66
|
+
|
|
67
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_Json.md)
|
|
68
|
+
|
|
69
|
+
## Maple File Format
|
|
70
|
+
|
|
71
|
+
Maple is a file system that I created when I was a child. It's like a combination of the INI file and the Jason file. I made this format that is easy to read and write for both humans and machines.
|
|
72
|
+
|
|
73
|
+
### Basic Format
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
All data before MAPLE\n will be ignored
|
|
77
|
+
|
|
78
|
+
MAPLE
|
|
79
|
+
# Maple data must start with "MAPLE"
|
|
80
|
+
|
|
81
|
+
*MAPLE_TIME
|
|
82
|
+
yyyy/MM/dd HH:mm:ss.fffffff
|
|
83
|
+
# Encoded time or optional time in the method parameter
|
|
84
|
+
|
|
85
|
+
H *STATUS
|
|
86
|
+
# File status
|
|
87
|
+
ADT yyyy/MM/dd HH:mm:ss.fffffff
|
|
88
|
+
RDT yyyy/MM/dd HH:mm:ss.fffffff
|
|
89
|
+
CNT {int}
|
|
90
|
+
H #*
|
|
91
|
+
ADT is the most recent edited time
|
|
92
|
+
RDT is the second most recent edited time (before ADT)
|
|
93
|
+
CNT is the data count (Optional)
|
|
94
|
+
E *#
|
|
95
|
+
E
|
|
96
|
+
H *Header
|
|
97
|
+
# Headers include '*' are system headers
|
|
98
|
+
E
|
|
99
|
+
H Data Headers
|
|
100
|
+
H Sub Data Header
|
|
101
|
+
CMT Comments
|
|
102
|
+
# This is also a comment
|
|
103
|
+
Tags Properties
|
|
104
|
+
# Propaties cannot include 'CRLF.'
|
|
105
|
+
Tags2 Properties
|
|
106
|
+
# You cannot use the same tags in a Header except CMT and NTE in H NOTES
|
|
107
|
+
H Sub Data Header
|
|
108
|
+
Tags Propaties
|
|
109
|
+
# You can use the same tag in the child header,
|
|
110
|
+
# which is already used in the parents' header
|
|
111
|
+
E
|
|
112
|
+
E
|
|
113
|
+
H *NOTES NOTES_HEADER
|
|
114
|
+
# Note's header
|
|
115
|
+
NTE {strimg}
|
|
116
|
+
NTE ...
|
|
117
|
+
# Notes' main strings for the multi-line data
|
|
118
|
+
# COMMENTS IN THE "*NOTES" BLOCK WILL BE DELETED WHEN SAVING!
|
|
119
|
+
E
|
|
120
|
+
H #*
|
|
121
|
+
This is a comment block.
|
|
122
|
+
Starts with "H #*"
|
|
123
|
+
and ends with "E *#"
|
|
124
|
+
E *#
|
|
125
|
+
E
|
|
126
|
+
H Data Headers2
|
|
127
|
+
E
|
|
128
|
+
# "\nEOF\n" must be needed for all data
|
|
129
|
+
EOF
|
|
130
|
+
|
|
131
|
+
All datas after "\nEOF\n" will be ignored
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_MapleTree.md#maple-file)
|
|
135
|
+
|
|
136
|
+
## MapleTree Class
|
|
137
|
+
|
|
138
|
+
MapleTree class is a Python library for reading, editing, and writeing the Maple formatted file from the Python code.
|
|
139
|
+
You can also automatically encrypt the file data using the library functions.
|
|
140
|
+
|
|
141
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_MapleTree.md#mapletree-class)
|
|
142
|
+
|
|
143
|
+
## Exceptions
|
|
144
|
+
|
|
145
|
+
Excption classes are the specialized classes for MapleX to make your debugging easier.
|
|
146
|
+
|
|
147
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_Exceptions.md#exceptions)
|
|
148
|
+
|
|
149
|
+
## Console Colors
|
|
150
|
+
|
|
151
|
+
ConsoleColors class is a class library for color-highlighting the standard output.
|
|
152
|
+
|
|
153
|
+
[More details](https://github.com/Ryuji-Hazama/MapleTree/blob/main/readmes/README_ConsoleColors.md)
|
|
154
|
+
|
|
155
|
+
## Install MapleX
|
|
156
|
+
|
|
157
|
+
### From PyPI
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
[python[3] -m] pip install MapleX [--upgrade] [--break-system-packages]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- `--upgrade` option for upgrade from older version.
|
|
164
|
+
- `--break-system-package` option for Python on Linux OS outside the `venv`. ***This might brak the system Python package dependencies.***
|
|
165
|
+
|
|
166
|
+
### Build the Package by Yourself
|
|
167
|
+
|
|
168
|
+
Run `python[3] -m build`
|
|
169
|
+
|
|
170
|
+
or
|
|
171
|
+
|
|
172
|
+
Run `python[3] setup.py sdist bdist_wheel`
|
|
173
|
+
|
|
174
|
+
### Unit test
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
python[3] -m unittest discover -s tests
|
|
178
|
+
```
|
|
Binary file
|
|
Binary file
|
|
@@ -4,10 +4,9 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "MapleX"
|
|
7
|
-
version = "
|
|
8
|
-
description = """
|
|
9
|
-
|
|
10
|
-
"""
|
|
7
|
+
version = "3.0.0a1"
|
|
8
|
+
description = """A Python library for simple logging, json file operations, Maple file format operations, and console color utilities."""
|
|
9
|
+
keywords = ["logging", "logger", "json", "file operations", "maple file format", "console colors"]
|
|
11
10
|
readme = "README.md"
|
|
12
11
|
license-files = ["LICENSE"]
|
|
13
12
|
authors = [
|
|
@@ -26,6 +25,10 @@ requires-python = ">=3.12"
|
|
|
26
25
|
|
|
27
26
|
[tool.setuptools.packages.find]
|
|
28
27
|
where = ["src"]
|
|
28
|
+
include = ["maplex*"]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.package-data]
|
|
31
|
+
"*" = ["tests/*.py"]
|
|
29
32
|
|
|
30
33
|
[project.urls]
|
|
31
34
|
PyPI = "https://pypi.org/project/MapleX/"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Logging Tips
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Console Colors
|
|
2
|
+
|
|
3
|
+
## Standard colors
|
|
4
|
+
|
|
5
|
+
|Key|Value|Color|
|
|
6
|
+
|---|-----|-----|
|
|
7
|
+
|`Black`|\\033\[30m|Black|
|
|
8
|
+
|`Red`|\\033\[31m|Red|
|
|
9
|
+
|`Green`|\\033\[32m|Green|
|
|
10
|
+
|`Yellow`|\\033\[33m|Yellow|
|
|
11
|
+
|`Blue`|\\033\[34m|Blue|
|
|
12
|
+
|`Magenta`|\\033\[35m|Magenta|
|
|
13
|
+
|`LightBlue`|\\033\[36m|LightBlue|
|
|
14
|
+
|`White`|\\033\[37m|White|
|
|
15
|
+
|
|
16
|
+
## Bright colors
|
|
17
|
+
|
|
18
|
+
|Key|Value|Color|
|
|
19
|
+
|---|-----|-----|
|
|
20
|
+
|`bBlack`|\\033\[90m|Black|
|
|
21
|
+
|`bRed`|\\033\[91m|Red|
|
|
22
|
+
|`bGreen`|\\033\[92m|Green|
|
|
23
|
+
|`bYellow`|\\033\[93m|Yellow|
|
|
24
|
+
|`bBlue`|\\033\[94m|Blue|
|
|
25
|
+
|`bMagenta`|\\033\[95m|Magenta|
|
|
26
|
+
|`bLightBlue`|\\033\[96m|LightBlue|
|
|
27
|
+
|`bWhite`|\\033\[97m|White|
|
|
28
|
+
|
|
29
|
+
## Background colors
|
|
30
|
+
|
|
31
|
+
|Key|Value|Color|
|
|
32
|
+
|---|-----|-----|
|
|
33
|
+
|`bgBlack`|\\033\[40m|Black|
|
|
34
|
+
|`bgRed`|\\033\[41m|Red|
|
|
35
|
+
|`bgGreen`|\\033\[42m|Green|
|
|
36
|
+
|`bgYellow`|\\033\[43m|Yellow|
|
|
37
|
+
|`bgBlue`|\\033\[44m|Blue|
|
|
38
|
+
|`bgMagenta`|\\033\[45m|Magenta|
|
|
39
|
+
|`bgLightBlue`|\\033\[46m|LightBlue|
|
|
40
|
+
|`bgWhite`|\\033\[47m|White|
|
|
41
|
+
|
|
42
|
+
## Other formats
|
|
43
|
+
|
|
44
|
+
|Key|Value|Description|
|
|
45
|
+
|---|-----|-----------|
|
|
46
|
+
|`Bold`|\\033\[1m|Bold text|
|
|
47
|
+
|`Italic`|\\033\[3m|Italic text|
|
|
48
|
+
|`Underline`|\\033\[4m|Underlined text|
|
|
49
|
+
|`Reversed`|\\033\[7m|Reversed colors|
|
|
50
|
+
|`Reset`|\\033\[0m|Reset formatting|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Exceptions
|
|
2
|
+
|
|
3
|
+
## `class MapleException(Exception)`
|
|
4
|
+
|
|
5
|
+
This is a basic exception class for MapleTree.
|
|
6
|
+
|
|
7
|
+
## `class MapleFileNotFoundException(MapleException)`
|
|
8
|
+
|
|
9
|
+
This occurs when the file that was specified at the instance initialization was not found.
|
|
10
|
+
|
|
11
|
+
## `class KeyEmptyException(MapleException)`
|
|
12
|
+
|
|
13
|
+
This occurs when `encrypt=True` is used at the instance initialization, but the key for encryption is missing (`None` or empty).
|
|
14
|
+
|
|
15
|
+
## `class MapleFileLockedException(MapleException)`
|
|
16
|
+
|
|
17
|
+
This occurs when the instance tries to open the file, but the other instance has already locked the file.
|
|
18
|
+
|
|
19
|
+
## `class MapleDataNotFoundException(MapleException)`
|
|
20
|
+
|
|
21
|
+
This occurs when the data is not found in the file.
|
|
22
|
+
|
|
23
|
+
## `MapleEncryptionNotEnabledException(MapleException)`
|
|
24
|
+
|
|
25
|
+
This occurs when trying to encrypt Maple data, but the encryption flag is `False`.
|
|
26
|
+
|
|
27
|
+
## `class MapleHeaderNotFoundException(MapleDataNotFoundException)`
|
|
28
|
+
|
|
29
|
+
This occurs when the header (specified by the user) is not found in the data.
|
|
30
|
+
|
|
31
|
+
## `class MapleTagNotFoundException(MapleDataNotFoundException)`
|
|
32
|
+
|
|
33
|
+
This occurs when the tag (specified by the user) is not found in the data.
|
|
34
|
+
|
|
35
|
+
## `class NotAMapleFileException(MapleDataNotFoundException)`
|
|
36
|
+
|
|
37
|
+
This occurs when the file is not a Maple file.
|
|
38
|
+
|
|
39
|
+
- The file without a "MAPLE" line.
|
|
40
|
+
|
|
41
|
+
## `class InvalidMapleFileFormatException(NotAMapleFileException)`
|
|
42
|
+
|
|
43
|
+
This occurs when the file format is an invalid Maple format.
|
|
44
|
+
|
|
45
|
+
- The file has a "MAPLE" line, but the format is wrong or broken.
|
|
46
|
+
|
|
47
|
+
## `class MapleFileEmptyException(NotAMapleFileException)`
|
|
48
|
+
|
|
49
|
+
This occurs when the file is empty (No data)
|
|
50
|
+
|
|
51
|
+
## `class MapleSyntaxException(MapleException)`
|
|
52
|
+
|
|
53
|
+
This occurs when the syntax of the MapleTree function (mostly its parameter) is invalid.
|
|
54
|
+
|
|
55
|
+
## `class MapleTypeException(MapleSyntaxException)`
|
|
56
|
+
|
|
57
|
+
This occurs when the user hands the unknown keyword arguments as the `**kwargs` to the MapleTree function.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# MapleJson Class
|
|
2
|
+
|
|
3
|
+
MapleJson class is a class library to manage the JSON formatted files.
|
|
4
|
+
|
|
5
|
+
- You can read a JSON file as a `dict` data.
|
|
6
|
+
- You can write the `dict` data into a file as a JSON formatted string
|
|
7
|
+
- You can save the data as an encrypted data string.
|
|
8
|
+
- You can decrypt the encrypted data.
|
|
9
|
+
|
|
10
|
+
## Class Initialization
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
filePath: str,
|
|
16
|
+
fileEncoding: str = 'utf-8',
|
|
17
|
+
indent: int = 4,
|
|
18
|
+
ensure_ascii: bool = False,
|
|
19
|
+
encrypt: bool = False,
|
|
20
|
+
key: bytes = None
|
|
21
|
+
) -> None:
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|Property|Required|Value|Version|
|
|
25
|
+
|--------|--------|-----|-------|
|
|
26
|
+
|**filePath**|\*|JSON file path|3.0.0|
|
|
27
|
+
|**fileEncoding**||File encoding|3.0.0|
|
|
28
|
+
|**indent**||Indent size for save as a JSON file|3.0.0|
|
|
29
|
+
|**ensureAscii**||Ensure ASCII flag when save to a file|3.0.0|
|
|
30
|
+
|**encrypt**||Encryption flag|3.0.0|
|
|
31
|
+
|**key**|(\*)|Encryption key|3.0.0|
|
|
32
|
+
|
|
33
|
+
Initialize the class with a file path.
|
|
34
|
+
|
|
35
|
+
### File encoding
|
|
36
|
+
|
|
37
|
+
You can set a specific file character encoding. Default: `UTF-8`
|
|
38
|
+
|
|
39
|
+
E.g.: If you are using `Shift_JIS` (Japanese system), you should initialize the class like the example below:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from maplex import MapleJson
|
|
43
|
+
|
|
44
|
+
jsonInstance = MapleJson("jsonFile.json", fileEncoding="shift_jis")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Indent size
|
|
48
|
+
|
|
49
|
+
You can set the block indent size with `indent` parameter. Default: `4`
|
|
50
|
+
|
|
51
|
+
If you set `indent=2`, the file will be save like the example below:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"Data": {
|
|
56
|
+
"Key": "Value",
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Ensure ASCII
|
|
62
|
+
|
|
63
|
+
You can set the flag to ensure ASCII encoding.
|
|
64
|
+
|
|
65
|
+
If you don't set the parameter (Default: `False`), the file contents after saving are look like the example below:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"data": {
|
|
70
|
+
"japanese": "値",
|
|
71
|
+
"russian": "значение",
|
|
72
|
+
"english": "value"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
But, if you set `ensureAscii=True`, the file contents after saving will be changed like:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"data": {
|
|
82
|
+
"japanese": "\u5024",
|
|
83
|
+
"russian": "\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435",
|
|
84
|
+
"english": "value"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Encrypt
|
|
90
|
+
|
|
91
|
+
### Key
|
|
92
|
+
|
|
93
|
+
## Functions
|