MapleX 2.2.0a1__tar.gz → 2.2.0a2__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.0a1 → maplex-2.2.0a2}/LICENSE +1 -1
- {maplex-2.2.0a1/src/MapleX.egg-info → maplex-2.2.0a2}/PKG-INFO +2 -2
- {maplex-2.2.0a1 → maplex-2.2.0a2}/pyproject.toml +12 -2
- {maplex-2.2.0a1 → maplex-2.2.0a2/src/MapleX.egg-info}/PKG-INFO +2 -2
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/maplex/__init__.py +1 -1
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/maplex/mapleLogger.py +20 -7
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/maplex/mapleTreeEditor.py +36 -18
- {maplex-2.2.0a1 → maplex-2.2.0a2}/MANIFEST.in +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/README.md +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/setup.cfg +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/MapleX.egg-info/SOURCES.txt +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/MapleX.egg-info/dependency_links.txt +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/MapleX.egg-info/requires.txt +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/MapleX.egg-info/top_level.txt +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/maplex/mapleColors.py +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/maplex/mapleExceptions.py +0 -0
- {maplex-2.2.0a1 → maplex-2.2.0a2}/src/maplex/utils.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MapleX
|
|
3
|
-
Version: 2.2.
|
|
4
|
-
Summary: MapleX
|
|
3
|
+
Version: 2.2.0a2
|
|
4
|
+
Summary: # MapleX
|
|
5
5
|
Author: Ryuji Hazama
|
|
6
6
|
Project-URL: PyPI, https://pypi.org/project/MapleX/
|
|
7
7
|
Project-URL: Homepage, https://github.com/Ryuji-Hazama
|
|
@@ -4,9 +4,19 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "MapleX"
|
|
7
|
-
version = "2.2.
|
|
7
|
+
version = "2.2.0a2"
|
|
8
8
|
description = """
|
|
9
|
-
MapleX
|
|
9
|
+
# MapleX
|
|
10
|
+
|
|
11
|
+
A Python library for Maple file format operations, with logging and console color utilities
|
|
12
|
+
|
|
13
|
+
## MapleTree
|
|
14
|
+
|
|
15
|
+
MapleTree is a powerful Python library designed for reading, editing, and managing Maple file formats. It provides a simple and intuitive interface for developers to work with Maple files, making it easier to manipulate data stored in this format.
|
|
16
|
+
|
|
17
|
+
## Logger
|
|
18
|
+
|
|
19
|
+
Logger is a versatile logging utility that allows developers to log messages with different severity levels (INFO, WARNING, ERROR, DEBUG) and customize the output format. It supports logging to both console and file, making it easy to track application behavior and diagnose issues.
|
|
10
20
|
"""
|
|
11
21
|
readme = "README.md"
|
|
12
22
|
license-files = ["LICENSE"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MapleX
|
|
3
|
-
Version: 2.2.
|
|
4
|
-
Summary: MapleX
|
|
3
|
+
Version: 2.2.0a2
|
|
4
|
+
Summary: # MapleX
|
|
5
5
|
Author: Ryuji Hazama
|
|
6
6
|
Project-URL: PyPI, https://pypi.org/project/MapleX/
|
|
7
7
|
Project-URL: Homepage, https://github.com/Ryuji-Hazama
|
|
@@ -31,16 +31,14 @@ class Logger:
|
|
|
31
31
|
self.pid = os.getpid()
|
|
32
32
|
self.consoleColors = ConsoleColors()
|
|
33
33
|
|
|
34
|
-
# Check the OS (Windows cannot change the console color)
|
|
34
|
+
# Check the OS (Windows 10 or older cannot change the console color)
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if systemId.startswith("win"):
|
|
36
|
+
if hasattr(sys, "getwindowsversion") and sys.getwindowsversion().build < 22000:
|
|
39
37
|
|
|
40
38
|
self.consoleColors = ConsoleColors(Black="", Red="", Green="", Yellow="", Blue="", Magenta="", LightBlue="", White="",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
bgBlack="", bgRed="", bgGreen="", bgYellow="", bgBlue="", bgMagenta="", bgLightBlue="", bgWhite="",
|
|
40
|
+
bBlack="", bRed="", bGreen="", bYellow="", bBlue="", bMagenta="", bLightBlue="", bWhite="",
|
|
41
|
+
Bold="", Underline="", Reversed="", Reset="")
|
|
44
42
|
|
|
45
43
|
#
|
|
46
44
|
############################
|
|
@@ -220,6 +218,7 @@ class Logger:
|
|
|
220
218
|
|
|
221
219
|
# Console colors
|
|
222
220
|
|
|
221
|
+
Black = self.consoleColors.Black
|
|
223
222
|
bBlack = self.consoleColors.bBlack
|
|
224
223
|
Red = self.consoleColors.Red
|
|
225
224
|
bRed = self.consoleColors.bRed
|
|
@@ -264,6 +263,10 @@ class Logger:
|
|
|
264
263
|
|
|
265
264
|
col = Bold + Red
|
|
266
265
|
|
|
266
|
+
case self.LogLevel.NONE:
|
|
267
|
+
|
|
268
|
+
col = Bold + Black
|
|
269
|
+
|
|
267
270
|
case _:
|
|
268
271
|
|
|
269
272
|
col = ""
|
|
@@ -364,6 +367,16 @@ class Logger:
|
|
|
364
367
|
|
|
365
368
|
self.logWriter(self.LogLevel.FATAL, object, callerDepth=2)
|
|
366
369
|
|
|
370
|
+
#
|
|
371
|
+
################################
|
|
372
|
+
# None
|
|
373
|
+
|
|
374
|
+
def log(self, object: any):
|
|
375
|
+
|
|
376
|
+
'''None log'''
|
|
377
|
+
|
|
378
|
+
self.logWriter(self.LogLevel.NONE, object, callerDepth=2)
|
|
379
|
+
|
|
367
380
|
#
|
|
368
381
|
################################
|
|
369
382
|
# Error messages
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os.path as path
|
|
2
2
|
from cryptography.fernet import Fernet
|
|
3
3
|
from . import mapleExceptions as mExc
|
|
4
|
+
import warnings
|
|
4
5
|
|
|
5
6
|
class MapleTree:
|
|
6
7
|
|
|
@@ -442,6 +443,11 @@ class MapleTree:
|
|
|
442
443
|
headerIndex = headers.index("#*")
|
|
443
444
|
raise mExc.MapleSyntaxException(f"Cannot search inside comment block: Comment block header \"#*\" found in search headers list at index {headerIndex}")
|
|
444
445
|
|
|
446
|
+
if len(headers) == 0:
|
|
447
|
+
|
|
448
|
+
# Return root block (No headers provided)
|
|
449
|
+
return True, self.eofIndex, self.mapleIndex
|
|
450
|
+
|
|
445
451
|
# Find header
|
|
446
452
|
|
|
447
453
|
try:
|
|
@@ -484,7 +490,7 @@ class MapleTree:
|
|
|
484
490
|
|
|
485
491
|
raise mExc.InvalidMapleFileFormatException(self.fileName)
|
|
486
492
|
|
|
487
|
-
|
|
493
|
+
return False, lineIndex, ind
|
|
488
494
|
|
|
489
495
|
lineIndex += 1
|
|
490
496
|
|
|
@@ -573,10 +579,13 @@ class MapleTree:
|
|
|
573
579
|
|
|
574
580
|
def saveTagLine(self, tag: str, valueStr: str, willSave: bool, *headers: str) -> None:
|
|
575
581
|
|
|
576
|
-
"""
|
|
582
|
+
"""(Out of support)\n
|
|
583
|
+
Save valueStr to tag in headers.\n
|
|
577
584
|
If the headers does not exist, create new headers.\n
|
|
578
585
|
Overwrte file if sillSave == True"""
|
|
579
586
|
|
|
587
|
+
warnings.warn("saveTagLine is out of support. Use saveValue instead.", DeprecationWarning)
|
|
588
|
+
|
|
580
589
|
# Find headers
|
|
581
590
|
|
|
582
591
|
isHead, eInd, headInd = self._findHeader(headers)
|
|
@@ -656,11 +665,13 @@ class MapleTree:
|
|
|
656
665
|
|
|
657
666
|
def deleteTag(self, delTag: str, willSave: bool = False, *headers: str) -> bool:
|
|
658
667
|
|
|
659
|
-
"""
|
|
668
|
+
"""(Out of support)\n
|
|
660
669
|
Delete tag(delTag) from header(headers) in Maple file(delFile)\n
|
|
661
670
|
Return True if it success.
|
|
662
671
|
"""
|
|
663
672
|
|
|
673
|
+
warnings.warn("deleteTag is out of support. Use deleteValue instead.", DeprecationWarning)
|
|
674
|
+
|
|
664
675
|
try:
|
|
665
676
|
|
|
666
677
|
gotHeader, eInd, headInd = self._findHeader(headers)
|
|
@@ -830,22 +841,23 @@ class MapleTree:
|
|
|
830
841
|
raise mExc.MapleSyntaxException("No headers provided to save notes")
|
|
831
842
|
|
|
832
843
|
willSave = kwargs.get('save', False)
|
|
833
|
-
|
|
834
|
-
|
|
844
|
+
headersList = list(headers)
|
|
845
|
+
headersLastIndex = len(headersList) - 1
|
|
846
|
+
headersList[headersLastIndex] = f"*NOTES {headersList[headersLastIndex]}"
|
|
835
847
|
|
|
836
848
|
try:
|
|
837
849
|
|
|
838
|
-
isFound, eInd, headInd = self._findHeader(
|
|
850
|
+
isFound, eInd, headInd = self._findHeader(headersList)
|
|
839
851
|
|
|
840
852
|
if not isFound:
|
|
841
853
|
|
|
842
854
|
# Create new headers
|
|
843
855
|
|
|
844
|
-
headLen = len(
|
|
856
|
+
headLen = len(headersList)
|
|
845
857
|
|
|
846
858
|
while headInd < headLen:
|
|
847
859
|
|
|
848
|
-
self.fileStream.insert(eInd, f"H {
|
|
860
|
+
self.fileStream.insert(eInd, f"H {headersList[headInd]}\n")
|
|
849
861
|
eInd += 1
|
|
850
862
|
self.fileStream.insert(eInd, "E\n")
|
|
851
863
|
headInd += 1
|
|
@@ -908,16 +920,17 @@ class MapleTree:
|
|
|
908
920
|
|
|
909
921
|
raise mExc.MapleSyntaxException("No headers provided to read notes")
|
|
910
922
|
|
|
911
|
-
|
|
912
|
-
|
|
923
|
+
headersList = list(headers)
|
|
924
|
+
headersLastIndex = len(headersList) - 1
|
|
925
|
+
headersList[headersLastIndex] = f"*NOTES {headersList[headersLastIndex]}"
|
|
913
926
|
|
|
914
927
|
try:
|
|
915
928
|
|
|
916
|
-
isFound, eInd, headInd = self._findHeader(
|
|
929
|
+
isFound, eInd, headInd = self._findHeader(headersList)
|
|
917
930
|
|
|
918
931
|
if not isFound:
|
|
919
932
|
|
|
920
|
-
self.__headerNotFoundExceptionHandler(headInd,
|
|
933
|
+
self.__headerNotFoundExceptionHandler(headInd, headersList)
|
|
921
934
|
|
|
922
935
|
noteValues = []
|
|
923
936
|
|
|
@@ -979,17 +992,18 @@ class MapleTree:
|
|
|
979
992
|
Return True if it success.
|
|
980
993
|
"""
|
|
981
994
|
|
|
982
|
-
willSave = kwargs.get('save', False)
|
|
983
|
-
|
|
984
995
|
if len(headers) == 0:
|
|
985
996
|
|
|
986
997
|
raise mExc.MapleSyntaxException("No headers provided to delete notes")
|
|
987
|
-
|
|
988
|
-
headersLastIndex = len(headers) - 1
|
|
989
|
-
headers[headersLastIndex] = f"*NOTES {headers[headersLastIndex]}"
|
|
990
998
|
|
|
991
|
-
|
|
999
|
+
willSave = kwargs.get('save', False)
|
|
1000
|
+
|
|
1001
|
+
headersList = list(headers)
|
|
1002
|
+
headersLastIndex = len(headersList) - 1
|
|
1003
|
+
headersList[headersLastIndex] = f"*NOTES {headersList[headersLastIndex]}"
|
|
992
1004
|
|
|
1005
|
+
return self.deleteHeader(headersList[-1], willSave, *headersList[:-1])
|
|
1006
|
+
|
|
993
1007
|
#
|
|
994
1008
|
#############################
|
|
995
1009
|
# Delete header (easier to write)
|
|
@@ -1010,6 +1024,10 @@ class MapleTree:
|
|
|
1010
1024
|
|
|
1011
1025
|
def deleteHeader(self, delHead: str, willSave: bool = False, *Headers: str) -> bool:
|
|
1012
1026
|
|
|
1027
|
+
"""(Out of support)\n"""
|
|
1028
|
+
|
|
1029
|
+
warnings.warn("deleteHeader is out of support. Use removeHeader instead.", DeprecationWarning)
|
|
1030
|
+
|
|
1013
1031
|
try:
|
|
1014
1032
|
|
|
1015
1033
|
gotHeader, eInd, headInd = self._findHeader(Headers)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|