Skip to main content

Many-to-one keys-value pair relationship Python object manager.

Project description

namari

Many-to-one keys-value pair relationship Python object manager.

Usage

Install the latest namari package, upcoming versions might introduce unannounced changes, so a virtual environment is a must have before installation.

pip install --upgrade namari

To integrate namari into your Python codes, check the code snippet below:

from namari import Namari

# initialize
lexicon = Namari()

# initialize with filename
lexicon = Namari("filename.json")

# clear contents
lexicon.clear()

# set key-value pair
lexicon.set("yellow", "sun")

# check if key existing
if lexicon.contains("yellow"):
    print("Exists")

# associate an existing key with another value
lexicon.attach("yellow", "hot")
lexicon.attach("yellow", "morning")
lexicon.attach("yellow", "tea")
lexicon.attach("morning", "summer")
lexicon.attach("morning", "cold")
lexicon.attach("morning", "tea")

# associate an existing key with a unique value
lexicon.attach("morning", "tea", unique=True)

# disassociate 2nd key from the 1st key
lexicon.detach("summer", "cold")

# get the value of the specified key
object = lexicon.get("morning") # None

# get the value of the specified key with specified fallback
object = lexicon.get("night", fallback="moon")

# get the first parent of child
parent = lexicon.findFirst("summer", fallback=None)
parents = lexicon.findAll("tea")

# count contents
count = lexicon.count()

# check if empty
if lexicon.is_empty():
    print("Empty")

# iterate over all keys-value pairs
for keys, value in lexicon.items():
    print(type(keys)) # list
    print("\n".join(keys))
    print(value)

Did you know?

The repository name namari was inspired from the developer's noisy cat named Anna Marie, it also means as lead or guidance in Japanese.

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

namari-1.1.9.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

namari-1.1.9-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file namari-1.1.9.tar.gz.

File metadata

  • Download URL: namari-1.1.9.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for namari-1.1.9.tar.gz
Algorithm Hash digest
SHA256 636c19103929fa5fc2aab4f8af0fb41ab294c2114cf9d1c358f760f92abee397
MD5 43f270df4cfbaf13aa5aae3bddce8037
BLAKE2b-256 211fbfa97c1d65f8743f37c73b88c31e898f35ce46ce0a3bd1e54e4b9b95cdeb

See more details on using hashes here.

File details

Details for the file namari-1.1.9-py3-none-any.whl.

File metadata

  • Download URL: namari-1.1.9-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for namari-1.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 890706686607cfbed67e50a5f1de84366d8925d0d6758223af02ec2dd72b056f
MD5 dd9fb76f9c059e24265f6100abbfb289
BLAKE2b-256 7f432937ec664673dfee21bf8cf61ba64918bb1c970124a0db6af4c43e7ed4f1

See more details on using hashes here.

Supported by

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