Skip to main content

This Niffler finds shiny variables in text

Project description

Tiffler

A Niffler that only likes shiny variables

Installation

pip install -U tiffler

Usage

import tiffler

template = "One {unit} was equal to {num_sickles:int} Sickles or {num_knuts:int} Knuts."
variables = tiffler.scan(
    template, 
    "one Galleon was equal to 17 Sickles or 493 Knuts.", 
    case_sensitive=False
)

print(variables)

#{'unit': 'Galleon', 'num_sickles': 17, 'num_knuts': 493}
import tiffler

template = "\s+{item}: {price:int} {unit:str:\w+}"
bill = """
    Pewter cauldron: 15 galeons,
    Brass cauldron: 21 galeons,
    Copper cauldron: 25 galeons,
"""
for match in tiffler.search(template, bill, case_sensitive=False):
    print(match)

# {'item': 'Pewter cauldron', 'price': 15, 'unit': 'galeons'}
# {'item': 'Brass cauldron', 'price': 21, 'unit': 'galeons'}
# {'item': 'Copper cauldron', 'price': 25, 'unit': 'galeons'}

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

tiffler-0.1.9.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

tiffler-0.1.9-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file tiffler-0.1.9.tar.gz.

File metadata

  • Download URL: tiffler-0.1.9.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for tiffler-0.1.9.tar.gz
Algorithm Hash digest
SHA256 7ac90ffab62d8316befcae66472c66642f6f39943e661351c34b383836eef9cd
MD5 193099c45cf9ee09880ed2ee994cae42
BLAKE2b-256 8dd41966c77329abff036cb7715d08ced00346166e70a56a109b6e309694ad74

See more details on using hashes here.

File details

Details for the file tiffler-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: tiffler-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for tiffler-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5920e34d7690dcadde41e240c4b0d96f340a27867fb3950c3f508b92079ca11f
MD5 4cdd854800b24304bbe985c2afe29dbe
BLAKE2b-256 52b78e28e04d378ca79e8984e544d4da3068977989db0696ca8b86393a2f7c13

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