{ "info": { "author": "Mark Anderson", "author_email": "nosrednakram@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Utilities" ], "description": "Help on module Preferences:\n\nNAME\n Preferences\n\nFILE\n /home/nosrednakram/work/preferences/src/Preferences/Preferences.py\n\nCLASSES\n Preferences\n \n class Preferences\n | Preference CLASS\n | \n | It a simple class that creates a list of dictionarries to store\n | preferences as key value pairs for managing parameter sets. You\n | can use the class directly or load the parameters from files.\n | The main reason I wrote it was so that I could have an easy way \n | of storing more than one preference with the same name and load \n | them form files in a manner that allows for easy appending or \n | replacing of parmeters that could have been loaded from a \n | default prameter file.\n | \n | Config Files:\n | \n | The load_files will try to read files from three locations\n | by default: /etc/file, ~/.file, cwd/.file and load them in\n | that order but you can always pass in a list of files to \n | load. load_files uses read_file so you can use it to load\n | files one at a time if you would prefer.\n | Here are a few examples.\n | \n | /etc/my_prefs\n | Organization: NosrednaKram.com\n | \n | [User Home]/.my_prefs\n | Author: Mark Anderson\n | Maintainer: Mark Anderson\n | Email: Nosrednakram < at > GMail < dot > Com\n | \n | [CWD]/.my_prefs\n | Project= Nosrednakram Preferences\n | Description= You can do multi-line\n | Just start lines with four spaces\n | and they will be appended regardless\n | of formating\n | Author: Someone Else\n | Author: Yet again Somone Else\n | \n | The file content should begin in postion 1 of the file unless\n | it's a continuation then it should start with four spaces then\n | the content.\n | \n | The : seperator allows for more than one paramter with that\n | name. \n | \n | The = Seperator will remove all previous loaded parameters\n | with the same name and then add. It will just add if no\n | previous parameters were set. Basiclly use for a preference\n | when you only want one returned.\n | \n | Code Examples: (Assuming at least one file exists)\n | \n | # Import\n | from Preferences import Preferences\n | \n | # Create Preferences instance\n | project = Preferences()\n | \n | # Load Preferences for dfault locations if they exist \n | project.load_files('my_prefs')\n | \n | # List the Authors with a loop\n | for author in project.get('Author'):\n | print('Author: %s' % author\n | \n | # Print Authors as a CSV\n | print project.get_csv('Author')\n | \n | # Add and additional Author\n | project.add({'Author': 'Yet Another Person'})\n | \n | # Add more preferences from another file\n | project.read_file('additional_file.prf')\n | \n | # Dump the project preferences to standard out\n | project.dump()\n | \n | # see test.py for more usage examples.\n | \n | Methods defined here:\n | \n | __init__(self, param=None)\n | \n | add(self, pref=None)\n | Append a parameter to the params list.\n | \n | dump(self)\n | I use this for debugging some times.\n | \n | get(self, pref)\n | get(self, pref)\n | \n | Looks up all preferences of the provieded type.\n | \n | Returns '' if no parameters were found.\n | Returns value if only one parameter was found\n | Returns list of values if more than one parameter was found.\n | \n | get_csv(self, pref)\n | This return a csv list of the specified preference values or \n | '' if there are not matching preferences.\n | \n | has(self, pref, value)\n | When passed a parameter and value it returns true if a matching\n | key value pair exists and False otherwise.\n | \n | has_pref(self, pref)\n | Returns True if a parameter with that name exists and fails \n | otherwise.\n | \n | load_files(self, file_name, path=[])\n | When called with a path that is a list of paths to configuration\n | files they are read in the order they appear in the list. If not\n | it will first look for files in /etc, the users home directory, and\n | then the current working director for the passed in file name. The\n | exception is a . is prepended to the file name in the users \n | directory. These files are all loaded so you can define global,\n | local and user preferences. See read_file for more on thy syntax.\n | \n | read_file(self, file)\n | Reads preferences from a file line by line. Skipping all lines\n | beginning with a # or newline. splitting on the first =, * or :. \n | \n | If split on an = other parameters with the same name are removed \n | then the preference is added irregardless of if there were \n | pre-exising preferences with the same name. \n | \n | If split on an * the preference is simply added allowing for the\n | same preference to appear several times even with the same value.\n | \n | If split on an : the key value pair is forced to be unique and if\n | there are multipul key value pairs that match all but one set is\n | removed.\n | \n | It will raise a Value error and provide the line number the error \n | appeard on if there is an line within your preferences file it\n | doesn't know how to handle.\n | \n | replace_key(self, pref, new_value)\n | First all occurances of the preference are removed. Then the\n | parameter is added regardless of weather or not an existing \n | parameter was found. See add for more details\n | \n | uniq_key_value(self, pref, value)\n | If you need unique key value pairs. For example if you have a\n | parameter that my appear in more than one config file but you \n | only want one occurance reported. Like ~./prefs has author mark\n | and .cwd also has author mark you would only return one author\n | mark but you could have another author that would also get returned.\n | \n | ----------------------------------------------------------------------\n | Data and other attributes defined here:\n | \n | params = []", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://preferences.django-development.com/", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "Preferences", "package_url": "https://pypi.org/project/Preferences/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Preferences/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://preferences.django-development.com/" }, "release_url": "https://pypi.org/project/Preferences/0.08/", "requires_dist": null, "requires_python": null, "summary": "It a simple class that creates a list of dictionarries to store preferences as key value pairs. You can use the class directly or load the preferences from files. The main reason I wrote it was to create an easy way of storing more than one preference with the same name and load them form files in a manner that allows for easy appending or replacing of parmeters that could have been loaded from a default prameter file. There are also several methods to make managing the preferences easier.", "version": "0.08" }, "last_serial": 784945, "releases": { "0.01": [ { "comment_text": "", "digests": { "md5": "bc9f585a90fdcfd6a11eac29be4824ec", "sha256": "7e0e64d8dbadda7d66e4779490488f58182f0ae85d48779d6ddaf9ca61ca90dd" }, "downloads": -1, "filename": "Preferences-0.01.tar.gz", "has_sig": false, "md5_digest": "bc9f585a90fdcfd6a11eac29be4824ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5657, "upload_time": "2010-04-26T15:04:00", "url": "https://files.pythonhosted.org/packages/29/d8/65c124a9700d4cc98213d4d6897419fd16271a7b9a091101482bcd262a31/Preferences-0.01.tar.gz" } ], "0.02": [ { "comment_text": "", "digests": { "md5": "37b2cfe04aa463d70f16e6db2b39cace", "sha256": "7326c277699e668a21b1e75007cfe84b1c945bf3474d7586575373f5fcb4294b" }, "downloads": -1, "filename": "Preferences-0.02.tar.gz", "has_sig": false, "md5_digest": "37b2cfe04aa463d70f16e6db2b39cace", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5684, "upload_time": "2010-04-26T17:02:17", "url": "https://files.pythonhosted.org/packages/83/ac/0cae2f69e3fd4df44305238f6c5ddec9010d296ce3aff4e0b33536b66561/Preferences-0.02.tar.gz" } ], "0.03": [ { "comment_text": "", "digests": { "md5": "717dcdd89a72f49082d3bd799bc3059f", "sha256": "8e36c59f5afaa16437eae446f9cf35a6bdf30edc185db2a902181887ebc5dfbf" }, "downloads": -1, "filename": "Preferences-0.03.tar.gz", "has_sig": false, "md5_digest": "717dcdd89a72f49082d3bd799bc3059f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6050, "upload_time": "2010-05-02T18:48:50", "url": "https://files.pythonhosted.org/packages/70/f4/b2f65c43e79bf80e470e3044dc36e8e392fb98898ab265e0be5920d3d93e/Preferences-0.03.tar.gz" } ], "0.04": [ { "comment_text": "", "digests": { "md5": "1aa07cb670dd42fc278d3a7a69072578", "sha256": "adfd0d22a094cd72443fc608e41f8cf3548e37712f48afe50e043e3d77fd4977" }, "downloads": -1, "filename": "Preferences-0.04.tar.gz", "has_sig": false, "md5_digest": "1aa07cb670dd42fc278d3a7a69072578", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6090, "upload_time": "2010-05-02T18:51:40", "url": "https://files.pythonhosted.org/packages/57/97/c0ac2b9b149dc4e0ec4cb5f8713605444f62cdc0a1e2207833345631a92d/Preferences-0.04.tar.gz" } ], "0.05": [ { "comment_text": "", "digests": { "md5": "5dc7509498579f60713e2cb6c00ef2f3", "sha256": "7ecab768abf14f9edff8f105786e27f951e88d23127a350d075f66c4c3145c9c" }, "downloads": -1, "filename": "Preferences-0.05.tar.gz", "has_sig": false, "md5_digest": "5dc7509498579f60713e2cb6c00ef2f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4018, "upload_time": "2010-05-08T18:46:09", "url": "https://files.pythonhosted.org/packages/af/b0/388fdb796e387f0b670af3a39bf0895fdb9c4e4a090c0e03382559625308/Preferences-0.05.tar.gz" } ], "0.06": [ { "comment_text": "", "digests": { "md5": "bd149a54db89efe0aa9ba0bf26b00b5a", "sha256": "4887ad83b2c3d870018fc170d5c75017020aa84b627f61c568e0fedda0c42cf6" }, "downloads": -1, "filename": "Preferences-0.06.tar.gz", "has_sig": false, "md5_digest": "bd149a54db89efe0aa9ba0bf26b00b5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4020, "upload_time": "2010-05-08T18:54:22", "url": "https://files.pythonhosted.org/packages/ed/32/1d1f13e4deede6dee3011e6fcc0b011e57eecd6403ef41b1c04aff4d1bbf/Preferences-0.06.tar.gz" } ], "0.07": [ { "comment_text": "", "digests": { "md5": "7bd3bc80bc7c5a83b8d1f030a879c955", "sha256": "49ce6617dde542dca300f489b822709a84acc52f3c5efa50c18de73b3fdbc2d0" }, "downloads": -1, "filename": "Preferences-0.07.tar.gz", "has_sig": false, "md5_digest": "7bd3bc80bc7c5a83b8d1f030a879c955", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4018, "upload_time": "2010-05-08T19:05:07", "url": "https://files.pythonhosted.org/packages/66/16/615c29ba5b8a8f499cbd8620f80f256655660c915b56232e3eb6384b2679/Preferences-0.07.tar.gz" } ], "0.08": [ { "comment_text": "", "digests": { "md5": "35e2c032f6982be368368ce0d5fa964d", "sha256": "6886bfe2c9b5c629cd68898823804b28ef84ab069f82c5d0f4b5f5d1a1db5dab" }, "downloads": -1, "filename": "Preferences-0.08.tar.gz", "has_sig": false, "md5_digest": "35e2c032f6982be368368ce0d5fa964d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6072, "upload_time": "2010-05-08T19:52:01", "url": "https://files.pythonhosted.org/packages/02/ab/351cbd737eb773eda94c22fe13ad3e028d472c31566731ff0eabca43cdd3/Preferences-0.08.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "35e2c032f6982be368368ce0d5fa964d", "sha256": "6886bfe2c9b5c629cd68898823804b28ef84ab069f82c5d0f4b5f5d1a1db5dab" }, "downloads": -1, "filename": "Preferences-0.08.tar.gz", "has_sig": false, "md5_digest": "35e2c032f6982be368368ce0d5fa964d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6072, "upload_time": "2010-05-08T19:52:01", "url": "https://files.pythonhosted.org/packages/02/ab/351cbd737eb773eda94c22fe13ad3e028d472c31566731ff0eabca43cdd3/Preferences-0.08.tar.gz" } ] }