pyparsing.pyparsing_common

Module pyparsing :: Class pyparsing_common |
[frames] | no frames]

# Class pyparsing_common

source code

Here are some common low-level expressions that may be useful in jump-starting parser development:

- numeric forms (integers, reals, scientific notation)
- common programming identifiers
- network addresses (MAC, IPv4, IPv6)
- ISO8601 dates and datetime
- UUID

Parse actions:

- `convertToInteger`
- `convertToFloat`
- `convertToDate`
- `convertToDatetime`
- `stripHTMLTags`

Instance Methods
convertToInteger(s, l, t) Parse action for converting parsed integers to Python int | source code
convertToFloat(s, l, t) Parse action for converting parsed numbers to Python float | source code

Static Methods
convertToDate(fmt=`'``%Y-%m-%d``'`) Helper to create a parse action for converting parsed date string to Python datetime.date | source code
convertToDatetime(fmt=`'``%Y-%m-%dT%H:%M:%S.%f``'`) Helper to create a parse action for converting parsed datetime string to Python datetime.datetime | source code
stripHTMLTags(s, l, tokens) Parse action to remove HTML tags from web page HTML source | source code

Class Variables
| integer = `integer` expression that parses an unsigned integer, returns an int
| hex_integer = `hex integer` expression that parses a hexadecimal integer, returns an int
| signedInteger = `signed integer` expression that parses an integer with optional leading sign, returns an int
| fraction = `fraction` fractional expression of an integer divided by an integer, returns a float
| mixed_integer = `fraction or mixed integer-fraction` mixed integer of the form 'integer - fraction', with optional leading integer, returns float
| real = `real number` expression that parses a floating point number and returns a float
| sciReal = `real number with scientific notation` expression that parses a floating point number with optional scientific notation and returns a float
| numeric = `{real number with scientific notation | real number `...`` any numeric expression, returns the corresponding Python type
| number = `number` any int or real number, returned as float
| identifier = `identifier` typical code identifier (leading alpha or '_', followed by 0 or more alphas, nums, or '_')
| ipv4_address = `IPv4 address` IPv4 address (`0.0.0.0 - 255.255.255.255`)
| ipv6_address = `IPv6 address` IPv6 address (long, short, or mixed form)
| mac_address = `MAC address` MAC address xx:xx:xx:xx:xx (may also have '-' or '.' delimiters)
| iso8601_date = `ISO8601 date` ISO8601 date (`yyyy-mm-dd`)
| iso8601_datetime = `ISO8601 datetime` ISO8601 datetime (`yyyy-mm-ddThh:mm:ss.s(Z|+-00:00)`) - trailing seconds, milliseconds, and timezone optional; accepts separating `'T'` or `' '`
| uuid = `UUID` UUID (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)

Method Details

### convertToDate(fmt=`'``%Y-%m-%d``'`) Static Method | source code
Helper to create a parse action for converting parsed date string to Python datetime.date Params - fmt - format to be passed to datetime.strptime (default=`"%Y-%m-%d"`)

### convertToDatetime(fmt=`'``%Y-%m-%dT%H:%M:%S.%f``'`) Static Method | source code
Helper to create a parse action for converting parsed datetime string to Python datetime.datetime Params - fmt - format to be passed to datetime.strptime (default=`"%Y-%m-%dT%H:%M:%S.%f"`)

Class Variable Details

  ### numeric any numeric expression, returns the corresponding Python type Value:
      {real number with scientific notation | real number | signed integer}