Changed the constant file with os.environ
Also doing some more testing and mucking around with the parsermaster
parent
a2452e72a6
commit
465bbe9c15
|
@ -1 +0,0 @@
|
|||
DEBUG = True
|
|
@ -25,5 +25,5 @@ VAR_MATCH = {
|
|||
r"\".+\"": Datatype.STRING,
|
||||
r"\d+\.\d{0,}": Datatype.FLOAT,
|
||||
r"\d+": Datatype.INTEGER,
|
||||
r".+": Datatype.NONE,
|
||||
# r".+": Datatype.NONE,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from constants import DEBUG
|
||||
import os
|
||||
|
||||
|
||||
def todo(msg: str = "Not implemented"):
|
||||
def inner(func):
|
||||
def inner2(*args, **kwargs):
|
||||
if DEBUG:
|
||||
if "PYNE_DEBUG" in os.environ:
|
||||
print(f"[{func.__name__}] TODO: {msg}")
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
@ -15,7 +15,7 @@ def todo(msg: str = "Not implemented"):
|
|||
|
||||
def wip(func):
|
||||
def inner(*args, **kwargs):
|
||||
if DEBUG:
|
||||
if "PYNE_DEBUG" in os.environ:
|
||||
print(
|
||||
f"Called work in progress function {func.__name__}. Functionality may change in the future."
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ def wip(func):
|
|||
def deprecated(func):
|
||||
@functools.wraps(func)
|
||||
def inner(*args, **kwargs):
|
||||
if DEBUG:
|
||||
if "PYNE_DEBUG" in os.environ:
|
||||
print(
|
||||
f"\x1b[31mWarning:\x1b[0m The function {inner.__name__} is deprecated."
|
||||
)
|
||||
|
|
9
pyne.py
9
pyne.py
|
@ -24,7 +24,7 @@ class Pyne:
|
|||
def parse(self) -> list[PyneObject]:
|
||||
objects: list[PyneObject] = []
|
||||
with open(self.path) as f:
|
||||
for line in f.readlines():
|
||||
for row, line in enumerate(f.readlines(), 1):
|
||||
for var in datatypes.VAR_MATCH:
|
||||
regex = re.compile(var)
|
||||
res = regex.match(line)
|
||||
|
@ -35,6 +35,9 @@ class Pyne:
|
|||
)
|
||||
)
|
||||
break
|
||||
continue
|
||||
else:
|
||||
raise ParserError(f"[{self.path}:{row}] Token {line} not found.")
|
||||
if len(objects) == 0:
|
||||
objects.append(datatypes.NONE_TYPE)
|
||||
return objects
|
||||
|
@ -55,10 +58,12 @@ def main() -> int:
|
|||
args = parser.parse_args()
|
||||
print(args)
|
||||
pyne = Pyne(args.file[0], None)
|
||||
|
||||
try:
|
||||
for obj in pyne.parse():
|
||||
print(obj)
|
||||
return 0
|
||||
except ParserError as e:
|
||||
print(f"Found invalid token: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue