test (bool, optional): [if true, will not actually create files or folders]. Defaults to False.
"""
# TODO - put all these as regular vars on the lexer
tree._QUIET_MODE_BAK = tree.QUIET_MODE = quiet
tree.LABEL = label
CWD_b4 = os.getcwd()
sslog(f"{TREE_ICN} tree")
tree._TEST_MODE_BAK = tree.TEST_MODE = test
self.tree_string = tree_string.replace("\t", " ") # force tabs to 4 spaces
if tree.TEST_MODE:
sslog("TEST_MODE", "testmode is active. Changes will not be applied.", lvl='w')
self.lexer = Lex()
self.lexer.lexer.input(self.tree_string)
while True:
tok = self.lexer.lexer.token()
if not tok:
break
# return to the original cwd
os.chdir(CWD_b4)
@staticmethod
def mock():
"""Create a .tree string from the current working directory
ok so i was naughty and used some post it notes on this class . however a lexer lets you store your own vars on it. so we may as well do that and pass them through instead.
This issue was automatically created by a github action that converts project Todos to issues.
https://github.com/byteface/sharpshooter/blob/b7afabf36077e1d982f523b71e742597441dedff/sharpshooter/__init__.py#L953