pickydict

More picky version of Python dictionary

https://github.com/florian-huber/pickydict

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

More picky version of Python dictionary

Basic Info
  • Host: GitHub
  • Owner: florian-huber
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 82 KB
Statistics
  • Stars: 6
  • Watchers: 2
  • Forks: 0
  • Open Issues: 5
  • Releases: 7
Created about 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License Citation

README.md

GitHub PyPI Conda (channel only) GitHub Workflow Status

pickydict - the more picky version of Python dictionary

PickyDict objects will behave just like Python dictionaries, with a few notable exceptions:

  1. PickyDict has a force_lower_case attribute.
    If set to True (default) then dictionary keys will all be treated as lower-case.

  2. PickyDict can contain two additional dictionaries named key_replacements and key_regex_replacements with mappings to enforce translating specific key words.

Installation

PickyDict can simply be installed with: pip install pickydict

It has no further dependencies and should run fine with Python >= 3.6 (probably also lower versions, but that is not tested).

Code examples

```python from pickydict import PickyDict

per default forcelowercase is set to True:

mydict = PickyDict({"A": 1, "B": 2}) print(mydict) # => {'a': 1, 'b': 2}

now also using a replacements dictionary

mydict = PickyDict({"A": 1, "B": 2}, keyreplacements={"a": "abc", "b": "bcd", "c": "cde"}) print(my_dict) # => {'abc': 1, 'bcd': 2}

When adding a value using an undesired key, the key will automatically be fixed

mydict["c"] = 100 print(mydict) # => {'abc': 1, 'bcd': 2, 'cde': 100}

Trying to add a value using an undesired key while the proper key already exists,

will raise an exception.

my_dict["b"] = 5 # => ValueError: Key 'b' will be interpreted as 'bcd'... ```

It is also possible to add a dictionary with regex expression to replace parts of key strings. This is done using the key_regex_replacements attribute. In the following example the dictionary will replace all spaces in keys with underscores.

Important to note is that regex based replacements will be carried out before the more specific key_replacements. This is to reduce the number of possible variations and make things simpler for the user.

Example:

```python from pickydict import PickyDict

mydict = PickyDict({"First Name": "Peter", "Last Name": "Petersson"}, keyreplacements={"lastname": "surname"}, keyregexreplacements={r"\s": ""}) print(mydict) # => {'firstname': 'Peter', 'surname': 'Petersson'} ```

Whenever the pickyness is updated, no matter if the force_lower_case, key_replacements, or key_regex_replacements, the entire dictionary will be updated accordingly.

Example:

```python

from pickydict import PickyDict

mydict = PickyDict({"First Name": "Peter", "Last Name": "Petersson"}) print(mydict) # => {'first name': 'Peter', 'last name': 'Petersson'}

mydict.setpickyness(keyreplacements={"lastname": "surname"}, keyregexreplacements={r"\s": ""}) print(mydict) # => {'first_name': 'Peter', 'surname': 'Petersson'} ```

Handling of key duplicates

PickyDict converts key names as described above. This can obviously lead to cases of having key duplicates. This is handled in two different ways. When passing a dictionary to PickyDict in the beginning, only the entries for the desired keys will be kept.

Example:

```python

from pickydict import PickyDict

mydict = PickyDict({"My Name": "Peter", "name": "Peter Petersson"}, keyreplacements={"myname": "name"}, keyregexreplacements={r"\s": ""}) print(my_dict) # => {"name": "Peter Petersson"} ``` Later adding values using an improper key, however, will raise an exception when it leads to a duplicate.

Example:

```python

from pickydict import PickyDict

mydict = PickyDict({"firstname": "Peter Petersson"}, keyregexreplacements={r"\s": ""}) mydict["First Name"] = Peter P. Petersson # => ValueError:Key 'First name' will be interpreted as 'first_name' ```

For the rest it's just a dict

All other operation should work as you are used to from Python dictionaries.

Owner

  • Name: Florian Huber
  • Login: florian-huber
  • Kind: user
  • Location: Düsseldorf, Germany
  • Company: HSD, Düsseldorf, Germany

Citation (CITATION.cff)

# YAML 1.2
---
abstract: "pickydict - the more picky version of Python dictionary"
authors:
  -
    affiliation: "HSD - University of Applied Sciences, Düsseldorf, Germany"
    family-names: Huber
    given-names: Florian
    orcid: "https://orcid.org/0000-0002-3535-9406"

cff-version: "1.1.0"
keywords:
  - Python dictionary
license: "MIT"
repository-code: "https://github.com/florian-huber/pickydict"
title: pickydict
...

GitHub Events

Total
Last Year

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 54
  • Total Committers: 1
  • Avg Commits per committer: 54.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Florian Huber 3****r 54

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 8
  • Total pull requests: 6
  • Average time to close issues: about 13 hours
  • Average time to close pull requests: about 5 hours
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 0.63
  • Average comments per pull request: 0.17
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 21 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • florian-huber (7)
  • hechth (1)
Pull Request Authors
  • florian-huber (7)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 52,728 last-month
  • Total docker downloads: 250,177
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 5
    (may contain duplicates)
  • Total versions: 8
  • Total maintainers: 1
pypi.org: pickydict

More picky version of Python dictionary.

  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 4
  • Downloads: 52,728 Last month
  • Docker Downloads: 250,177
Rankings
Docker downloads count: 1.0%
Dependent packages count: 4.7%
Downloads: 6.0%
Dependent repos count: 7.5%
Average: 11.8%
Stargazers count: 21.5%
Forks count: 29.8%
Maintainers (1)
Last synced: 8 months ago
conda-forge.org: pickydict
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.1%
Average: 50.1%
Dependent packages count: 51.5%
Stargazers count: 59.2%
Forks count: 65.6%
Last synced: 7 months ago

Dependencies

.github/workflows/CI_build.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/CI_test_pip_install.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/pypi_publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • pypa/gh-action-pypi-publish master composite
setup.py pypi