def modifyArgsByStdinStream(): content = sys.stdin.read() content = tools.stdinEncode(content) if not content: out.failureMessage("Input stream is empty.") return tools.exit() title = ' '.join(content.split(' ', 5)[:-1]) title = re.sub(r'(\r\n|\r|\n)', r' ', title) if not title: out.failureMessage("Error while crating title of note from stream.") return tools.exit() elif len(title) > 50: title = title[0:50] + '...' ARGS = {'title': title, 'content': content} return ('create', ARGS)
def modifyArgsByStdinStream(): content = sys.stdin.read() content = tools.stdinEncode(content) if not content: out.failureMessage("Input stream is empty.") return tools.exit() title = " ".join(content.split(" ", 5)[:-1]) title = re.sub(r"(\r\n|\r|\n)", r" ", title) if not title: out.failureMessage("Error while crating title of note from stream.") return tools.exit() elif len(title) > 50: title = title[0:50] + "..." ARGS = {"title": title, "content": content} return ("create", ARGS)
def modifyArgsByStdinStream(): content = sys.stdin.read() content = tools.stdinEncode(content) if not content: out.failureMessage("Input stream is empty.") return tools.exit() title = ' '.join(content.split(' ', 5)[:-1]) title = re.sub(r'(\r\n|\r|\n)', r' ', title) if not title: out.failureMessage("Error while crating title of note from stream.") return tools.exit() elif len(title) > 50: title = title[0:50] + '...' ARGS = { 'title': title, 'content': content } return ('create', ARGS)
def rawInput(message, isPass=False): if isPass: data = getpass.getpass(message) else: data = raw_input(message) return tools.stdinEncode(data)