26 lines
777 B
Python
Executable File
26 lines
777 B
Python
Executable File
#!/bin/python3
|
|
from pathlib import Path
|
|
import tempfile
|
|
import subprocess
|
|
|
|
if __name__ == "__main__":
|
|
# set input_string to the contents of a temporary file opened with nano
|
|
f = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
|
|
n = f.name
|
|
f.close()
|
|
subprocess.call(['nano', n])
|
|
|
|
with open(n, 'r') as f:
|
|
input_string = f.read()
|
|
Path(n).unlink()
|
|
|
|
# Write your code here
|
|
input_string = input_string.strip().strip(',').strip('[').strip(']')
|
|
|
|
def process_part(part: str) -> str:
|
|
part = part.strip()
|
|
quotation = '"' if part.startswith('"') and part.endswith('"') else "'"
|
|
return part.strip(quotation)
|
|
|
|
input_string = ','.join(process_part(p) for p in input_string.split(','))
|
|
print(input_string) |