byteface / sharpshooter

A shorthand for creating files and folders. (A parser could be written in any language)
MIT License
11 stars 1 forks source link

- put all these as regular vars on the lexer #31

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

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

            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
byteface commented 2 years ago

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.