If you find yourself writing multiple tools/scripts that share common configuration settings and despise ini files, this will be of interest to you. In my setting, I frequently write code that goes against the same databases and accesses the same resources. So I am constantly repeating code for configuration settings or worse yet, hard-coding it in where it shouldn't be.
YamJam allows you to put it in a common area that you can secure properly from prying eyes and makes working with oft used resources simple and straight forward.
yamjam attributesProject settings can saved in a user directory. Multiple configuration files can be specified. files are proper yaml files detailsThe main yamjam config file is located ~/.yamjam/config.yaml
on windows: c:\documents and settings\[username]\.yamjam\config.yaml on *nix: ~/.yamjam/config.yaml
Then yamjam looks for possible overrides/additions in the local config.yaml(if it exists) You can override the default config file(s) when you call the function by specifying a different one explicitly. i.e.
from YamJam import yamjam
myConfig = yamjam('file/path/filename')myConfig is now a dictionary populated with the values from the specified yaml config file. By default YamJam looks for 2 config.yaml files, the main and then a project specific one. You may specify one or more files. Each file path listed should be separated by semi-colons(;)
myConfig = yamjam('file/path/filename;other/path/file') The config.yaml file is yaml formatted which is a superset of json.
Every call to yamjam() re-reads the config file. If you wish to cache the info then do it in the calling code. i.e.
myConfig = yamjam() If you only want to cache part of the configuration
myCfg = yamjam()['mykey']
30 Day Summary Aug 4 2011 — Sep 3 2011
|
12 Month Summary not available |
Copyright
©
2013
Black Duck Software, Inc.
and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a
Creative Commons Attribution 3.0 Unported License
. Ohloh
®
and the Ohloh logo are trademarks of
Black Duck Software, Inc.
in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.