Skip to main content

Parser for hyerarchical text data and configuration files

Project description

wcfg is a small module to parse hierarchical data from text files, and it is particularly suitable for configuration files.

Features:

  • Text-based, hierarchical format, with simple syntax which is designed to be easy to parse both by programs and humans.

  • Both reading and writing back is supported. Written data is guaranteed to be readable back to its original representation.

  • Small, self-contained, pure Python implementation.

Grammar

This is the grammar accepted by the parser, in [EBNF syntax](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form):

identifier = - ( whitespace | “:” )

string character = - “"”

key-value pair = identifier, “:”, value
identifier, value

octal digit = “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7”

digit = octal digit | “8” | “9”

hexdigit = digit | “a” | “b” | “c” | “d” | “e” | “f”
“A” | “B” | “C” | “D” | “E” | “F”

sign = “-” | “+”

integral number = digit, { digit }

dotted float = “.”, digit, { digit }
digit, “.”, { digit }
exponent = (“e” | “E”), sign, digit, { digit }
(“e” | “E”), digit, { digit }
float number = dotted float
dotted float, exponent
integral number, exponent
number body = integral number
float number
number = “0”, ( “x” | “X” ), hex digit, { hex digit }
“0”, octal digit, { octal digit }
sign, number body
number body
value = “"”, { string character }, “"”
“[”, { value } “]”
“{”, { key-value pair }, “}”
number
input = “{”, { key-value pair }, “}”
{ key-value pair }

Note that comments are not specified in the grammar above does not include comments for the sake of simplicity. Comments can appear anywhere except inside strings, and they span from the octothorpe sign (#) to the end of the line.

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

wcfg-1.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file wcfg-1.tar.gz.

File metadata

  • Download URL: wcfg-1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wcfg-1.tar.gz
Algorithm Hash digest
SHA256 cc4dec0e879ae212c2a8a938a6fb3ad45cac82362a46e16823927d2164de3708
MD5 54edd34d7797cd1bcb841b8dd3ed5f97
BLAKE2b-256 383a5b3a6edae9a9f7f5d1a178bb2b9007437359c70f3f23ceaa810aee3995c7

See more details on using hashes here.

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