ssato / python-anyconfig

Python library provides common APIs to load and dump configuration files in various formats
MIT License
279 stars 31 forks source link

[BUG] Anyconfig load the wrong file - with Jinja2 templating. #18

Closed quamilek closed 9 years ago

quamilek commented 9 years ago

This is a tree of files where error occured:

└── current_dir
    ├── test
    │   └── location
    │       └── config.yaml
    └── config.yaml

When i run:

context = {'name': 'James Bond'}
path = 'test/location/config.yaml'
config = anyconfig.load(
    path, 'yaml', ac_template=True, ac_context=context,
)

Anyconfig load file config.yaml instead of test/location/config.yaml, this is unexpected action. Expected behavior is, when Anyconfig load test/location/config.yaml file.

Errors occured in: https://github.com/ssato/python-anyconfig/blob/master/anyconfig/template.py#L84 Now it is:

return env.get_template(os.path.basename(template_file)).render(**ctx)

I think should be:

return env.get_template(template_file).render(**ctx)

Full example of code to explanation this bug: https://gist.github.com/quamilek/95487915f66c4edc7441

ssato commented 9 years ago

Thanks a lot for your report!

I've just checked in a part of possible fixes in anyconfig.template side. It seems that your test case still fails so I'll investigate it further.

ssato commented 9 years ago

I added one more test case in the commit, e2ae25d401. Could you please take a loot at it?

quamilek commented 9 years ago

Now work correctly. Thanks for your quick response. When would you like release a new version?

ssato commented 9 years ago

OK, I'll close this issue. Thanks a lot for the confirmation!

About the next release, I'm planning to release it this weekend hopefully w/ fixes/refactorings and some minor enhancements.

kamilchm commented 9 years ago

What with the release of this fix? We're using monkey pathed 0.0.7 because of it and it would be great to just upgrade anyconfig from pypi :)

ssato commented 9 years ago

Sorry to late. I've been busy w/ my day job and it also took some more to finish the rest of work for the 0.0.8 release than I thought.

Anyway, I've just uploaded the 0.0.8 release. Could you please try it?

kamilchm commented 9 years ago

It works. Thx for your quick response!

ssato commented 9 years ago

I've closed this now. If you have any related issues, could you re-open another issue, please?