Changeset - b49356bcb609
[Not reviewed]
0 0 1
Brett Smith - 7 years ago 2017-05-17 18:40:43
brettcsmith@brettcsmith.org
__main__: Start module to run the tool.
1 file changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
oxrlib/__main__.py
Show inline comments
 
new file 100644
 
import decimal
 
import importlib
 
import sys
 

	
 
import oxrlib.config
 

	
 
def decimal_context(base=decimal.BasicContext):
 
    context = base.copy()
 
    context.rounding = decimal.ROUND_HALF_EVEN
 
    context.traps[decimal.Inexact] = False
 
    context.traps[decimal.Rounded] = False
 
    return context
 

	
 
def main(arglist=None, stdout=sys.stdout, stderr=sys.stderr):
 
    config = oxrlib.config.Configuration(arglist)
 
    subcmd_module = importlib.import_module('.commands.' + config.args.command, 'oxrlib')
 
    with decimal.localcontext(decimal_context()):
 
        subcmd_module.run(config, stdout, stderr)
 
    return 0
 

	
 
if __name__ == '__main__':
 
    exit(main())
0 comments (0 inline, 0 general)