Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import io
  2. import sys
  3.  
  4. from ruamel.yaml import YAML
  5.  
  6. sys.stdin = io.TextIOWrapper(sys.stdin.buffer, errors='replace')
  7. yaml = YAML(typ='safe')
  8. docs = yaml.load_all(sys.stdin)
  9.  
  10. ABI_id = 42  # hard coded as I don't have your DB
  11. csv = []
  12. doc_nr = 0
  13. try:
  14.     for doc_nr, doc in enumerate(docs, start=1):
  15.         csv.append(f"{ABI_id}\t{doc['origin']}\t{doc['name']}\t{doc['version']}")
  16.     print('\n'.join(csv))
  17. except Exception as ex:
  18.     print(f'Exception while parsing document number: {doc_nr}', ex)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement