Table of Contents

Module: __init__ Martel/__init__.py
Imported modules   
import Expression
import convert_re
import string
from xml.sax import xmlreader
Functions   
Alt
Any
AnyBut
Assert
AssertNot
Bol
Case
DelimitedFields
Digits
Empty
Eof
Eol
Float
Group
Integer
MaxRepeat
Opt
Punctuation
Re
Rep
Rep1
RepN
Seq
SimpleRecordFilter
SkipLinesTo
SkipLinesUntil
Spaces
Str
Str1
ToEol
ToSep
Unprintable
UntilEol
UntilSep
Word
_fix_newlines
_group
replace_groups
select_names
  Alt 
Alt ( *args )

exp1, exp2, ... -> match exp1 or (if that fails) match exp2 or ...

  Any 
Any ( s )

(s) -> match any character in s

  AnyBut 
AnyBut ( s )

s -> match any character not in s

  Assert 
Assert ( expression )

  AssertNot 
AssertNot ( expression )

  Bol 
Bol ()

Exceptions   
NotImplementedError
  Case 
Case ( expr )

Exceptions   
NotImplementedError
  DelimitedFields 
DelimitedFields (
        name=None,
        sep=None,
        attrs=None,
        )

match 0 or more fields seperated by the given seperator(s)

This is useful for parsing space, tab, color, or other character delimited fields. There is no default seperator.

If name is not None, the delimited text, excluding the seperator, will be put inside groups of the given name. You can optionally include group attributes. The seperator character is consumed, but not accessible using a group.

Neither "\r" nor "\n" may be used as a seperator. The line as a whole is not included in a group.

Exceptions   
TypeError( "Must specify a sep (via the 'sep' parameter)" )
  Digits 
Digits ( name=None,  attrs=None )

match one or more decimal digits

This is the same as (?P<name?attrs>\d+).

If name is not None, the matching text will be put inside a group of the given name. You can optionally include group attributes.

  Empty 
Empty ()

Exceptions   
NotImplementedError
  Eof 
Eof ()

Exceptions   
NotImplementedError
  Eol 
Eol ()

Exceptions   
NotImplementedError
  Float 
Float ( name=None,  attrs=None )

match floating point numbers like 6, 6., -.1, 2.3, +4E-5, ...

If name is not None, the matching text will be put inside of a group of the given name. You can optionally include group attributes.

  Group 
Group (
        name,
        expr,
        attrs=None,
        )

name, expr -> use name to describe a successful match of the expression

  Integer 
Integer ( name=None,  attrs=None )

match an integer (digits w/ optional leading + or - sign)

If name is not None, the matching text will be put inside a group of the given name. You can optionally include group attributes.

  MaxRepeat 
MaxRepeat (
        expr,
        min_count,
        max_count=Expression.MAXREPEAT,
        )

expr, min_count, max_count = 65535 -> match between min- and max_count times

If max_count == 65535 (which is Expression.MAXREPEAT) then there is no upper limit.

  Opt 
Opt ( expr )

expr -> match expr 1 or 0 times

  Punctuation 
Punctuation ( name=None,  attrs=None )

match a punctuation character (characters in string.punctuation)

If name is not None, the matching text will be put inside of a group of the given name. You can optionally include group attributes.

  Re 
Re ( pattern,  fix_newlines=0 )

pattern -> the expression tree for the regexp pattern string

  Rep 
Rep ( expr )

expr -> match expr as many times as possible, even 0 time

  Rep1 
Rep1 ( expr )

expr -> match expr as many times as possible, but at least once

  RepN 
RepN ( expr,  count )

expr, count -> match the expression count number of time

This option is handy for named group repeats since you don't have to use the name twice; for the min_count and max_count fields.

  Seq 
Seq ( *args )

exp1, exp2, ... -> match exp1 followed by exp2 followed by ...

  SimpleRecordFilter 
SimpleRecordFilter (
        expr,
        make_reader,
        reader_args=(),
        )

  SkipLinesTo 
SkipLinesTo ( expr )

read and ignore lines up to and including, the line matching expr

  SkipLinesUntil 
SkipLinesUntil ( expr )

read and ignore lines up to, but excluding, the line matching expr

  Spaces 
Spaces ( name=None,  attrs=None )

match one or more whitespace (except newline)

"Spaces" is defined as [\t\v\f\r ]+, which is not the same as \s+. (It's missing the \n, which is useful since you almost never mean for whitespace to go beyond the newline.)

If name is not None, the matching text will be put inside of a group of the given name. You can optionally include group attributes.

  Str 
Str ( *args )

(s1, s2, ...) -> match s1 or s2 or ...

  Str1 
Str1 ( s )

(s) -> match the literal string

  ToEol 
ToEol ( name=None,  attrs=None )

match everything up to and including the end of line

If name is not None, the matching text, except for the newline, will be put inside a group of the given name. You can optionally include group attributes.

  ToSep 
ToSep (
        name=None,
        sep=None,
        attrs=None,
        )

match all characters up to the given seperator(s)

This is useful for parsing space, tab, color, or other character delimited fields. There is no default seperator character.

If name is not None, the matching text, except for the seperator will be put inside a group of the given name. You can optionally include group attributes. The seperator character will also be consumed.

Neither "\r" nor "\n" may be used as a seperator

Exceptions   
TypeError( "Must specify a seperator (the 'sep' parameter)" )
  Unprintable 
Unprintable ( name=None,  attrs=None )

match an unprintable character (characters not in string.printable)

If name is not None, the matching text will be put inside of a group of the given name. You can optionally include group attributes.

  UntilEol 
UntilEol ( name=None,  attrs=None )

match everything up to but not including the end of line

If name is not None, the matching text, except for the newline, will be put inside a group of the given name. You can optionally include group attributes.

  UntilSep 
UntilSep (
        name=None,
        sep=None,
        attrs=None,
        )

match all characters up to the given seperators(s)

This is useful for parsing space, tab, color, or other character delimited fields. There is no default seperator.

If name is not None, the matching text, except for the seperator will be put inside a group of the given name. You can optionally include group attributes. The seperator character will not be consumed.

Neither "\r" nor "\n" may be used as a seperator.

Exceptions   
TypeError( "Must specify a seperator (the 'sep' parameter)" )
  Word 
Word ( name=None,  attrs=None )

match a word

A word is defined as \w+, and \w is [a-zA-Z0-9_].

If name is not None, the matching text will be put inside of a group of the given name. You can optionally include group attributes.

In other words, this is the short way to write (?P<name>\w+).

  _fix_newlines 
_fix_newlines ( s )

  _group 
_group (
        name,
        exp,
        attrs,
        )

helper function

  replace_groups 
replace_groups ( expr,  replacements )

  select_names 
select_names ( expression,  names )

Use this to prune out group names you aren't interested in seeing, which reduces the number of method calls back to the parser.


Table of Contents

This document was automatically generated on Mon Jul 1 12:03:20 2002 by HappyDoc version 2.0.1