Skip to main content

A library for manipulating eXtra BootConfig (XBC) files

Project description

py-xbc

py-xbc is a pure-Python library for reading and writing files in the eXtra BootConfig (XBC) file format specified by the Linux kernel. This is not a strictly-conforming implementation: in particular, this implementation does not enforce the 32,767-byte ceiling on XBC files, nor does it enforce the 16-level cap on keys and blocks.

Requirements

py-xbc currently requires pyparsing and Python 3.7+.

Usage

py-xbc exports four functions:

  • loads_xbc parses a string.
  • load_xbc opens a file and then parses a string.
  • saves_xbc renders to a string.
  • save_xbc renders to a string and writes the string to a file.

Format

XBC files consist of a series of statements, of which there are three kinds:

  • A key is a sequence of one or more bytes in the range a-zA-Z0-9_-. They are namespaced with periods (.) and may be followed by an equals sign (=). Key statements are terminated by a semicolon (;), a linefeed, or a semicolon followed by a linefeed.

  • A key/value statement is a key followed by an operator, followed in turn by one or more values. There are three operators:

    • Assignment (=) specifies an initial value.
    • Updates (:=) overwrites whatever value was previously there.
    • Appends (+=) appends one or more values.

    There are two kinds of values: strings and arrays. Strings can be either 'bare' or quoted.

    • Bare strings are a sequence of one or more bytes that are not in the range {}#=+:;,\n'" .
    • Quoted strings are a sequence of bytes that begins with a single quote (') or a double quote (") and ends only with the same quote. Quotes cannot be escaped.
    • Arrays are a sequence of one or more values delimited by a comma (,).
  • A block is a key followed by a pair of curly braces, inside which is one or more key or key/value statements.

Keys are composable. The following examples are equivalent:

foo {
    bar {
        fluff = 1
    }
}
# is equivalent to
foo.bar.fluff = 1
# is equivalent to
foo.bar { fluff = 1 }
# is equivalent to
foo { bar.fluff = 1 }

Licence

py-xbc is published under the MIT license. See LICENSE.txt for more information.

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

py-xbc-0.1.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

py_xbc-0.1.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file py-xbc-0.1.2.tar.gz.

File metadata

  • Download URL: py-xbc-0.1.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for py-xbc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 420ba7a7e33b635f4cd05aff5be052fb92504554e02278d1d31eb069cacb5c2d
MD5 3d24eb79387395c803b3488e67b2ce99
BLAKE2b-256 397c952ecae9bf7d761c8e6e912563bec715db96a861d0d9adaf6810065f7511

See more details on using hashes here.

File details

Details for the file py_xbc-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: py_xbc-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for py_xbc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1f12622c702c99c3f0f813c87b74e6d748106e6b34ad73a44c012715607d5b7e
MD5 0008b335acb88a071878c2b5c43fca6a
BLAKE2b-256 fc6a4c932ef1b39b09989ed33b5b398c4352c86822c8251d1092defc668ce9b1

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