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

branches implementation #29

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#L358

        if content[-1] == "]":
            content = content[:-1]

        # sslog('cl:', self.current_label)
        if content not in self.labels:
            # sslog('Adding a label:', self.current_label, lvl='g')
            self.labels.append(self.current_label)
            self.current_label = content
        else:
            pass
            # sslog('Creating a branch:', content, lvl='g')
            # TODO - this is a potential can of worms. (mainly due to catching incorrect use cases)
            # if branch exists already, then make it
            # TODO - may need to save cwd and restore?
            # cwd = os.getcwd()
            # TODO - these cant be constants for this to work. (will need to pass vars)
            # note - the lexer itself allows for custom props
            # tree(self.lexer.lexdata, test=tree.TEST_MODE, quiet=tree.QUIET_MODE, label=tree.LABEL)
            # os.chdir(cwd)

        t.lexer.skip(original_length)

    def t_newline(self, t):
        r"\n+"
        if tree.LABEL is not None:
            if self.current_label != tree.LABEL:
                tree.TEST_MODE = True
                tree.QUIET_MODE = True
            else:
                tree.TEST_MODE = tree._TEST_MODE_BAK
                tree.QUIET_MODE = tree._QUIET_MODE_BAK

        t.lexer.lineno += t.value.count("\n")
        self.was_dir = self.is_dir
byteface commented 2 years ago

if a label already exists. we can add it as a branch. however this will cause iteration and needs careful consideration. also if incorrect syntax gets parsed in an interation that gets sticky. so may avoid this feature for now.