examples Package

This package is a series of self contained examples that use partpy to accomplish their goal. All complete examples are included in the test suite to check their output and that they function.

contacts Module

SourceString utilizes SourceString to provide some simple string matching functionality.

class examples.contacts.ContactsParser(string=None)[source]

Bases: partpy.sourcestring.SourceString

The contacts parser will simply look for name and website pairs while disregarding any kind of whitespace and store them in a dict.

parse()[source]

Run the parser over the entire sourestring and return the results.

parse_contact()[source]

Parse a top level contact expression, these consist of a name expression a special char and an email expression.

The characters found in a name and email expression are returned.

parse_email()[source]

Email address parsing is done in several stages. First the name of the email use is determined. Then it looks for a ‘@’ as a delimiter between the name and the site. Lastly the email site is matched.

Each part’s string is stored, combined and returned.

parse_name()[source]

This function uses string patterns to match a title cased name. This is done in a loop until there are no more names to match so as to be able to include surnames etc. in the output.

parse_top_level()[source]

The top level parser will do a loop where it looks for a single contact parse and then eats all whitespace until there is no more input left or another contact is found to be parsed and stores them.

parse_whitespace()[source]

This function simply eats chars until the current char is no longer a space, tab, newline.

Project Versions

Table Of Contents

Previous topic

partpy Package

This Page