oxrlib/oxrlib/__main__.py
2017-05-17 14:40:43 -04:00

22 lines
653 B
Python

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())