- you can't pass existing file content into the input easily
Opened this issue · 0 comments
github-actions commented
This issue was automatically created by a github action that converts project Todos to issues.
sharpshooter/sharpshooter/__init__.py
Line 491 in a4473f4
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))