documentation
This commit is contained in:
parent
4221f2d010
commit
a8d664456f
|
@ -34,18 +34,25 @@ def gen_url(config_data: dict, phlog_file: str) -> dict:
|
|||
|
||||
# spawn $EDITOR or nano by default to edit the post text
|
||||
def edit_post(post: str) -> str:
|
||||
# Fetch OS editor
|
||||
EDITOR = os.environ.get('EDITOR', 'nano')
|
||||
|
||||
# Temporary File
|
||||
tf_file = tempfile.NamedTemporaryFile(suffix = '.tmp', delete = False)
|
||||
|
||||
# Paste in the sample post with links generated
|
||||
with open(tf_file.name, 'w') as tf:
|
||||
tf.write(post)
|
||||
|
||||
# Spawn subprocess on a temporary file
|
||||
call([EDITOR, tf_file.name])
|
||||
|
||||
# Read the file for the final post
|
||||
with open(tf_file.name, 'r') as tf:
|
||||
post = tf.read()
|
||||
tf.close()
|
||||
|
||||
# Delete the temp file
|
||||
os.unlink(tf_file.name)
|
||||
return post
|
||||
|
||||
|
|
Loading…
Reference in New Issue