__main__: Start module to run the tool.

This commit is contained in:
Brett Smith 2017-05-17 14:40:43 -04:00
parent 3b5a563ef6
commit b49356bcb6

22
oxrlib/__main__.py Normal file
View file

@ -0,0 +1,22 @@
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())