ssato / python-anyconfig

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

Don't sort files by filename #124

Closed edyan closed 2 years ago

edyan commented 3 years ago

Hello,

I am trying to load multiple files with the load method I and noticed that the merge between them is not done properly. Instead of loading files in respect of the list, it sort the list then load it. Then if you load a z.yaml file then a a.yaml file, the second is loaded first and overridden by the first (instead of the opposite).

File z.yaml

---

services:
  php:
    enabled: false

file a.yaml

---

services:
  php:
    enabled: true

Command : anyconfig_cli -T z.yaml a.yaml -O yaml gives :

services:
  php:
    enabled: false

This works with anyconfig 0.9.x but not with 0.10.x

ssato commented 3 years ago

You're right. It may be resolved by f921986.

ssato commented 3 years ago

I've released 0.11.0 and it may resolve your issue as far as I tested. Could you please try that version?

edyan commented 3 years ago

hi, thanks for your reactivity. It seems that now I have a new problem : I have a certain amount of config files and a spec file to validate the concatenated files.

Exemple File a.yaml

---

services:
  php:
    enabled: false
environment: dev

file z.yaml

---

services:
  php:
    enabled: true

I say in my specs that I need to have "environment". And anyconfig tells me : - 'environment' is a required property

---

"$schema": http://json-schema.org/draft-04/schema#
type: object
required:
  - environment

For your information I tried load() and multiload

ssato commented 3 years ago

Thanks for your report!

Is the issue you reported resolved by the latest release? If so, I'll close this issue.

And could you please open another issue for new issue? I could not understand what is your expected behavior in the new issue so it would be great if you add explanation about that.

edyan commented 3 years ago

Hello, I am not sure it's another issue, I think it's linked as I didn't have that in the 0.10.1 when I load the yaml "manually"

        conf = {}
        for filepath in self.config_files:
            yaml = anyconfig.load(filepath, Loader=FullLoader)
            conf = _merge_dictionaries(conf, yaml)
ssato commented 3 years ago

Could you please open another issue even if it looks related or linked? I need to know the followings at least to fix your issues.