Moved the tools to normal modules to use with the error_mngr
This commit is contained in:
parent
adba59fa8e
commit
6460ac1766
|
|
@ -9,6 +9,7 @@ import re
|
|||
###############################################################################
|
||||
# Paths
|
||||
########################################
|
||||
import rich
|
||||
|
||||
|
||||
def __base():
|
||||
|
|
@ -17,7 +18,7 @@ def __base():
|
|||
:return: Path of the main module
|
||||
:rtype: str
|
||||
"""
|
||||
return "../../src/bootstraparse/"
|
||||
return "."
|
||||
|
||||
|
||||
def __module_path(module_name):
|
||||
|
|
@ -28,15 +29,38 @@ def __module_path(module_name):
|
|||
:return: Path of the module
|
||||
:rtype: str
|
||||
"""
|
||||
return os.path.normpath(os.path.join(os.path.dirname(__file__), __base(), "modules", module_name))
|
||||
return os.path.normpath(os.path.join(os.path.dirname(__file__), __base(), module_name))
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Frame inspection
|
||||
########################################
|
||||
# Cursed frame inspection
|
||||
def __prev_stack(nb=0):
|
||||
"""
|
||||
Return the nth previous stack
|
||||
:return: Previous stack
|
||||
:rtype: inspect.Traceback
|
||||
"""
|
||||
for frame in inspect.stack()[1 + nb:]:
|
||||
return frame
|
||||
return inspect.getframeinfo(inspect.currentframe().f_back)
|
||||
|
||||
|
||||
def __GL():
|
||||
return inspect.getframeinfo(inspect.currentframe().f_back).lineno
|
||||
return __prev_stack().lineno
|
||||
|
||||
|
||||
def __GFu():
|
||||
return __prev_stack().function
|
||||
|
||||
|
||||
def __GFi():
|
||||
return __prev_stack().filename
|
||||
|
||||
|
||||
def __GLk():
|
||||
return f' File "{__prev_stack(2).filename}", line {max(__prev_stack(2).lineno, 1)}'.replace("\\", "/")
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
|
@ -4,7 +4,7 @@ import pyparsing
|
|||
import pytest
|
||||
|
||||
import bootstraparse.modules.syntax as sy
|
||||
from tools import __GL, __module_path, find_variables_in_file # , find_functions_in_file, find_classes_in_file
|
||||
from bootstraparse.modules.tools import __GL, __module_path, find_variables_in_file # , find_functions_in_file, find_classes_in_file
|
||||
|
||||
ptp = pytest.param
|
||||
__XF = pytest.mark.xfail
|
||||
|
|
|
|||
Loading…
Reference in New Issue