Skip to main content

Implementation of the lens functional pattern

Project description

Lens 1.2.1

Purpose

The purpose of this project is to implement the "Lens" functional pattern in Python and supply that implementation as a package that can be imported into any other python project.

Install

pip install simplelens

Uninstall

pip uninstall simplelens

Usage

Install the package from PyPi via pip install
import lens

The lens function expects a collection of some form, as well as a list of keys and/or indexes to use to extract data from the collection.

collection = {'a': {'b': [{'a': 1}, {'b': 2}, {'c': 3}]
lens.focus(collection, ['a', 'b', 2, 'c'])
#=> 3

Also a feature is returning a tuple of multiple key sequences.

collection = {'a': {'b': [{'a': 1}, {'b': 2}, {'c': 3}]
lens.multi_focus(collection, (['a', 'b', 2, 'c'], ['a', 'b', 0, 'a']))
#=> (3, 1)

Changelog

See changelog here: Changelog.md

License

Copyright 2024 Nathan Menge - nathan.menge@gmail.com

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.

Project details


Download files

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

Source Distribution

simplelens-1.2.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplelens-1.2.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file simplelens-1.2.1.tar.gz.

File metadata

  • Download URL: simplelens-1.2.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for simplelens-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ed8202d9838a8ed835a63787b9b452c1f1f81f454d92e0431ca2f641813266d5
MD5 41b5922048a29f1dd6693e1c76925261
BLAKE2b-256 15efb17d1abf3510ee7e1c903d40ee50ceed62b2b11764f03d6863c010481294

See more details on using hashes here.

File details

Details for the file simplelens-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: simplelens-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for simplelens-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 952b669e52b1ca1f55b3820b06059975b72f6d9b371b6a1fbafac0c12989082b
MD5 399c52cbad9b5eb89b45ea88cab817ab
BLAKE2b-256 64a87683e93894875b7c66dfae1fd6590990c6b22ecb384bf8b0e76dde64b1d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page