This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This repo is a port of the node.js querystring module.

It contains two methods, parse_qs and stringify_obj that are functionally equivalent to the querystring.parse and querystring.stringify node counterparts. It also contains default encode_uri_component and decode_uri_component functions that can be used for convenience.

Installation

pip install querystring

Usage

Parsing a query string

>>> querystring.parse_qs('foo=bar&baz=qux&baz=quux&corge=')
{u'foo': u'bar', u'baz': [u'qux', u'quux'], u'corge': u''}
>>> querystring.parse_qs('foo:bar;baz:qux;baz:quux;corge:', sep=';', eq=':')
{u'foo': u'bar', u'baz': [u'qux', u'quux'], u'corge': u''}
>>> def gbk_decode(s):
...     return urllib.unquote(s)
...
>>> querystring.parse_qs('foo=bar&w=%D6%D0%CE%C4', decode_fn=gbk_decode)
{'foo': 'bar', 'w': '\xd6\xd0\xce\xc4'}  # u'中文'

Converting an object back into a query string

>>> querystring.stringify_obj({'foo': 'bar', 'baz': ['qux', 'quux'], 'corge': ''})
'foo=bar&baz=qux&baz=quux&corge='
>>> querystring.stringify_obj({'foo': 'bar', 'baz': ['qux', 'quux'], 'corge': ''}, sep=';', eq=':')
'foo:bar;baz:qux;baz:quux;corge:'
>>> def gbk_encode(s):
...     return urllib.quote(unicode(s).encode('gbk'))
...
>>> querystring.stringify_obj({'foo': 'bar', 'w': u'中文'}, encode_fn=gbk_encode)
'foo=bar&w=%D6%D0%CE%C4'

Motivation

We were looking for a simple module to parse query parameters in a sensible way, and were unsatisfied by how urlparse handled params (putting all values in a list), so we made this.

License

Copyright Refinery29, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release History

Release History

0.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
querystring-0.1.0.tar.gz (3.9 kB) Copy SHA256 Checksum SHA256 Source Mar 13, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting