Major improvements, deduplication and simplification in over.app.

- over.app.ConfigFile can create empty config files and read all options from them
- over.callback was created to hold commandline parser callbacks
- over.app.Option.is_boolean hint added
- major improvements and increased robustness of over.app.Main command line parser
This commit is contained in:
Martinez 2016-05-17 16:48:58 +02:00
parent 720dfa7b09
commit 2757cd8e96
6 changed files with 247 additions and 69 deletions

36
over/callback.py Normal file
View file

@ -0,0 +1,36 @@
#! /usr/bin/env python3
# encoding: utf-8
# --------------------------------------------------
def boolean(arg):
"""
Converts
- "True", "true" or "1" True
- "False", "false" or "0" False
@while converting argument to bool
"""
if arg in (True, "True", "true", "1"):
return True
elif arg in (False, "False", "false", "0"):
return False
else:
raise ValueError(arg)
def booleans(*args):
"""
Converts each
- "True", "true" or "1" True
- "False", "false" or "0" False
@while converting arguments to bools
"""
out = []
for arg in args:
out.append(boolean(arg))
return out