Created
September 7, 2023 09:22
-
-
Save legionus/798721787f1dce8e77e6c1d97cd6a70f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process_commands(payload): | |
fd = io.StringIO(initial_value=payload, newline='\n') | |
while True: | |
value = fd.readline() | |
if not value: | |
break | |
value = value[:-1] | |
if not re.match(r'^\s*jira\s+', value, re.I): | |
continue | |
words = [ x for x in re.split(r'("[^"]+"|\'[^\']+\'|\S+)', value) if len(x.strip()) > 0 ] | |
for i, word in enumerate(words): | |
if word.startswith("<<"): | |
token = word[2:] | |
heredoc = [] | |
while True: | |
s = fd.readline() | |
if not s: | |
break | |
if s[:-1] == token: | |
break | |
heredoc.append(s) | |
words[i] = "".join(heredoc) | |
print(words) | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment