Trying to use an editor (emacs) via subprocess-module to edit new draft.

This commit is contained in:
Homer 2015-02-07 00:56:44 +01:00 committed by Homer S
parent ec60f10c40
commit 3b161c257c
1 changed files with 42 additions and 6 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os,re import os,re,subprocess
from string import Template from string import Template
from argparse import ArgumentParser from argparse import ArgumentParser
@ -105,7 +105,7 @@ except:
tplDir = os.path.join(blog_dir,"templates") tplDir = os.path.join(blog_dir,"templates")
def update_blog(): def update_blog(subsection):
tplIndex = os.path.join(tplDir,"index.htm") tplIndex = os.path.join(tplDir,"index.htm")
blogIndex = os.path.join(blog_dir,"index.html") blogIndex = os.path.join(blog_dir,"index.html")
@ -137,41 +137,77 @@ def update_blog():
print(tmpIndex, file=f) print(tmpIndex, file=f)
# blog functions
if vars(args)['target'] == 'blog': if vars(args)['target'] == 'blog':
## update subsections or whole blog
if vars(args)['action'] == 'update': if vars(args)['action'] == 'update':
print("Updating your block.") print("Updating your block.")
update_blog() update_blog(vars(args)['subsection'])
## add a new blog at -d blog-directory
if vars(args)['action'] == 'add': if vars(args)['action'] == 'add':
pass pass
# draft functions
if vars(args)['target'] == 'draft': if vars(args)['target'] == 'draft':
## add new draft
if vars(args)['action'] == 'add': if vars(args)['action'] == 'add':
pass subprocess.call(["emacs",os.path.join(blog_dir,"templates/article.txt")])
## list drafts
if vars(args)['action'] == 'list': if vars(args)['action'] == 'list':
pass pass
## edit draft
if vars(args)['action'] == 'edit': if vars(args)['action'] == 'edit':
pass pass
## remove draft
if vars(args)['action'] == 'remove': if vars(args)['action'] == 'remove':
pass pass
# article functions
if vars(args)['target'] == 'article': if vars(args)['target'] == 'article':
## add new article
if vars(args)['action'] == 'add': if vars(args)['action'] == 'add':
pass pass
## list articles
if vars(args)['action'] == 'list': if vars(args)['action'] == 'list':
pass pass
## edit article
if vars(args)['action'] == 'edit': if vars(args)['action'] == 'edit':
pass pass
if vars(args)['action'] == 'remove':
## remove article
if vars(args)['action'] == 'remove':
pass pass