Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Text Parsing Function Dispatcher

Project Description

TPFD is an easy way to parse strings and execute functions depending on their contents.

Inspired by Flask and using Parse under the hood, this allows you to decorate functions with grammar rules and if a pattern that matches one of your grammar rules is found, the function will be run with a set of keyword arguments you’ve specified passed to it! Great for parsing logs and executing macros on what it finds!


Turtles are cool
Sloths are cool
Mosquitos are dumb

>>> p  = tpfd.Parser()

>>> @p.on_parse('{Animal} are cool')
    def main(animal):
        print('I like {0}.'.format(animal))

>>> p.parse_file('animals.txt')
'I like turtles.'
'I like sloths.'

>>> p.parse(['Turtles are cool', 'Sloths are cool', 'Mosquitos are dumb'])
'I like turtles.'
'I like sloths.'

>>> p.parse('Sloths are cool')
'I like sloths.'

>>> p.parse('Mosquitos are dumb')

>>> @p.on_find('>{}<')
    def find_example(words):
    print (words)

>>> p.find('<p>the <b>bold</b> text</p>')
'the bold text'

To Install

$ pip install tpfd


Any format spec supported by parse is supported by this library since it’s all parse under the hood. Example: {[field name]:[format spec]}

Current Features

  • Support for parsing text files
  • Support for accepting generators that output text or ints
  • Support for parsing unicode strings
  • Supports parsing strings, ints and interator/generator’s automagically with new parse method.


  • Expose custom types functionality that Parse already offers

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(6.6 kB) Copy SHA256 Hash SHA256
any Wheel Sep 24, 2016
(4.3 kB) Copy SHA256 Hash SHA256
Source Sep 24, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting