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.11.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

tiffler-0.1.11-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

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