pydoit / doit

CLI task management & automation tool
http://pydoit.org
MIT License
1.85k stars 175 forks source link

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

Open assarbad opened 5 years ago

assarbad commented 5 years ago

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

Fund with Polar