configuration - Yaml merge in Python -
So I thought of myself (and who cares about using it at all) with a small boilerplate Library for Pygame in Python I would like a system where the settings for the application are provided with a yaml file.
So I was wondering if this would be useful if the library provided a default yamala tree and mixed it by a user supplied it. For the sake of applicability, I think that if possible, there may be any divine law where:
In any way where Yamala, given by the user, overlaps with default, the user The supplied branches supply libraries.
In any case where the yum given by the user does not overlap the default tree, the default tree remains.
Any overflow branches provided by the user provided by JML are enclosed.
I know that this explanation was verbose because it is obviously clear what I am asking for. I am surprised that there is so much to get it for free.
You can use to parse files, and then the following functions to merge two trees To: merge (user, default): ifinstance (user, dict) and isinstance (default, dict): for k, v by default Iteritems (): if not in user : User [k] = V other: user [k] = merge (user [k], v) user back
Alternatively, you can call this function One of the user-trees before taking it.
Comments
Post a Comment