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!
Project Description

plucky.pluckable happily wraps any Python object and allows for chained soft plucking with attribute- and item- getters (e.g. .attr, ["key"], [idx], [::2], or a combination: ["key1", "key2"], and [0, 3:7, ::-1]; even: ["length", 0:5, 7]).

plucky.pluck will allow you to pluck same as with pluckable (regarding the plucking operations), but accepting a string selector instead of a Python expression.

plucky.plucks enables you to safely extract several-levels deep values by using a concise string selector comprised of dictionary-like keys and list-like indices/slices. Stands for pluck simplified, since it supports only a subset of pluck syntax. It’s simpler and a more efficient.

plucky.merge facilitates recursive merging of two data structures, reducing leaf values with the provided binary operator.

Installation

plucky is available as a zero-dependency Python package. Install with:

$ pip install plucky

Usage

from plucky import pluck, plucks, pluckable, merge

pluckable(obj).users[2:5, 10:15].name["first", "middle"].value

pluck(obj, 'users[2:5, 10:15].name["first", "middle"]')

plucks(obj, 'users.2:5.name.first')

merge({"x": 1, "y": 0}, {"x": 2})

Examples

obj = {
    'users': [{
        'uid': 1234,
        'name': {
            'first': 'John',
            'last': 'Smith',
        }
    }, {
        'uid': 2345,
        'name': {
            'last': 'Bono'
        }
    }, {
        'uid': 3456
    }]
}

plucks(obj, 'users.1.name')
# -> {'last': 'Bono'}

plucks(obj, 'users.name.last')
# -> ['Smith', 'Bono']

plucks(obj, 'users.*.name.first')
# -> ['John']

pluckable(obj).users.name.first.value
# -> ['John']

pluckable(obj).users.uid[0, 2, 1].value
# -> [1234, 3456, 2345]

pluckable([datetime.datetime.now(), None, {'month': 8}])[::2].month
# -> [5, 8]

pluckable(obj, skipmissing=False, default='Unnamed').users.name.first.value
# -> ['John', 'Unnamed', 'Unnamed']

More Examples! :)

pluckable(obj).users[:, ::-1].name.last.value
# -> ['Smith', 'Bono', 'Bono', 'Smith']

pluckable(obj).users[:, ::-1].name.last[0, -1].value
# -> ['Smith', 'Smith']

pluck(obj, 'users[:, ::-1].name.last[0, -1]')
# -> ['Smith', 'Smith']

plucks([1, {'val': 2}, 3], 'val')
# -> [2]

plucks([1, {'val': [1,2,3]}, 3], '1.val.-1')
# -> 3

merge({"x": 1, "y": 0}, {"x": 2})
# -> {"x": 3, "y": 0}

merge({"a": [1, 2], "b": [1, 2]}, {"a": [3, 4], "b": [3]})
# -> {"a": [4, 6], "b": [1, 2, 3]}
Release History

Release History

0.4.1

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

0.4.0

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

0.3.7

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

0.3.6

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

0.3.5

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

0.3.4

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

0.3.3

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

0.3.2

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

0.3.1

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

0.3

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

0.2

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

0.1

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

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
plucky-0.4.1-py2.py3-none-any.whl (10.1 kB) Copy SHA256 Checksum SHA256 3.5 Wheel May 3, 2017
plucky-0.4.1.tar.gz (8.0 kB) Copy SHA256 Checksum SHA256 Source May 3, 2017

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