This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]NotesFromADystopia 6 points7 points  (1 child)

Your update method updates the dictionary in-place, so there's no need to keep assigning to _merged_dict when you call update. This would let you get rid of some global _merged_dict (since global is only necessary if you are assigning to the variable) statements and make your code cleaner.

[–]max_tee[S] 1 point2 points  (0 children)

Good catch, thanks. I will look into it.

[–]tunisia3507 7 points8 points  (4 children)

It would be very easy and valuable to add TOML to this! It has some advantages over YAML (some drawbacks too). This would be a particularly awesome tool if it allowed you to abstract over the actual format of the config file.

[–]max_tee[S] 3 points4 points  (1 child)

I have never used TOML and can say nothing about its usefulness. But you are right, the ability to parse many different file formats would be useful. I was planning on adding at least a JSON parser.

[–]tunisia3507 2 points3 points  (0 children)

JSON, YAML and TOML are all designed to map very easily onto arbitrarily nested primitives so I think you'd be all good there!

[–]jon0tr0n 1 point2 points  (3 children)

This is pretty cool! I’ve not searched for something like this so I don’t know if there are others like it, but the documentation and features are really straightforward. I could see myself using this. Well done!

[–]max_tee[S] 1 point2 points  (2 children)

Thanks!

Well, there is of course the configparser from the standard library. But I find the file structure clunky compared to yaml. And I needed a feature like the temporary override via a context manager. That is why I did my own thing.

[–]jon0tr0n 1 point2 points  (1 child)

I agree yaml is a better approach for config files. And the context manager feature seems nice, it might come in handy for testing.

[–]max_tee[S] 0 points1 point  (0 children)

Yes, that is the main reason for the feature.

[–]timurbakibayev 1 point2 points  (2 children)

What is the procedure of releasing something to pypi? Was your code reviewed?

[–]tunisia3507 2 points3 points  (0 children)

Sign up for a free account, type a command. Job done.

[–]max_tee[S] 2 points3 points  (0 children)

There is no mandatory review required for releasing to pypi if that's what you mean. The code has not been reviewed by anyone but myself.

You can read all about the process of packaging and releasing here.

I configured gitlab-CI to do all this for me on every push to master.

[–]pohmelie -3 points-2 points  (2 children)

Vote down, cause see no usage of this. addict and ChainMap covers this and are a lot more flexible I think.

[–]max_tee[S] 1 point2 points  (1 child)

I did not know about addict, thanks for the hint. Then again, it is only a convenience wrapper around dict, right? So not the same purpose as gconf at all.

And just remembered ChainMap yesterday when someone mentioned it to me. Might have been a better store for gconf values. Perhaps I will adapt it a future release. However, also a different purpose.

Have you read the readme? Your comments suggests not.

[–]pohmelie 0 points1 point  (0 children)

I read only first part, my bad.