bla
This commit is contained in:
parent
f6f140735e
commit
80291b0942
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import configparser
|
||||
from string import Template
|
||||
from argparse import ArgumentParser
|
||||
|
||||
# check for arguments and options
|
||||
|
@ -7,6 +10,32 @@ parser = ArgumentParser(description="Manage your weblog via commandline. Creates
|
|||
parser.add_argument('--blog_dir', default='~/public_html/blog', help='path to blog directory (default: %(default)s)')
|
||||
parser.add_argument('action', choices=['update'], help='updates blog to current state')
|
||||
args = parser.parse_args()
|
||||
print(vars(args))
|
||||
try:
|
||||
blog_dir = os.path.abspath(os.path.expanduser(vars(args)['blog_dir']))
|
||||
if not os.path.isdir(blog_dir):
|
||||
print("The path you offered is not a directory!")
|
||||
exit
|
||||
except:
|
||||
raise
|
||||
|
||||
def readout_conf(p):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(p)
|
||||
return config
|
||||
|
||||
pbconf = readout_conf(os.path.join(blog_dir,"pb.conf"))
|
||||
l10nconf = readout_conf(os.path.join(blog_dir,"l10n",pbconf['General']['BLOG_LANG'],"static.conf"))
|
||||
def update_blog():
|
||||
|
||||
print(pbconf['General']['BLOG_LANG'])
|
||||
print(l10nconf['General']['APP_NAME'])
|
||||
print(l10nconf.defaults())
|
||||
tplIndex = os.path.join(blog_dir,"templates","index.htm")
|
||||
tpl = Template(open(tplIndex,'r'))
|
||||
blogIndex = os.path.join(blog_dir,"index.html")
|
||||
with open(blogIndex,"w", encoding=l10nconf['General']['BLOG_CHARSET']) as f:
|
||||
print(tpl.safe_substitute(l10nconf), file=f)
|
||||
if vars(args)['action'] == 'update':
|
||||
print("Updating your block.")
|
||||
update_blog()
|
||||
|
|
Loading…
Reference in New Issue