{ "info": { "author": "Acrisel", "author_email": "support@acrisel.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable" ], "description": "xmlprops provides mechanism for to access and manipulate XML based properties.\r\n\r\nOverview\r\n========\r\nXMLProps provides means to access properties that are stored in XML (file or string) - Java XML style. \r\n\r\nThere are two main classes xmlprops provides:\r\n 1. XMLPropsFile: file based XML that containing properties\r\n 2. XMLPropsStr: string base XML that containing properties\r\n\r\nBoth classes inherit from *dict* class.\r\nBoth classes provide similar methods to allow stractured access to the properties. \r\n\r\nBoth classes inherit same base class that provides access and manipulation \r\nmethods that used by XMLProps family. \r\n\r\nA property is represented by key value XML entries.\r\n \r\nKey: property path. string names separated by, usually, '.' (dot). Key examples:\r\n 1. 'factory_name'\r\n 2. 'arizona.capitol'\r\n 3. 'texas.dallas.mayor'\r\n \r\nThe property name is the last element in property path (similar to basename in path methods)\r\nThe property hierarchy is the path to it.\r\nValue: property value. string representing the value assignment to property\r\n \r\nThe get dict function '[]' was enhanced to include hierarchical get.\r\nOn the item a.b.c; get will try to get c, a.c, and a.b.c.\r\nThe last one available, wins.\r\n\r\nFunctions\r\n=========\r\nget(key, key_sep=None)\r\n----------------------\r\nSimilar to **get()** \"dict\" function '[]' but in addition adds hierarchical relations.\r\n**get()** looks for the *key* in it loaded properties. \r\n\r\nAssuming key is property path, the following order of search will be done (key is 'a.b.c.'):\r\n 1. First lookup c, \r\n 2. Then lookup 'a.c' \r\n 3. And lastly look for 'a.b.c.'\r\n\r\nThe last found match wins.\r\n \r\nset(key, value)\r\n---------------\r\nSets dictionary *key* with *value*\r\n\r\nget_keys(prefix, keys, key_sep=None)\r\n------------------------------------\r\nReturn a dictionary for *prefix* and list of *keys*\r\n\r\nget_match(key_prefix=None, key_suffix=None, key_sep=None, value_sep = None, decrypt=False)\r\n------------------------------------------------------------------------------------------\r\nReturns *OrderedDict* with all keys matching the criteria.\r\nLook for *key* for *key_prefix* and *key_suffix* \r\nEach found key is loaded into a dictionary\r\nThe *key* in the returned dictionary is stripped of its prefix.\r\nThe function returns newly created dictionary\r\nIf you want the prefix to end with '.' delimiter; use 'prefix.' as key_prefix.\r\nIf *value_sep* is provided, it is used to separate the value of the element into a list.\r\nIf *decrypt*, encrypted fields with ending with _encrypted will be decrypted\r\n\r\nget_re(key_re=None, value_sep = None, decrypt=False)\r\n----------------------------------------------------\r\nThe function looks for a keys that fits regular expression.\r\n**key_re** is string of a Pythonic regular expression \r\nIf value_sep provided, it is used to separate the value of the element into a list.\r\nReturns *dict* object. \r\n\r\nget_contain(key_value=None, ignore_case=False, exact_match=False, value_sep = None, decrypt=False)\r\n--------------------------------------------------------------------------------------------------\r\nThe function looks for a keys that that has **key_value** in them.\r\n\r\nParameters:\r\n 1. *key_value*: exact match of *key* or Pythonic regular expression \r\n 1. *ignore_case*: if set will ignore the case where finding a match\r\n 2. *exact*: if set, will take only keys that equals key_value (with considerations to case)\r\n 3. If *value_sep* is provided, it is used to separate the value of the element into a list.\r\n\r\nXMLPropsFile.writes(props_file=None)\r\n------------------------------------\r\nWrites loaded and possibly updated props into property file\r\n**writes()** will either write a new property file of override existing one with it loaded properties.\r\n*props_file*: a path to property file. If none provided, the file loaded will be overwritten.\r\nReturns: None\r\nRaises: XMLPropsWriteFileError\r\n\r\nXMLPropsStr.writes()\r\n--------------------\r\nWrites loaded and possibly updated props into property string\r\n**writes()** will either write a new property file of override existing one with it loaded properties.\r\n*props_file*: a path to property file. If none provided, the file loaded will be overwritten.\r\nReturns: XML formatted string with *entry*, *name and *value* populated from the object\r\n\r\n\r\nExamples of use\r\n===============\r\n\r\n.. code-block:: python\r\n\r\n from xmlprops import XMLPropsStr\r\n from xmlprops import XMLPropsFile\r\n\r\n ## Define example string\r\n props_xml_01='''\r\n \r\n \r\n MySql\r\n BF\r\n shared\r\n db1\r\n 10\r\n 1\r\n userdb\r\n passworddb\r\n hostdb\r\n hw_host\r\n portdb1\r\n databasedb1\r\n portdb2\r\n databasedb2\r\n 1\r\n 2\r\n \r\n '''\r\n ##Load XML from string\r\n xmlprops=XMLPropsStr(props=props_xml_01)\r\n print(xmlprops)\r\n ## prints {'db1.charset': 'utf8', 'db1.use_unicode': 'True', 'init_active': '1', 'product': 'MySql', 'db1.host': 'hostdb', 'service_mode': 'BF', 'db1.port': 'portdb', 'exposure': 'shared', 'db1.password': 'passworddb', 'db1.database': 'databasedb', 'max_active': '10', 'db1.user': 'userdb', 'db1.priority': '2', 'makers': 'db1'}\r\n xmlprops.get_match(key_prefix='db2.')['port'] ## returns 'portdb2'\r\n xmlprops.get_match(key_prefix='db1.')['port'] ##returns 'portdb1'\r\n xmlprops.get_match(key_prefix='db1.port')[''] ##returns 'portdb1'\r\n xmlprops.get_match(key_prefix='db2.') ## returns OrderedDict([('port', 'portdb2'), ('database', 'databasedb2')])\r\n ##Next statement examplifies that last value for key \"priority\" was loaded\r\n xmlprops.get_match(key_prefix='db1.')['priority'] ## returns '2'\r\n ## Next statements examplify priority in evaluating keys when using \"get\" function\r\n xmlprops.get('db1.host') ## returns 'hostdb' - since key 'db1.host' is evaluated after key 'host' \r\n xmlprops.get('db1.max_active') ## returns '10' - key 'max_active' is evaluated first, then 'db1.max_active' is evaluated and is not found\r\n xmlprops.get('db2.max_active') ## returns '10' - key 'max_active' is evaluated first, then 'db2.max_active' is evaluated and is not found\r\n xmlprops.set('new_key','new_key_value') ## Add new key/value\r\n xmlprops.get_contain('host') ## returns {'host': 'hw_host', 'db1.host': 'hostdb'}\r\n xmlprops.get_contain(key_value='host',exact_match=True) ## returns {'host': 'hw_host'}\r\n xmlprops.get_contain('db1.host') ## retuns {'db1.host': 'hostdb'}\r\n xmlprops.get_contain('db.\\.port') ## returns {'db2.port': 'portdb2', 'db1.port': 'portdb1'}\r\n \r\n\r\nAdditional resources\r\n====================\r\n\r\n\r\nDocumentation is in the \"docs\" directory and online at the design and use of xmlprops.\r\n\r\n**example** and **tests** directory shows ways to use xmlprops . Both directories are available to view and download as part of source code\r\non GitHub. GitHub_link_\r\n\r\n.. _GitHub_link: https://github.com/Acrisel/xmlprops\r\n\r\nDocs are updated rigorously. If you find any problems in the docs, or think they\r\nshould be clarified in any way, please take 30 seconds to fill out a ticket in\r\ngithub or send us email at support@acrisel.com\r\n\r\nTo get more help or to provide suggestions you can send as email to:\r\narnon@acrisel.com uri@acrisel.com", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/Acrisel/xmlprops.git", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Acrisel/xmlprops", "keywords": "xml properties dictionary tree", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "xmlprops", "package_url": "https://pypi.org/project/xmlprops/", "platform": "", "project_url": "https://pypi.org/project/xmlprops/", "project_urls": { "Download": "https://github.com/Acrisel/xmlprops.git", "Homepage": "https://github.com/Acrisel/xmlprops" }, "release_url": "https://pypi.org/project/xmlprops/2.0.0/", "requires_dist": null, "requires_python": null, "summary": "xmlprops provides mechanism for to access and manipulate XML based properties", "version": "2.0.0" }, "last_serial": 1944386, "releases": { "0.9": [], "1.0.0": [ { "comment_text": "", "digests": { "md5": "da5b6413acfdb0ad29f644486c742c22", "sha256": "6911d2ab46f77f7137e90f08f717f53cac82acfca566589bfc8e2af0bda23ef7" }, "downloads": -1, "filename": "xmlprops-1.0.0.zip", "has_sig": false, "md5_digest": "da5b6413acfdb0ad29f644486c742c22", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 11686, "upload_time": "2015-11-27T22:10:38", "url": "https://files.pythonhosted.org/packages/a2/af/aeb2eb36577475e43962837911690d8e68e7689cd09358a51b2cb1e437d3/xmlprops-1.0.0.zip" }, { "comment_text": "", "digests": { "md5": "d2f17ced25d77684d3505978249312f0", "sha256": "72cbec6bab5c4e6a7e7a79c38fc09a878d51ded16af3a9d7d3a2a1385b1e50e6" }, "downloads": -1, "filename": "xmlprops-1.0.2.zip", "has_sig": false, "md5_digest": "d2f17ced25d77684d3505978249312f0", "packagetype": "bdist_wheel", "python_version": "3.2", "requires_python": null, "size": 13095, "upload_time": "2015-11-28T06:23:50", "url": "https://files.pythonhosted.org/packages/f0/dd/eeff41a8015a776c23d14f40b156861243926f814d0f8c2bfef62ae7fd0d/xmlprops-1.0.2.zip" } ], "1.0.2": [], "2.0.0": [ { "comment_text": "", "digests": { "md5": "dc53cf471baf5e5c12562648e8ff86e6", "sha256": "f0b40255595aff047a42fe52adc43ca7b76b92998a650806277d173407287b7b" }, "downloads": -1, "filename": "xmlprops-2.0.0.zip", "has_sig": false, "md5_digest": "dc53cf471baf5e5c12562648e8ff86e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14042, "upload_time": "2016-02-07T16:31:46", "url": "https://files.pythonhosted.org/packages/bf/ce/7d99b00878fd03b6305ea591d43323857d3904aca76b3c6a5800b5affdc8/xmlprops-2.0.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dc53cf471baf5e5c12562648e8ff86e6", "sha256": "f0b40255595aff047a42fe52adc43ca7b76b92998a650806277d173407287b7b" }, "downloads": -1, "filename": "xmlprops-2.0.0.zip", "has_sig": false, "md5_digest": "dc53cf471baf5e5c12562648e8ff86e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14042, "upload_time": "2016-02-07T16:31:46", "url": "https://files.pythonhosted.org/packages/bf/ce/7d99b00878fd03b6305ea591d43323857d3904aca76b3c6a5800b5affdc8/xmlprops-2.0.0.zip" } ] }