Skip to main content

Cross platform string syntax for reliably extracting object data

Project description

Cross platform string syntax for reliably extracting object data

Usage examples

import Populater

Person = {
    "age": 17,
    "name": {
        "first": "Marty",
        "last": "Mcfly",
        "full": "Marty Mcfly"
    }
}
ctx                               =  Populater( Person )

assert ctx('{{ age }}')                   == '17'
assert ctx('< age')                       == 17
assert ctx('= {{ age }}')                 == 17
assert ctx("< name.first")                == "Marty"
assert ctx("= {{ age }} > 18")            is True
assert ctx("{{ name.none }}")             == ""
assert ctx("= {{ name.none }}")           is None
assert ctx(":= {{ name.full }}")          == "= Marty Mcfly"
assert ctx("= '= {{ name.full }}'")       == "= Marty Mcfly"
assert ctx(":: {{ name.full }}")          == ": Marty Mcfly"
assert ctx("= self['name']['full']")      == "Marty Mcfly"

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

populater-0.1.5.tar.gz (3.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page