{ "info": { "author": "Paul-Michael Agapow", "author_email": "pma@agapow.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Text Processing :: Filters", "Topic :: Text Processing :: General" ], "description": "============\nAbout konval\n============\n\nBackground\n----------\n\nThe problem of sanitizing data (checking correctness and transforming to a\nuseful form) is widespread throughout programming:\n\n* How do I verify user input is correct?\n* How do I munge data from a spreadsheet into dates and numbers?\n* How do I convert raw database fields into a programmatic object?\n\nIan Bicking came up with a sensible idiom for this problem, embodied in his\nFormencode library [formencode]_: validation and conversion are one and the same\nthing, and can be handled by passing raw data through a chain of validators.\nEach validator checks and/or transforms the data and passes it on to the next.\n\nIn this spirit, *konval* is a package that provides:\n\n* a rich library of validation objects\n* base classes for easily producing custom validators\n* functions for easily using validators in a variety of ways\n\n\nStatus\n------\n\n*konval* is in an exploratory state, having been produced to support another\npackage and to see if use can be got out of generalising conversion. As such. it \nis still an early release and the API may change. Comment is invited.\n\n\nInstallation\n------------\n\nThe simplest way to install *konval* is via ``easy_install`` [setuptools]_ or an\nequivalent program::\n\n\t% easy_install konval\n\nAlternatively the tarball can be downloaded [konval-pypi]_, unpacked and\n``setup.py`` run::\n\n\t% tar zxvf konval.tgz\n\t% cd konval\n\t% python set.py install\n\n*konval* has no prerequisites and should work with just about any version of\nPython.\n\n\nUsing konval\n------------\n\nA full API is included in the source distribution.\n\n\nExamples\n~~~~~~~~\n\nMost commonly, konval will be used to check or clean values. Failures result in\nexceptions being thrown::\n\n\t# convert user input to a actual integer\n\t>>> from konval import *\n\t>>> sanitize ('1.0', ToInt())\n\t1\n\t>>> sanitize ('one', ToInt())\n\tTraceback (most recent call last)\n\t...\n\tValueError: can't convert 'one' to integer\n\t\nA single validator or list can be passed to `sanitize`. Failure in any will\nresult in any exception::\n\n\t# check a list has no more than 3 members\n\t>>> sanitize (['a', 'b', 'c'], [ToLength(), IsEqualOrLess(3)])\n\t3\n\t# check a password is long enough\n\t>>> sanitize ('mypass', [ToLength(), IsEqualOrMore(8)])\n\tTraceback (most recent call last)\n\t...\n\tValueError: 6 is lower than 8\n\nAny callable object that accepts and returns a single value can be used as a\nvalidator::\n\t\n\t>>> from string import *\n\t>>> sanitize (\" my title \", [strip, capitalize])\n\t'My title'\n\nA rich library of prebuilt validators is supplied::\n\n\t>>> sanitize ('abcde', IsNonblank())\n\t'abcde'\n\t>>> sanitize (5, IsInRange(1,6))\n\t5\n\t>>> sanitize ('foo', ToSynonym({'foo': 'bar', 'baz': 'quux'}))\n\t'bar'\n\nCustom validators can easily be subclassed from a supplied base class::\n\n\tclass IsFoo (BaseValidator):\n\t\tdef validate_value (self, value):\n\t\t\tif value != 'foo':\n\t\t\t\tself.raise_validation_error (value)\n\t\t\treturn True\n\n\nLimitations\n-----------\n\n*konval* is aimed at a one-way transformation of data, turning user input or\nstored data *into* Python objects. Certainly it could be used in the reverse\ndirection, but this is not a primary use case. FormEncode is based around\ntwo-way (round trip) conversion of data, so that may be a useful alternative.\n\nThe name *konval* was chosen because:\n\n1. there's already a Python library called \"sanity\"\n\n2. out of \"valcon\", \"valkon\", \"conval\" etc. it was the one with the fewest hits\n on Google\n\n\nCredit\n------\n\nThanks to Ian Bicking for inspiration in FormEncode. Thanks also to Egor Ryabkov.\n\n\nReferences\n----------\n\n.. [konval-home] `konval home page `__\n\n.. [konval-pypi] `konval on PyPi `__\n\n.. [setuptools] `Setuptools & easy_install `__\n\n.. [konval-github] `konval on github `__\n\n.. [formencode] `FormEncode `__\n\n\nHistory\n-------\n\nv0.3, 20110802\n~~~~~~~~~~~~~~\n\n* Renamed a few validators to more consistent scheme. Names should be fixed now.\n\n\nv0.2, 20110726\n~~~~~~~~~~~~~~\n\n* Fixed incorrect example\n\n* Added logic validators (Or, Default, Constant)\n\n\nv0.1, 20110722\n~~~~~~~~~~~~~~\n\n* Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.agapow.net/software/py-konval", "keywords": "validation conversion", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "konval", "package_url": "https://pypi.org/project/konval/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/konval/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.agapow.net/software/py-konval" }, "release_url": "https://pypi.org/project/konval/0.3dev/", "requires_dist": null, "requires_python": null, "summary": "Routines for data validation & conversion", "version": "0.3dev" }, "last_serial": 793981, "releases": { "0.1dev": [ { "comment_text": "", "digests": { "md5": "10d9bf5490ec2c639c5186ea2aa9d72d", "sha256": "a19b0dfb1935dc48e532bbf163e7dd1d5da81eea1a4c038f2e8feab1e5ff3b98" }, "downloads": -1, "filename": "konval-0.1dev.tar.gz", "has_sig": false, "md5_digest": "10d9bf5490ec2c639c5186ea2aa9d72d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 143431, "upload_time": "2011-07-22T16:28:21", "url": "https://files.pythonhosted.org/packages/33/4e/9f97f5abf05fccf885ca912169be189389299124b3e40e427236b1bbaf8e/konval-0.1dev.tar.gz" } ], "0.3dev": [ { "comment_text": "", "digests": { "md5": "e663ffe655b9128497e5c0ebe1374b00", "sha256": "fa33d1a211b6aa4e0a387fd61c40df388a30a04a3056e4b0eb896ae83217757c" }, "downloads": -1, "filename": "konval-0.3dev.tar.gz", "has_sig": false, "md5_digest": "e663ffe655b9128497e5c0ebe1374b00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 146037, "upload_time": "2011-08-02T16:07:05", "url": "https://files.pythonhosted.org/packages/01/8d/404c88b69ed0664090c6b85481b61ec802d969c34e26e84dea34fbf5ef04/konval-0.3dev.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e663ffe655b9128497e5c0ebe1374b00", "sha256": "fa33d1a211b6aa4e0a387fd61c40df388a30a04a3056e4b0eb896ae83217757c" }, "downloads": -1, "filename": "konval-0.3dev.tar.gz", "has_sig": false, "md5_digest": "e663ffe655b9128497e5c0ebe1374b00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 146037, "upload_time": "2011-08-02T16:07:05", "url": "https://files.pythonhosted.org/packages/01/8d/404c88b69ed0664090c6b85481b61ec802d969c34e26e84dea34fbf5ef04/konval-0.3dev.tar.gz" } ] }