MapleX 2.2.0__tar.gz → 2.2.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.
@@ -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,3 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: MapleX
3
+ Version: 2.2.0a1
4
+ Summary: MapleX: A Python library for Maple file format operations, with logging 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
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: cryptography>=46.0.3
19
+ Requires-Dist: pydantic>=2.12.5
20
+ Dynamic: license-file
21
+
1
22
  # :maple_leaf: MapleX :deciduous_tree:
2
23
 
3
24
      MapleX is a tool set for Maple file format operations, with logging and console color utilities for Python applications.
@@ -5,18 +26,9 @@
5
26
      ***You can install the package from pip with the following command.***
6
27
 
7
28
  ```bash
8
- pip install MapleX
29
+ pip install maplex
9
30
  ```
10
31
 
11
- ## Table of Contents
12
-
13
- > - [Maple File](#maple-file)
14
- > - [MapleTree Class](#mapletree-class)
15
- > - [Logger Class](#logger-class)
16
- > - [Exceptions](#exceptions)
17
- > - [Console Colors](#console-colors)
18
- > - [Install MapleX](#install-maplex)
19
-
20
32
  ## Maple File
21
33
 
22
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.
@@ -58,15 +70,15 @@ H Data Headers
58
70
  H Sub Data Header
59
71
  Tags Propaties
60
72
  # You can use the same tag in the child header,
61
- # which is already used in the parents' header
73
+ # which is already used in the parent's header
62
74
  E
63
75
  E
64
76
  H *NOTES NOTES_HEADER
65
77
  # Note's header
66
78
  NTE {strimg}
67
79
  NTE ...
68
- # Notes' main strings for the multi-line data
69
- # COMMENTS IN THE "*NOTES" BLOCK WILL BE DELETED WHEN SAVING!
80
+ # Note's main strings for the multi-line data
81
+ # COMMENTS IN THE "*NOTES" BLOCK WILL BE DELETED WHEN SAVE VALUE!
70
82
  E
71
83
  H #*
72
84
  This is a comment block.
@@ -141,7 +153,7 @@ EOF
141
153
  `v2.2.0` or newer
142
154
 
143
155
  - You can save multi-lined data inside `H *NOTES` block.
144
- - You must specify the header when you save the notes value.
156
+ - You must specify the header when you save notes value.
145
157
 
146
158
  E.g.:
147
159
 
@@ -302,8 +314,6 @@ EOF
302
314
      If `encrypt=True`, the instance decrypts data when it is read, and encrypts data when it is saved.
303
315
      You need to specify the byte key when you use encryption, and the file must be encrypted.
304
316
 
305
- :warning: **The key must be 32 url-safe base64-encoded bytes**
306
-
307
317
  ```python
308
318
  mapleFile = MapleTree("FileName.mpl", encrypt=True, key=key)
309
319
  ```
@@ -375,32 +385,7 @@ def saveTagLine(
375
385
  |**`willSave`**|\*|Save to file flag|
376
386
  |**`headers`**||Target headers|
377
387
 
378
-     Outdated from `v2.2.0`
379
-
380
- ### `saveValue()`
381
-
382
-     `v2.2.0` or newer
383
-
384
- ```python
385
- def saveValue(
386
- tag: str,
387
- valueString: any,
388
- *headers: str,
389
- **kwargs
390
- ) -> bool
391
- ```
392
-
393
- |Property|Required|Value|
394
- |--------|--------|-----|
395
- |**`tag`**|\*|Target tag|
396
- |**`value`**|\*|Value to save|
397
- |**`headers`**||Target headers|
398
- |**`kwargs`**||Keyword arguments|
399
-
400
-     `saveValue` saves a value with a tag in a header block specified by the parameter.
401
-
402
- - Set `save=True` to save changes to the file.
403
- - Default: `save=False`
388
+     `saveTagLine` saves a value with a tag in a header block specified by the parameter.
404
389
 
405
390
  E.g.:
406
391
 
@@ -408,7 +393,7 @@ E.g.:
408
393
  from maplex import MapleTree
409
394
 
410
395
  mapleFile = MapleTree("SampleData.mpl", createBaseFile=True)
411
- mapleFile.saveTagLine("TAG", "VALUE", "FOO", save=True)
396
+ mapleFile.saveTagLine("TAG", "VALUE", True, "FOO")
412
397
 
413
398
  ```
414
399
 
@@ -424,12 +409,12 @@ EOF
424
409
 
425
410
  #### Update a Buffer Content
426
411
 
427
-     If `save=False` (or not specified), the buffer content will be updated, but no update on physical file content.
412
+     If `willSave=False`, the buffer content will be updated, but no update on physical file content.
428
413
 
429
414
  E.g.:
430
415
 
431
416
  ```python
432
- mapleFile.saveTagLine("TAG", "NEW VALUE", "FOO")
417
+ mapleFile.saveTagLine("TAG", "NEW VALUE", False, "FOO")
433
418
  ```
434
419
 
435
420
      This code changes the contents on buffer like:
@@ -454,10 +439,10 @@ EOF
454
439
 
455
440
  #### Update and Save Changes
456
441
 
457
-     If `save=True`, all the changes to the buffer will be saved.
442
+     If `willSave=True`, all the changes to the buffer will be saved.
458
443
 
459
444
  ```python
460
- mapleFile.saveTagLine("BAR", "ANOTHER VALUE", "FOO", save=True)
445
+ mapleFile.saveTagLine("BAR", "ANOTHER VALUE", True, "FOO")
461
446
  ```
462
447
 
463
448
      This code changes the contents in the file like:
@@ -476,10 +461,10 @@ EOF
476
461
      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.
477
462
 
478
463
  ```python
479
- mapleFile.saveTagLine("TAZ", "NEW HEADER AND TAG", "NEW_HEADER")
464
+ mapleFile.saveTagLine("TAZ", "NEW HEADER AND TAG", False, "NEW_HEADER")
480
465
  ```
481
466
 
482
-     This code will change the buffer data like:
467
+     This code will change the data like:
483
468
 
484
469
  ```text
485
470
  MAPLE
@@ -493,47 +478,48 @@ E
493
478
  EOF
494
479
  ```
495
480
 
496
- ### `deleteTag()`
481
+ ### `saveValue()`
482
+
483
+     `v2.2.0` or newer
497
484
 
498
485
  ```python
499
- def deleteTag(
500
- delTag: str,
501
- willSave: bool = False,
502
- *headers: str
486
+ def saveValue(
487
+ tag: str,
488
+ valueString: any,
489
+ *headers: str,
490
+ **kwargs
503
491
  ) -> bool
504
492
  ```
505
493
 
506
494
  |Property|Required|Value|
507
495
  |--------|--------|-----|
508
- |**`delTag`**|\*|Tag to delete|
509
- |**`willSave`**||Save to file flag|
496
+ |**`tag`**|\*|Tag to delete|
497
+ |**`value`**|\*|Value to save|
510
498
  |**`headers`**||Target headers|
499
+ |**`kwargs`**||Keyword arguments|
511
500
 
512
-     Outdated from `v2.2.0`
513
-
514
- ### `deleteValue()`
501
+ - Same as `saveTagLine()`
502
+ - Set `save=True` to save changes to the file.
503
+ - Default: `save=False`
515
504
 
516
-     `v2.2.0` or newer
505
+ ### `deleteTag()`
517
506
 
518
507
  ```python
519
- def deleteValue(
508
+ def deleteTag(
520
509
  delTag: str,
521
- *headers: str,
522
- **kwargs
510
+ willSave: bool = False,
511
+ *headers: str
523
512
  ) -> bool
524
513
  ```
525
514
 
526
515
  |Property|Required|Value|
527
516
  |--------|--------|-----|
528
517
  |**`delTag`**|\*|Tag to delete|
518
+ |**`willSave`**||Save to file flag|
529
519
  |**`headers`**||Target headers|
530
- |**`kwargs`**||Keyword arguments|
531
520
 
532
521
      Delete a tag and its value.
533
522
 
534
- - Set `save=True` to save changes to the file.
535
- - Default: `save=False`
536
-
537
523
  Sample data: `SampleData.mpl`
538
524
 
539
525
  ```text
@@ -553,7 +539,7 @@ E.g.:
553
539
  from maplex import MapleTree
554
540
 
555
541
  mapleFile = MapleTree("SampleData.mpl")
556
- mapleFile.deleteTag("BAR", "FOO", save=True)
542
+ mapleFile.deleteTag("BAR", True, "FOO")
557
543
  ```
558
544
 
559
545
      The file data will be changed like:
@@ -568,6 +554,28 @@ E
568
554
  EOF
569
555
  ```
570
556
 
557
+ ### `deleteValue()`
558
+
559
+     `v2.2.0` or newer
560
+
561
+ ```python
562
+ def deleteValue(
563
+ delTag: str,
564
+ *headers: str,
565
+ **kwargs
566
+ ) -> bool
567
+ ```
568
+
569
+ |Property|Required|Value|
570
+ |--------|--------|-----|
571
+ |**`delTag`**|\*|Tag to delete|
572
+ |**`headers`**||Target headers|
573
+ |**`kwargs`**||Keyword arguments|
574
+
575
+ - Same as `deleteTag()`
576
+ - Set `save=True` to save changes to the file.
577
+ - Default: `save=False`
578
+
571
579
  ### `getTagValueDict()`
572
580
 
573
581
  ```python
@@ -662,31 +670,8 @@ def deleteHeader(
662
670
  |**`willSave`**||Save to file flag|
663
671
  |**`Headers`**||Target headers|
664
672
 
665
-     Outdated from `v2.2.0`
666
-
667
- ### `removeHeader()`
668
-
669
-     `v2.2.0` or newer
670
-
671
- ```python
672
- def removeHeader(
673
- delHead: str,
674
- *headers: str,
675
- **kwargs
676
- ) -> bool
677
- ```
678
-
679
- |Property|Required|Value|
680
- |--------|--------|-----|
681
- |**`delHead`**|\*|Deleting header|
682
- |**`headers`**||Target headers|
683
- |**`kwargs`**||Keyword arguments|
684
-
685
673
      This deletes an entire header block and its associated data, including child blocks.
686
674
 
687
- - Set `save=True` for saving data to the file.
688
- - Default: `save=False`
689
-
690
675
  Sample data: `SampleData.mpl`
691
676
 
692
677
  ```text
@@ -711,7 +696,7 @@ E.g.:
711
696
  from maplex import MapleTree
712
697
 
713
698
  mapleTree = MapleTree("SampleData.mpl")
714
- mapleTree.deleteHeader("FOO", save=True)
699
+ mapleTree.deleteHeader("FOO", True)
715
700
  ```
716
701
 
717
702
      This code changes the data like:
@@ -726,6 +711,28 @@ E
726
711
  EOF
727
712
  ```
728
713
 
714
+ ### `removeHeader()`
715
+
716
+     `v2.2.0` or newer
717
+
718
+ ```python
719
+ def removeHeader(
720
+ delHead: str,
721
+ *headers: str,
722
+ **kwargs
723
+ ) -> bool
724
+ ```
725
+
726
+ |Property|Required|Value|
727
+ |--------|--------|-----|
728
+ |**`delHead`**|\*|Deleting header|
729
+ |**`headers`**||Target headers|
730
+ |**`kwargs`**||Keyword arguments|
731
+
732
+ - Same as `deleteHeader()`
733
+ - Set `save=True` for save data to the file.
734
+ - Default: `save=False`
735
+
729
736
  ### `getHeaders()`
730
737
 
731
738
  ```python
@@ -788,7 +795,7 @@ def saveNotes(
788
795
  |**`headers`**|\*|Target headers|
789
796
  |**`kwargs`**||Keyword arguments|
790
797
 
791
-     The function saves a string list as a special notes block value. Set `save=True` to save the changes (Default: `save=False`)
798
+     The function saves string list as a special notes block value. Set `save=True` to save the changes (Default: `save=False`)
792
799
 
793
800
  E.g.:
794
801
 
@@ -800,7 +807,7 @@ stringList = ["Hello", "there!"]
800
807
  mapleTree.saveNotes(stringList, "FOO", "BAR", save=True)
801
808
  ```
802
809
 
803
-     This code creates a new file that contains the following contents:
810
+     This code creates a new file contains the following contents:
804
811
 
805
812
  ```text
806
813
  MAPLE
@@ -833,7 +840,7 @@ def saveNote(
833
840
  |**`headers`**|\*|Target headers|
834
841
  |**`kwargs`**||Keyword arguments|
835
842
 
836
-     The function saves a multi-lined string as a special notes block value. Set `save=True` to save the changes (Default: `save=False`)
843
+     The function saves multi-lined string as a special notes block value. Set `save=True` to save the changes (Default: `save=False`)
837
844
 
838
845
  E.g.:
839
846
 
@@ -845,7 +852,7 @@ dataString = "This is a\nmulti-lined data."
845
852
  mapleTree.saveNotes(dataString, "FOO", "BAR", save=True)
846
853
  ```
847
854
 
848
-     This code creates a new file that contains the following contents:
855
+     This code creates a new file contains the following contents:
849
856
 
850
857
  ```text
851
858
  MAPLE
@@ -874,7 +881,7 @@ def readNotes(
874
881
  |--------|--------|-----|
875
882
  |**`headers`**|\*|Target headers|
876
883
 
877
-     Read note block value, which is specified by the `headers`, and return as a string list.
884
+     Read note block value which specified by the `headers` and return as a string list.
878
885
 
879
886
  Sample data: `SampleData.mpl`
880
887
 
@@ -917,7 +924,7 @@ def readNote(
917
924
  |--------|--------|-----|
918
925
  |**`headers`**|\*|Target headers|
919
926
 
920
-     Read note block value, which specified by the `headers`, and return as a string.
927
+     Read note block value which specified by the `headers` and return as a string.
921
928
 
922
929
  Sample data: `SampleData.mpl`
923
930
 
@@ -944,7 +951,7 @@ dataString = mapleFile.readNote("FOO", "BAR")
944
951
 
945
952
  print(dataString)
946
953
  # Outputs "This is a
947
- # multi-lined data."
954
+ # multi-lined data"
948
955
  ```
949
956
 
950
957
  ### `deleteNotes()`
@@ -962,7 +969,7 @@ def deleteNotes(
962
969
  |**`headers`**|\*|Target headers|
963
970
  |**`kwargs`**||Keyword args|
964
971
 
965
-     Delete note block which specified by the `headers` and return `True` if it succeeds. Set `save=True` to save the changes (Default: `save=False`)
972
+     Delete note block which specified by the `headers` and return `True` if it success. Set `save=True` to save the changes (Default: `save=False`)
966
973
 
967
974
  Sample data: `SampleData.mpl`
968
975
 
@@ -999,26 +1006,6 @@ E
999
1006
  EOF
1000
1007
  ```
1001
1008
 
1002
- ### `changeEncryptionKey()`
1003
-
1004
-     `v2.2.0` or newer
1005
-
1006
- ```python
1007
- def changeEncryptionKey(
1008
- newKey: bytes,
1009
- save: bool = False
1010
- ) -> None
1011
- ```
1012
-
1013
- |Property|Required|Value|
1014
- |--------|--------|-----|
1015
- |**`newKey`**|\*|New encryption key|
1016
- |**`save`**||Save to file flag|
1017
-
1018
-     Changing file encryption key. If `save=True`, encrypt the buffer data with the new key and save to the file.
1019
-
1020
- :warning: **The key must be 32 url-safe base64-encoded bytes**
1021
-
1022
1009
  ## Logger Class
1023
1010
 
1024
1011
      Logger is a logging object for Python applications. It outputs application logs to log files and to standard output.
@@ -1051,7 +1038,7 @@ def changeEncryptionKey(
1051
1038
  from maplex import Logger
1052
1039
 
1053
1040
  logger = Logger("FunctionName")
1054
- logger.info("Hello there!")
1041
+ logger.Info("Hello there!")
1055
1042
  ```
1056
1043
 
1057
1044
  This outputs:
@@ -1101,9 +1088,8 @@ def ShowError(
1101
1088
 
1102
1089
  - You can configure log settings with `config.mpl`.
1103
1090
  - If `config.mpl` does not exist, the instance auto-generates the file.
1104
- - Instance uses the parameter values to auto-generate a configuration file, or uses the default value if it was not specified.
1105
1091
 
1106
- Auto-generated `config.mpl` (parameters not specified):
1092
+ Auto-generated `config.mpl`:
1107
1093
 
1108
1094
  ```text
1109
1095
  MAPLE
@@ -1125,8 +1111,8 @@ EOF
1125
1111
  |**`MAX`**|Log file max size (MB)|
1126
1112
  |**`OUT`**|Log file output path|
1127
1113
 
1128
- - To disable the log output, set the log level to `NONE`.
1129
- - You can use a `float` number for the file max size (E.g., `2.5` for `2.5MB`)
1114
+ - To disable the log output, set log level to `NONE`.
1115
+ - You can use a `float` number for the file max size (E.g. `2.5` for `2.5MB`)
1130
1116
 
1131
1117
  ## Exceptions
1132
1118
 
@@ -1136,11 +1122,11 @@ EOF
1136
1122
 
1137
1123
  ### `class MapleFileNotFoundException(MapleException)`
1138
1124
 
1139
-     This occurs when the file that was specified at the instance initialization was not found.
1125
+     This occurs when the file which specified at the instance initialization was not found.
1140
1126
 
1141
1127
  ### `class KeyEmptyException(MapleException)`
1142
1128
 
1143
-     This occurs when `encrypt=True` is used at the instance initialization, but the key for encryption is missing (`None` or empty).
1129
+     This occurs when `encrypt=True` at the instance initialization, but the key for encryption is missing (`None` or empty).
1144
1130
 
1145
1131
  ### `class MapleFileLockedException(MapleException)`
1146
1132
 
@@ -1150,10 +1136,6 @@ EOF
1150
1136
 
1151
1137
      This occurs when the data is not found in the file.
1152
1138
 
1153
- ### `MapleEncryptionNotEnabledException(MapleException)`
1154
-
1155
-     This occurs when trying to encrypt Maple data, but the encryption flag is `False`.
1156
-
1157
1139
  ### `class MapleHeaderNotFoundException(MapleDataNotFoundException)`
1158
1140
 
1159
1141
      This occurs when the header (specified by the user) is not found in the data.
@@ -1232,17 +1214,16 @@ EOF
1232
1214
  |Key|Value|Description|
1233
1215
  |---|-----|-----------|
1234
1216
  |`Bold`|\\033\[1m|Bold text|
1235
- |`Italic`|\\033\[3m|Italic text|
1236
1217
  |`Underline`|\\033\[4m|Underlined text|
1237
1218
  |`Reversed`|\\033\[7m|Reversed colors|
1238
1219
  |`Reset`|\\033\[0m|Reset formatting|
1239
1220
 
1240
- ## Install MapleX
1221
+ ## Install maplex :inbox_tray:
1241
1222
 
1242
1223
  ### From PyPI
1243
1224
 
1244
1225
  ```bash
1245
- [python[3] -m] pip install MapleX [--break-system-packages]
1226
+ [python[3] -m] pip install maplex [--break-system-packages]
1246
1227
  ```
1247
1228
 
1248
1229
  ### Manual Installation
@@ -1257,9 +1238,3 @@ EOF
1257
1238
  or
1258
1239
 
1259
1240
      Run `python[3] setup.py sdist bdist_wheel`
1260
-
1261
- ### Unit test
1262
-
1263
- ```bash
1264
- python[3] -m unittest discover -s tests
1265
- ```