Skip to main content

No project description provided

Project description

property_accessor

Python property accessor module util

Installation:

> poetry add property-accessor

Usage

from property_accessor import PropertyAccessor
from dataclasses import dataclass, field


@dataclass
class Category:
    code: str

@dataclass
class Product:

    name: str
    sku: str
    price: float
    categories: list[Category] = field(default=list)


accessor = PropertyAccessor(None)

accessor.set('sku', 't-shirt-01')
accessor.set('name', 't-shirt basic black')
accessor.set('price', 39.9)
accessor.set('categories[0].code', 't-shits')

print(accessor.get('name')) # t-shirt basic black
print(accessor.get('categories[0].code')) # t-shirt


print(accessor.data) # AnonymousObject(sku='t-shirt-01', name='t-shirt basic black', price=39.9, categories=[AnonymousObject(code="t-shirts")])
print(accessor.data.cast(Product)) # Product(sku='t-shirt-01', name='t-shirt basic black', price=39.9, categories=[Category(code="t-shirts")])

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

property_accessor-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

property_accessor-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file property_accessor-0.1.0.tar.gz.

File metadata

  • Download URL: property_accessor-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for property_accessor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 247a2782e22446d0d599398880227a92fa3ebbe62c4b526f7312eb2af2f5256c
MD5 ba40ee94cf6453e43730beeef5fcb39e
BLAKE2b-256 4d45f36a43838139e74e9a4b65592a3778c72a682197ca99621550b8f44107fd

See more details on using hashes here.

File details

Details for the file property_accessor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for property_accessor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1fa1d076034dd126d403c6db76fd80cd632af160b513dcf5ce659bd51760a26
MD5 ff1a1f2ceb9a169973126f2e767171a0
BLAKE2b-256 d39843d1a992f33490d3b5bec55c3f42b2252520c6f3f4704344d11737288042

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