doit icon indicating copy to clipboard operation
doit copied to clipboard

Using getattr() instead of relying on .get() method

Open assarbad opened this issue 6 years ago • 0 comments

When trying to reuse the doit module in a standalone script that doesn't behave exactly like a dodo.py would, it's impossible to reuse doit.loader.load_doit_config() passing sys.modules[__name__] (the current "main" module), because it relies on the module object having a get method. That's not the case for the main module, it appears.

So for line 211 in the current version of loader.py I would suggest to replace:

doit_config = dodo_module.get('DOIT_CONFIG', {})

.... by:

doit_config = getattr(dodo_module, 'DOIT_CONFIG', {})

Environment

  1. OS: Ubuntu 16.04.6 LTS
  2. python version: 3.5.2
  3. doit version: 0.31.1

Thanks,

Oliver

assarbad avatar Aug 30 '19 09:08 assarbad