Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- you can't pass existing file content into the input easily #23

Open
github-actions bot opened this issue Dec 5, 2021 · 0 comments
Open

- you can't pass existing file content into the input easily #23

github-actions bot opened this issue Dec 5, 2021 · 0 comments
Labels

Comments

@github-actions
Copy link

github-actions bot commented Dec 5, 2021

This issue was automatically created by a github action that converts project Todos to issues.

# TODO - you can't pass existing file content into the input easily

        r"\:"
        self.is_read_only = True

    def t_QUESTION(self, t):
        r"\?"
        if self.is_extra:
            # gets the question
            question = t.lexer.lexdata[t.lexer.lexpos:]
            if question.find("\n") != -1:
                question = question[:question.find("\n")]
            original_length = len(question)
            question = '\n'.join(question.split('\\n'))
            if question is not None and question != "":
                if question[0] == " ":
                    question = question[1:]
            # print(question)
            print("\n")
            print("Editing: " + self.last_file_created)
            print("************************************************************")
            print("Multi-line editor: then Ctrl-D or Ctrl-Z ( windows ) to save.")
            print("TIP: Press Return for an empty newline BEFORE saving.")
            print("************************************************************")
            print("\U0001F4DD Enter/Paste your content.")
            print("************************************************************")

            # TODO - you can't pass existing file content into the input easily
            # i do have a branch that can break into vim and return.
            # but that wont work for windows. so will have a think about it.

            contents = []
            while True:
                try:
                    line = input()
                except EOFError:
                    break
                contents.append(line)
            content = '\n'.join(contents)

            if tree.TEST_MODE:
                sslog('TEST_MODE1: skip writing content into this file:', self.last_file_created)
            else:
                self.last_file_created = self.last_file_created.strip()  # ensure remove trailing spaces
                with open(self.last_file_created, "w+", encoding="utf-8") as f:
                    f.write(content)
                    sslog(f'    - Writing into {self.last_file_created}')
                    f.close()
                # sslog("wrote content into this file:", self.last_file_created)

            t.lexer.skip(original_length)
        else:
            filetype = 'folder' if self.is_dir else 'file'
            print('What would you like the ' + filetype + ' to be called?')
            line = input()
            class mock():
                value = line
            t = mock()
            self.t_FILE(t)

    def t_TAB(self, t):
        r"[\t]+"
        self.move_back(len(t.value))
@github-actions github-actions bot added the todo label Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants