emre/kaptan

when using files it does not:

alexsavio opened this issue · 4 comments

When using files, Kaptan does not:

  • check for '.py' extension from the file argument or,
    • this could be helpful for: not having to define a handler, being able to input a real file path to import_config
  • check if the file is in the path of the interpreter or,
    • this could be helpful for: being able to import a config file wherever it is.
from kaptan import Kaptan
kp = Kaptan()
kp.import_config('config.py')
ImportError
from kaptan import Kaptan
kp = Kaptan(handler='file')
kp.import_config('config.py')
ImportError
from kaptan import Kaptan
kp = Kaptan(handler='file')
kp.import_config('/home/user/project/config.py')
ImportError
from kaptan import Kaptan
kp = Kaptan(handler='file')
cfg = kp.import_config('config')
emre commented

Feel free to send a PR :-)

Not sure I have time these days. +1 for the suggestions though. That's definetely a to-do.

emre commented

@tony do you have time for this? 👍

Hi,

I have just done some kind of adapter here:
https://github.com/Neurita/pypes/blob/wip/pypes/config.py#L60

But I can send a PR soon if you agree with the issue.

tony commented

sounds like a good idea

@alexsavio I'm happy to review / QA if you want to PR it. Be sure to include tests.