Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from yaml import load, dump
- try:
- from yaml import CLoader as Loader, CDumper as Dumper
- except ImportError:
- from yaml import Loader, Dumper
- import yaml, tempfile, subprocess, sys
- def edit(data):
- fd, temp_path = tempfile.mkstemp(prefix='punctual.')
- with open(temp_path, "r+") as f:
- f.write(yaml.safe_dump(data, default_flow_style=False, allow_unicode=True))
- f.truncate()
- f.close()
- while True:
- with open(temp_path, "r+") as f:
- subprocess.check_call('vim -c "set syntax=yaml" ' + temp_path, shell=True)
- f.close
- try:
- data = yaml.load(open(temp_path,"r+").read())
- break
- except Exception as E:
- print(E)
- input("Press Enter to continue...")
- return data
- edit({})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement