MapleX 2.2.0b1__tar.gz → 2.2.0.dev2__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,8 +1,8 @@
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.dev2
4
+ Summary: MapleX: A Python library for Maple file format operations, with logging and console color utilities
5
+ Author: Ryuji Hazama
6
6
  Project-URL: PyPI, https://pypi.org/project/MapleX/
7
7
  Project-URL: Homepage, https://github.com/Ryuji-Hazama
8
8
  Project-URL: Repository, https://github.com/Ryuji-Hazama/MapleTree
@@ -26,18 +26,9 @@ Dynamic: license-file
26
26
      ***You can install the package from pip with the following command.***
27
27
 
28
28
  ```bash
29
- pip install MapleX
29
+ pip install maplex
30
30
  ```
31
31
 
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
32
  ## Maple File
42
33
 
43
34
      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 +73,11 @@ H Data Headers
82
73
  # which is already used in the parent's header
83
74
  E
84
75
  E
85
- H *NOTES NOTES_HEADER
76
+ H *NOTES
86
77
  # Note's header
87
78
  NTE {strimg}
88
79
  NTE ...
89
80
  # Note's main strings for the multi-line data
90
- # COMMENTS IN THE "*NOTES" BLOCK WILL BE DELETED WHEN SAVE VALUE!
91
81
  E
92
82
  H #*
93
83
  This is a comment block.
@@ -157,30 +147,9 @@ E
157
147
  EOF
158
148
  ```
159
149
 
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
150
  ### Comments
182
151
 
183
- `v2.1.0` or newer
152
+ `v2.1.0 or newer`
184
153
 
185
154
  #### Comment Line
186
155
 
@@ -323,8 +292,6 @@ EOF
323
292
      If `encrypt=True`, the instance decrypts data when it is read, and encrypts data when it is saved.
324
293
      You need to specify the byte key when you use encryption, and the file must be encrypted.
325
294
 
326
- :warning: **The key must be 32 url-safe base64-encoded bytes**
327
-
328
295
  ```python
329
296
  mapleFile = MapleTree("FileName.mpl", encrypt=True, key=key)
330
297
  ```
@@ -396,32 +363,7 @@ def saveTagLine(
396
363
  |**`willSave`**|\*|Save to file flag|
397
364
  |**`headers`**||Target headers|
398
365
 
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`
366
+     `saveTagLine` saves a value with a tag in a header block specified by the parameter.
425
367
 
426
368
  E.g.:
427
369
 
@@ -429,7 +371,7 @@ E.g.:
429
371
  from maplex import MapleTree
430
372
 
431
373
  mapleFile = MapleTree("SampleData.mpl", createBaseFile=True)
432
- mapleFile.saveTagLine("TAG", "VALUE", "FOO", save=True)
374
+ mapleFile.saveTagLine("TAG", "VALUE", True, "FOO")
433
375
 
434
376
  ```
435
377
 
@@ -445,12 +387,12 @@ EOF
445
387
 
446
388
  #### Update a Buffer Content
447
389
 
448
-     If `save=False` (or not specified), the buffer content will be updated, but no update on physical file content.
390
+     If `willSave=False`, the buffer content will be updated, but no update on physical file content.
449
391
 
450
392
  E.g.:
451
393
 
452
394
  ```python
453
- mapleFile.saveTagLine("TAG", "NEW VALUE", "FOO")
395
+ mapleFile.saveTagLine("TAG", "NEW VALUE", False, "FOO")
454
396
  ```
455
397
 
456
398
      This code changes the contents on buffer like:
@@ -475,10 +417,10 @@ EOF
475
417
 
476
418
  #### Update and Save Changes
477
419
 
478
-     If `save=True`, all the changes to the buffer will be saved.
420
+     If `willSave=True`, all the changes to the buffer will be saved.
479
421
 
480
422
  ```python
481
- mapleFile.saveTagLine("BAR", "ANOTHER VALUE", "FOO", save=True)
423
+ mapleFile.saveTagLine("BAR", "ANOTHER VALUE", True, "FOO")
482
424
  ```
483
425
 
484
426
      This code changes the contents in the file like:
@@ -497,10 +439,10 @@ EOF
497
439
      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
440
 
499
441
  ```python
500
- mapleFile.saveTagLine("TAZ", "NEW HEADER AND TAG", "NEW_HEADER")
442
+ mapleFile.saveTagLine("TAZ", "NEW HEADER AND TAG", False, "NEW_HEADER")
501
443
  ```
502
444
 
503
-     This code will change the buffer data like:
445
+     This code will change the data like:
504
446
 
505
447
  ```text
506
448
  MAPLE
@@ -530,31 +472,8 @@ def deleteTag(
530
472
  |**`willSave`**||Save to file flag|
531
473
  |**`headers`**||Target headers|
532
474
 
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
475
      Delete a tag and its value.
554
476
 
555
- - Set `save=True` to save changes to the file.
556
- - Default: `save=False`
557
-
558
477
  Sample data: `SampleData.mpl`
559
478
 
560
479
  ```text
@@ -574,7 +493,7 @@ E.g.:
574
493
  from maplex import MapleTree
575
494
 
576
495
  mapleFile = MapleTree("SampleData.mpl")
577
- mapleFile.deleteTag("BAR", "FOO", save=True)
496
+ mapleFile.deleteTag("BAR", True, "FOO")
578
497
  ```
579
498
 
580
499
      The file data will be changed like:
@@ -681,33 +600,10 @@ def deleteHeader(
681
600
  |--------|--------|-----|
682
601
  |**`delHead`**|\*|Deleting header|
683
602
  |**`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
603
  |**`headers`**||Target headers|
704
- |**`kwargs`**||Keyword arguments|
705
604
 
706
605
      This deletes an entire header block and its associated data, including child blocks.
707
606
 
708
- - Set `save=True` for save data to the file.
709
- - Default: `save=False`
710
-
711
607
  Sample data: `SampleData.mpl`
712
608
 
713
609
  ```text
@@ -732,7 +628,7 @@ E.g.:
732
628
  from maplex import MapleTree
733
629
 
734
630
  mapleTree = MapleTree("SampleData.mpl")
735
- mapleTree.deleteHeader("FOO", save=True)
631
+ mapleTree.deleteHeader("FOO", True)
736
632
  ```
737
633
 
738
634
      This code changes the data like:
@@ -791,255 +687,6 @@ print(headerList)
791
687
  # Outputs "['FOO', 'QUUX']"
792
688
  ```
793
689
 
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
690
  ## Logger Class
1044
691
 
1045
692
      Logger is a logging object for Python applications. It outputs application logs to log files and to standard output.
@@ -1122,9 +769,8 @@ def ShowError(
1122
769
 
1123
770
  - You can configure log settings with `config.mpl`.
1124
771
  - 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
772
 
1127
- Auto-generated `config.mpl` (parameters not specified):
773
+ Auto-generated `config.mpl`:
1128
774
 
1129
775
  ```text
1130
776
  MAPLE
@@ -1171,10 +817,6 @@ EOF
1171
817
 
1172
818
      This occurs when the data is not found in the file.
1173
819
 
1174
- ### `MapleEncryptionNotEnabledException(MapleException)`
1175
-
1176
-     This occurs when try to encrypt maple data, but the encryption flag is `False`.
1177
-
1178
820
  ### `class MapleHeaderNotFoundException(MapleDataNotFoundException)`
1179
821
 
1180
822
      This occurs when the header (specified by the user) is not found in the data.
@@ -1257,12 +899,12 @@ EOF
1257
899
  |`Reversed`|\\033\[7m|Reversed colors|
1258
900
  |`Reset`|\\033\[0m|Reset formatting|
1259
901
 
1260
- ## Install MapleX
902
+ ## Install maplex :inbox_tray:
1261
903
 
1262
904
  ### From PyPI
1263
905
 
1264
906
  ```bash
1265
- [python[3] -m] pip install MapleX [--break-system-packages]
907
+ [python[3] -m] pip install maplex [--break-system-packages]
1266
908
  ```
1267
909
 
1268
910
  ### Manual Installation