MapleX 2.2.0b1__tar.gz → 2.2.0.dev1__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
  MIT License
2
2
 
3
- Copyright (c) 2026 Ryuji Hazama
3
+ Copyright (c) 2025 Ryuji Hazama
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,10 +1,31 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MapleX
3
- Version: 2.2.0b1
4
- Summary: A Python library for Maple file format operations, with logging and console color utilities
5
- Author: RyujiHazama
3
+ Version: 2.2.0.dev1
4
+ Summary: MapleX: A Python library for Maple file format operations, with logging and console color utilities
5
+ Author: Ryuji Hazama
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Ryuji Hazama
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
6
27
  Project-URL: PyPI, https://pypi.org/project/MapleX/
7
- Project-URL: Homepage, https://github.com/Ryuji-Hazama
28
+ Project-URL: GitHub, https://github.com/Ryuji-Hazama
8
29
  Project-URL: Repository, https://github.com/Ryuji-Hazama/MapleTree
9
30
  Project-URL: Issues, https://github.com/Ryuji-Hazama/MapleTree/issues
10
31
  Project-URL: YouTube, https://www.youtube.com/@ryujihazama
@@ -26,18 +47,9 @@ Dynamic: license-file
26
47
      ***You can install the package from pip with the following command.***
27
48
 
28
49
  ```bash
29
- pip install MapleX
50
+ pip install maplex
30
51
  ```
31
52
 
32
- ## Table of Contents
33
-
34
- > - [Maple File](#maple-file)
35
- > - [MapleTree Class](#mapletree-class)
36
- > - [Logger Class](#logger-class)
37
- > - [Exceptions](#exceptions)
38
- > - [Console Colors](#console-colors)
39
- > - [Install MapleX](#install-maplex)
40
-
41
53
  ## Maple File
42
54
 
43
55
      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.
@@ -82,12 +94,11 @@ H Data Headers
82
94
  # which is already used in the parent's header
83
95
  E
84
96
  E
85
- H *NOTES NOTES_HEADER
97
+ H *NOTES
86
98
  # Note's header
87
99
  NTE {strimg}
88
100
  NTE ...
89
101
  # Note's main strings for the multi-line data
90
- # COMMENTS IN THE "*NOTES" BLOCK WILL BE DELETED WHEN SAVE VALUE!
91
102
  E
92
103
  H #*
93
104
  This is a comment block.
@@ -157,30 +168,9 @@ E
157
168
  EOF
158
169
  ```
159
170
 
160
- ### Notes (Multi-lined Data)
161
-
162
- `v2.2.0` or newer
163
-
164
- - You can save multi-lined data inside `H *NOTES` block.
165
- - You must specify the header when you save notes value.
166
-
167
- E.g.:
168
-
169
- ```text
170
- MAPLE
171
-
172
- H *NOTES NOTES_HEADER
173
- NTE YOU CAN SAVE
174
- NTE MULTI-LINED DATA
175
- NTE INSIDE THIS BLOCK
176
- E
177
-
178
- EOF
179
- ```
180
-
181
171
  ### Comments
182
172
 
183
- `v2.1.0` or newer
173
+ `v2.1.0 or newer`
184
174
 
185
175
  #### Comment Line
186
176
 
@@ -323,8 +313,6 @@ EOF
323
313
      If `encrypt=True`, the instance decrypts data when it is read, and encrypts data when it is saved.
324
314
      You need to specify the byte key when you use encryption, and the file must be encrypted.
325
315
 
326
- :warning: **The key must be 32 url-safe base64-encoded bytes**
327
-
328
316
  ```python
329
317
  mapleFile = MapleTree("FileName.mpl", encrypt=True, key=key)
330
318
  ```
@@ -396,32 +384,7 @@ def saveTagLine(
396
384
  |**`willSave`**|\*|Save to file flag|
397
385
  |**`headers`**||Target headers|
398
386
 
399
-     Outdated from `v2.2.0`
400
-
401
- ### `saveValue()`
402
-
403
-     `v2.2.0` or newer
404
-
405
- ```python
406
- def saveValue(
407
- tag: str,
408
- valueString: any,
409
- *headers: str,
410
- **kwargs
411
- ) -> bool
412
- ```
413
-
414
- |Property|Required|Value|
415
- |--------|--------|-----|
416
- |**`tag`**|\*|Target tag|
417
- |**`value`**|\*|Value to save|
418
- |**`headers`**||Target headers|
419
- |**`kwargs`**||Keyword arguments|
420
-
421
-     `saveValue` saves a value with a tag in a header block specified by the parameter.
422
-
423
- - Set `save=True` to save changes to the file.
424
- - Default: `save=False`
387
+     `saveTagLine` saves a value with a tag in a header block specified by the parameter.
425
388
 
426
389
  E.g.:
427
390
 
@@ -429,7 +392,7 @@ E.g.:
429
392
  from maplex import MapleTree
430
393
 
431
394
  mapleFile = MapleTree("SampleData.mpl", createBaseFile=True)
432
- mapleFile.saveTagLine("TAG", "VALUE", "FOO", save=True)
395
+ mapleFile.saveTagLine("TAG", "VALUE", True, "FOO")
433
396
 
434
397
  ```
435
398
 
@@ -445,12 +408,12 @@ EOF
445
408
 
446
409
  #### Update a Buffer Content
447
410
 
448
-     If `save=False` (or not specified), the buffer content will be updated, but no update on physical file content.
411
+     If `willSave=False`, the buffer content will be updated, but no update on physical file content.
449
412
 
450
413
  E.g.:
451
414
 
452
415
  ```python
453
- mapleFile.saveTagLine("TAG", "NEW VALUE", "FOO")
416
+ mapleFile.saveTagLine("TAG", "NEW VALUE", False, "FOO")
454
417
  ```
455
418
 
456
419
      This code changes the contents on buffer like:
@@ -475,10 +438,10 @@ EOF
475
438
 
476
439
  #### Update and Save Changes
477
440
 
478
-     If `save=True`, all the changes to the buffer will be saved.
441
+     If `willSave=True`, all the changes to the buffer will be saved.
479
442
 
480
443
  ```python
481
- mapleFile.saveTagLine("BAR", "ANOTHER VALUE", "FOO", save=True)
444
+ mapleFile.saveTagLine("BAR", "ANOTHER VALUE", True, "FOO")
482
445
  ```
483
446
 
484
447
      This code changes the contents in the file like:
@@ -497,10 +460,10 @@ EOF
497
460
      If the block and/or the header(s) specified with the parameters do not exist in the data, the function creates the new header block(s) and the tag and saves the value.
498
461
 
499
462
  ```python
500
- mapleFile.saveTagLine("TAZ", "NEW HEADER AND TAG", "NEW_HEADER")
463
+ mapleFile.saveTagLine("TAZ", "NEW HEADER AND TAG", False, "NEW_HEADER")
501
464
  ```
502
465
 
503
-     This code will change the buffer data like:
466
+     This code will change the data like:
504
467
 
505
468
  ```text
506
469
  MAPLE
@@ -530,31 +493,8 @@ def deleteTag(
530
493
  |**`willSave`**||Save to file flag|
531
494
  |**`headers`**||Target headers|
532
495
 
533
-     Outdated from `v2.2.0`
534
-
535
- ### `deleteValue()`
536
-
537
-     `v2.2.0` or newer
538
-
539
- ```python
540
- def deleteValue(
541
- delTag: str,
542
- *headers: str,
543
- **kwargs
544
- ) -> bool
545
- ```
546
-
547
- |Property|Required|Value|
548
- |--------|--------|-----|
549
- |**`delTag`**|\*|Tag to delete|
550
- |**`headers`**||Target headers|
551
- |**`kwargs`**||Keyword arguments|
552
-
553
496
      Delete a tag and its value.
554
497
 
555
- - Set `save=True` to save changes to the file.
556
- - Default: `save=False`
557
-
558
498
  Sample data: `SampleData.mpl`
559
499
 
560
500
  ```text
@@ -574,7 +514,7 @@ E.g.:
574
514
  from maplex import MapleTree
575
515
 
576
516
  mapleFile = MapleTree("SampleData.mpl")
577
- mapleFile.deleteTag("BAR", "FOO", save=True)
517
+ mapleFile.deleteTag("BAR", True, "FOO")
578
518
  ```
579
519
 
580
520
      The file data will be changed like:
@@ -681,33 +621,10 @@ def deleteHeader(
681
621
  |--------|--------|-----|
682
622
  |**`delHead`**|\*|Deleting header|
683
623
  |**`willSave`**||Save to file flag|
684
- |**`Headers`**||Target headers|
685
-
686
-     Outdated from `v2.2.0`
687
-
688
- ### `removeHeader()`
689
-
690
-     `v2.2.0` or newer
691
-
692
- ```python
693
- def removeHeader(
694
- delHead: str,
695
- *headers: str,
696
- **kwargs
697
- ) -> bool
698
- ```
699
-
700
- |Property|Required|Value|
701
- |--------|--------|-----|
702
- |**`delHead`**|\*|Deleting header|
703
624
  |**`headers`**||Target headers|
704
- |**`kwargs`**||Keyword arguments|
705
625
 
706
626
      This deletes an entire header block and its associated data, including child blocks.
707
627
 
708
- - Set `save=True` for save data to the file.
709
- - Default: `save=False`
710
-
711
628
  Sample data: `SampleData.mpl`
712
629
 
713
630
  ```text
@@ -732,7 +649,7 @@ E.g.:
732
649
  from maplex import MapleTree
733
650
 
734
651
  mapleTree = MapleTree("SampleData.mpl")
735
- mapleTree.deleteHeader("FOO", save=True)
652
+ mapleTree.deleteHeader("FOO", True)
736
653
  ```
737
654
 
738
655
      This code changes the data like:
@@ -791,255 +708,6 @@ print(headerList)
791
708
  # Outputs "['FOO', 'QUUX']"
792
709
  ```
793
710
 
794
- ### `saveNotes()`
795
-
796
-     `v2.2.0` or newer
797
-
798
- ```python
799
- def saveNotes(
800
- noteValues: list[str],
801
- *headers: str,
802
- **kwargs
803
- ) -> None
804
- ```
805
-
806
- |Property|Required|Value|
807
- |--------|--------|-----|
808
- |**`noteValues`**|\*|Data to save|
809
- |**`headers`**|\*|Target headers|
810
- |**`kwargs`**||Keyword arguments|
811
-
812
-     The function saves string list as a special notes block value. Set `save=True` to save the changes (Default: `save=False`)
813
-
814
- E.g.:
815
-
816
- ```python
817
- from maplex import MapleTree
818
-
819
- mapleTree = MapleTree("SampleData.mpl", createBasaFile=True)
820
- stringList = ["Hello", "there!"]
821
- mapleTree.saveNotes(stringList, "FOO", "BAR", save=True)
822
- ```
823
-
824
-     This code creates a new file contains the following contents:
825
-
826
- ```text
827
- MAPLE
828
-
829
- H FOO
830
- H *NOTES BAR
831
- NTE Hello
832
- NTE there!
833
- E
834
- E
835
-
836
- EOF
837
- ```
838
-
839
- ### `saveNote()`
840
-
841
-     `v2.2.0` or newer
842
-
843
- ```python
844
- def saveNote(
845
- noteValues: str,
846
- *headers: str,
847
- **kwargs
848
- ) -> None
849
- ```
850
-
851
- |Property|Required|Value|
852
- |--------|--------|-----|
853
- |**`noteValues`**|\*|Data to save|
854
- |**`headers`**|\*|Target headers|
855
- |**`kwargs`**||Keyword arguments|
856
-
857
-     The function saves multi-lined string as a special notes block value. Set `save=True` to save the changes (Default: `save=False`)
858
-
859
- E.g.:
860
-
861
- ```python
862
- from maplex import MapleTree
863
-
864
- mapleTree = MapleTree("SampleData.mpl", createBasaFile=True)
865
- dataString = "This is a\nmulti-lined data."
866
- mapleTree.saveNotes(dataString, "FOO", "BAR", save=True)
867
- ```
868
-
869
-     This code creates a new file contains the following contents:
870
-
871
- ```text
872
- MAPLE
873
-
874
- H FOO
875
- H *NOTES BAR
876
- NTE This is a
877
- NTE multi-lined data.
878
- E
879
- E
880
-
881
- EOF
882
- ```
883
-
884
- ### `readNotes()`
885
-
886
-     `v2.2.0` or newer
887
-
888
- ```python
889
- def readNotes(
890
- *headers: str
891
- ) -> list[str]
892
- ```
893
-
894
- |Property|Required|Value|
895
- |--------|--------|-----|
896
- |**`headers`**|\*|Target headers|
897
-
898
-     Read note block value which specified by the `headers` and return as a string list.
899
-
900
- Sample data: `SampleData.mpl`
901
-
902
- ```text
903
- MAPLE
904
-
905
- H FOO
906
- H *NOTES BAR
907
- NTE This is a
908
- NTE multi-lined data.
909
- E
910
- E
911
-
912
- EOF
913
- ```
914
-
915
- E.g.:
916
-
917
- ```python
918
- from maplex import MapleTree
919
-
920
- mapleFile = MapleTree("SampleData.mpl")
921
- stringList = mapleFile.readNotes("FOO", "BAR")
922
-
923
- print(stringList)
924
- # Outputs "['This is a', 'multi-lined data.']"
925
- ```
926
-
927
- ### `readNote()`
928
-
929
-     `v2.2.0` or newer
930
-
931
- ```python
932
- def readNote(
933
- *headers: str
934
- ) -> str
935
- ```
936
-
937
- |Property|Required|Value|
938
- |--------|--------|-----|
939
- |**`headers`**|\*|Target headers|
940
-
941
-     Read note block value which specified by the `headers` and return as a string.
942
-
943
- Sample data: `SampleData.mpl`
944
-
945
- ```text
946
- MAPLE
947
-
948
- H FOO
949
- H *NOTES BAR
950
- NTE This is a
951
- NTE multi-lined data.
952
- E
953
- E
954
-
955
- EOF
956
- ```
957
-
958
- E.g.:
959
-
960
- ```python
961
- from maplex import MapleTree
962
-
963
- mapleFile = MapleTree("SampleData.mpl")
964
- dataString = mapleFile.readNote("FOO", "BAR")
965
-
966
- print(dataString)
967
- # Outputs "This is a
968
- # multi-lined data"
969
- ```
970
-
971
- ### `deleteNotes()`
972
-
973
-     `v2.2.0` or newer
974
-
975
- ```python
976
- def deleteNotes(
977
- *headers: str
978
- ) -> bool
979
- ```
980
-
981
- |Property|Required|Value|
982
- |--------|--------|-----|
983
- |**`headers`**|\*|Target headers|
984
- |**`kwargs`**||Keyword args|
985
-
986
-     Delete note block which specified by the `headers` and return `True` if it success. Set `save=True` to save the changes (Default: `save=False`)
987
-
988
- Sample data: `SampleData.mpl`
989
-
990
- ```text
991
- MAPLE
992
-
993
- H FOO
994
- H *NOTES BAR
995
- NTE This is a
996
- NTE multi-lined data.
997
- E
998
- E
999
-
1000
- EOF
1001
- ```
1002
-
1003
- E.g.:
1004
-
1005
- ```python
1006
- from maplex import MapleTree
1007
-
1008
- mapleFile = MapleTree("SampleData.mpl")
1009
- stringList = mapleFile.deleteNotes("FOO", "BAR", save=True)
1010
- ```
1011
-
1012
-     This code changes the file data like:
1013
-
1014
- ```text
1015
- MAPLE
1016
-
1017
- H FOO
1018
- E
1019
-
1020
- EOF
1021
- ```
1022
-
1023
- ### `changeEncryptionKey()`
1024
-
1025
-     `v2.2.0` or newer
1026
-
1027
- ```python
1028
- def changeEncryptionKey(
1029
- newKey: bytes,
1030
- save: bool = False
1031
- ) -> None
1032
- ```
1033
-
1034
- |Property|Required|Value|
1035
- |--------|--------|-----|
1036
- |**`newKey`**|\*|New encryption key|
1037
- |**`save`**||Save to file flag|
1038
-
1039
-     Changing file encryption key. If `save=True`, encrypt the buffer data with new key and save to the file.
1040
-
1041
- :warning: **The key must be 32 url-safe base64-encoded bytes**
1042
-
1043
711
  ## Logger Class
1044
712
 
1045
713
      Logger is a logging object for Python applications. It outputs application logs to log files and to standard output.
@@ -1122,9 +790,8 @@ def ShowError(
1122
790
 
1123
791
  - You can configure log settings with `config.mpl`.
1124
792
  - If `config.mpl` does not exist, the instance auto-generates the file.
1125
- - Instance uses the parameter values to auto-generate configuration file, or using default value if it was not specified.
1126
793
 
1127
- Auto-generated `config.mpl` (parameters not specified):
794
+ Auto-generated `config.mpl`:
1128
795
 
1129
796
  ```text
1130
797
  MAPLE
@@ -1171,10 +838,6 @@ EOF
1171
838
 
1172
839
      This occurs when the data is not found in the file.
1173
840
 
1174
- ### `MapleEncryptionNotEnabledException(MapleException)`
1175
-
1176
-     This occurs when try to encrypt maple data, but the encryption flag is `False`.
1177
-
1178
841
  ### `class MapleHeaderNotFoundException(MapleDataNotFoundException)`
1179
842
 
1180
843
      This occurs when the header (specified by the user) is not found in the data.
@@ -1257,12 +920,12 @@ EOF
1257
920
  |`Reversed`|\\033\[7m|Reversed colors|
1258
921
  |`Reset`|\\033\[0m|Reset formatting|
1259
922
 
1260
- ## Install MapleX
923
+ ## Install maplex :inbox_tray:
1261
924
 
1262
925
  ### From PyPI
1263
926
 
1264
927
  ```bash
1265
- [python[3] -m] pip install MapleX [--break-system-packages]
928
+ [python[3] -m] pip install maplex [--break-system-packages]
1266
929
  ```
1267
930
 
1268
931
  ### Manual Installation