This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A small list/dict DSL for field filter specific designed for RESTful API partial response.

Project Description

https://github.com/kudo/collection-filter

This library provides a DSL filter for list or dict data. It is original designed for RESTful API partial response. Tested with Python 2.6, 2.7.

Quick Start

To install, use pip:

$ pip install collection-filter

Then:

$ python

>>> from collection_filter import collection_filter

# Query a dict
>>> collection_filter({'foo': 1, 'bar': 2}, 'foo')
{'foo': 1}

# Query a dict with multiple elements (seperated by comma)
>>> collection_filter({'foo': 1, 'bar': 2}, 'foo,bar')
{'foo': 1, 'bar': 2}

# Query a dict deeply
>>> collection_filter({'foo': {'bar': 2, 'orange': 'sweet'}}, 'foo.bar')
{'foo': {'bar': 2}}

# Query a list
>>> collection_filter([{'foo': 1, 'bar': 2}, {'foo': 3, 'bar': 4}], '[].foo')
[{'foo': 1}, {'foo': 3}]

# list/dict combination example
>>> collection_filter({'foo': 'bar', 'aListOfDict': [{'foo': 1, 'bar': 2}], 'aListOfDict[].foo')
{'aListOfDict': [{'foo': 1}]}

Syntax

Currently support operators

Operator Description
, Multiple field query sperated by comma
[] To indicate the data should be handled as list
. Dot notation should follow with a symbol name which to specify a field in current dict data
Release History

Release History

This version
History Node

0.5

History Node

0.3

History Node

0.2

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
collection-filter-0.5.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Oct 28, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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