mirror of
https://github.com/kennethreitz-archive/parse.git
synced 2026-06-05 15:30:18 +00:00
moar
This commit is contained in:
+39
-3
@@ -1,7 +1,43 @@
|
||||
Parse strings using a specification based on the Python format() syntax.
|
||||
|
||||
For documentation please "pydoc parse". The same documentation is available
|
||||
at http://pypi.python.org/pypi/parse
|
||||
Anonymous (fixed-position), named and typed values are supported. Also the
|
||||
alignment operators will cause whitespace (or another alignment character)
|
||||
to be stripped from the value.
|
||||
|
||||
To run its tests use "python -m html".
|
||||
You may not use both fixed and named values in your format string.
|
||||
|
||||
The types supported in ":type" expressions are the regular expression
|
||||
character group types d, D, w, W, s, S and not the string format types.
|
||||
|
||||
So, for example, some fixed-position parsing:
|
||||
|
||||
>>> r = parse('hello {}', 'hello world')
|
||||
>>> r.fixed
|
||||
('world', )
|
||||
|
||||
>>> r = parse('hello {:d} {:w}', 'hello 12 people')
|
||||
>>> r.fixed
|
||||
('12', 'people')
|
||||
|
||||
And some named parsing:
|
||||
|
||||
>>> r = parse('{greeting} {name}', 'hello world')
|
||||
>>> r.named
|
||||
{'greeting': 'hello', 'name': 'world'}
|
||||
|
||||
>>> r = parse('hello {^} world', 'hello there world')
|
||||
>>> r.fixed
|
||||
('there', )
|
||||
|
||||
A ValueError will be raised if there is no match:
|
||||
|
||||
>>> r = parse('hello {name:w}', 'hello 12')
|
||||
ValueError: ...
|
||||
|
||||
See also the unit tests at the end of the module for some more
|
||||
examples.
|
||||
|
||||
----
|
||||
|
||||
This code is copyright 2011 eKit.com Inc (http://www.ekit.com/)
|
||||
See the end of the source file for the license of use.
|
||||
|
||||
@@ -43,7 +43,7 @@ examples.
|
||||
|
||||
----
|
||||
|
||||
This code is copyright 2009-2011 eKit.com Inc (http://www.ekit.com/)
|
||||
This code is copyright 2011 eKit.com Inc (http://www.ekit.com/)
|
||||
See the end of the source file for the license of use.
|
||||
'''
|
||||
__version__ = '1.0.0'
|
||||
|
||||
@@ -2,27 +2,25 @@
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
from html import __version__, __doc__
|
||||
from parse import __version__, __doc__
|
||||
|
||||
# perform the setup action
|
||||
setup(
|
||||
name = "html",
|
||||
name = "parse",
|
||||
version = __version__,
|
||||
description = "simple, elegant HTML, XHTML and XML generation",
|
||||
description = "Parse strings using a specification based on the Python format() syntax.",
|
||||
long_description = __doc__.decode('utf8'),
|
||||
author = "Richard Jones",
|
||||
author_email = "rjones@ekit-inc.com",
|
||||
py_modules = ['html'],
|
||||
url = 'http://pypi.python.org/pypi/html',
|
||||
py_modules = ['parse'],
|
||||
url = 'https://github.com/r1chardj0n3s/parse',
|
||||
classifiers = [
|
||||
'Environment :: Web Environment',
|
||||
'Intended Audience :: Developers',
|
||||
'Programming Language :: Python :: 2.5',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Topic :: Software Development :: Code Generators',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||
'Topic :: Text Processing :: Markup :: HTML',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user