__main__: Start module to run the tool.
This commit is contained in:
parent
3b5a563ef6
commit
b49356bcb6
1 changed files with 22 additions and 0 deletions
22
oxrlib/__main__.py
Normal file
22
oxrlib/__main__.py
Normal 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())
|
Loading…
Reference in a new issue