Last active
September 11, 2019 11:23
-
-
Save errietta/46b85434b4237c63501b6b37772bd583 to your computer and use it in GitHub Desktop.
It'll save time in the long run.
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
import sys | |
from typing import List | |
def convert_kv_to_aws(lines: List[str]): | |
arr = [] | |
for txt in lines: | |
parts = txt.split(':') | |
if len(parts) < 2: | |
continue | |
k, v = map(str.strip, parts) | |
yaml = \ | |
f""" | |
- name: {k} | |
value: {v} | |
""" | |
yaml = yaml.lstrip() | |
arr.append(yaml) | |
return arr | |
if __name__ == '__main__': | |
lines = sys.stdin.readlines() | |
print("".join(convert_kv_to_aws(lines))) | |
""" | |
12:17 $ python aws_env.py | |
AWS_S3_BASE_URL: s3-eu-west-1.amazonaws.com | |
TEST1: foo | |
TEST2: bar | |
- name: AWS_S3_BASE_URL | |
value:s3-eu-west-1.amazonaws.com | |
- name: TEST1 | |
value: foo | |
- name: TEST2 | |
value: bar | |
""" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment