Commit 11e254ab authored by Sylvaine Ferrachat's avatar Sylvaine Ferrachat
Browse files

Added minimalistic user-defined config file handling for `mk_script.py`

parent 5b9da5ac
......@@ -33,6 +33,8 @@ YYYY_MM = '{:%Y-%m}'.format(datetime.date.today())
tmpl_dir = resource_filename(__name__,'templates')
tmpl_ext = '.tmpl'
config_header = '# Configure file for {}\n'.format(os.path.basename(sys.argv[0]))
config_file = os.path.join(os.path.expanduser('~'),'.mk_script.cfg')
#------------------------------------------
#-- Classes
......@@ -89,7 +91,7 @@ class Script:
#-- Main
@begin.start(cmd_delim='--',
config_file='.mk_script.cfg',
config_file=config_file,
)
@begin.logging
def run(
......@@ -107,6 +109,19 @@ def run(
based on template.
"""
#-- User-config handling
if author == None:
author = input(u'Author name is not yet set. Please enter author name.\n')
logging.info('Writing author name to config file {}'.format(config_file))
config = begin.cmdline.configparser.ConfigParser()
config['run'] = {}
config['run']['author'] = author
with open(config_file,'w') as f:
f.write(config_header)
config.write(f)
f.close()
#-- Filename handling
fn_decomp = filename.split('.')
if len(fn_decomp) == 1:
basename = filename
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment