FPIBG Utility
|
Classes | |
class | AttrDict |
class | BoolToken |
class | ConfigParseError |
class | ConfigSerializeError |
class | FltToken |
class | IntToken |
class | LibconfArray |
class | LibconfInt64 |
class | LibconfList |
class | Parser |
class | StrToken |
class | Token |
class | Tokenizer |
class | TokenStream |
Functions | |
isstr (s) | |
isint (i) | |
decode_escapes (s) | |
compile_regexes (token_map) | |
load (f, filename=None, includedir='') | |
loads (string, filename=None, includedir='') | |
is_long_int (i) | |
dump_int (i) | |
dump_string (s) | |
get_dump_type (value) | |
get_array_value_dtype (lst) | |
dump_value (key, value, f, indent=0) | |
dump_collection (cfg, f, indent=0) | |
dump_dict (cfg, f, indent=0) | |
dumps (cfg) | |
dump (cfg, f) | |
main () | |
Variables | |
LONGTYPE = long | |
int | SMALL_INT_MIN = -2**31 |
int | SMALL_INT_MAX = 2**31 - 1 |
ESCAPE_SEQUENCE_RE = re.compile(, re.UNICODE | re.VERBOSE) | |
SKIP_RE = re.compile(r'\s+|#.*$|//.*$|/\*(.|\n)*?\*/', re.MULTILINE) | |
UNPRINTABLE_CHARACTER_RE = re.compile(r'[\x00-\x1F\x7F]') | |
libconf.compile_regexes | ( | token_map | ) |
libconf.decode_escapes | ( | s | ) |
Unescape libconfig string literals
libconf.dump | ( | cfg, | |
f ) |
Serialize ``cfg`` as a libconfig-formatted stream into ``f`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). ``f`` must be a ``file``-like object with a ``write()`` method.
libconf.dump_collection | ( | cfg, | |
f, | |||
indent = 0 ) |
Save a collection of attributes
libconf.dump_dict | ( | cfg, | |
f, | |||
indent = 0 ) |
Save a dictionary of attributes
libconf.dump_int | ( | i | ) |
Stringize ``i``, append 'L' suffix if necessary
libconf.dump_string | ( | s | ) |
Stringize ``s``, adding double quotes and escaping as necessary Backslash escape backslashes, double quotes, ``\f``, ``\n``, ``\r``, and ``\t``. Escape all remaining unprintable characters in ``\xFF``-style. The returned string will be surrounded by double quotes.
libconf.dump_value | ( | key, | |
value, | |||
f, | |||
indent = 0 ) |
Save a value of any libconfig type This function serializes takes ``key`` and ``value`` and serializes them into ``f``. If ``key`` is ``None``, a list-style output is produced. Otherwise, output has ``key = value`` format.
libconf.dumps | ( | cfg | ) |
Serialize ``cfg`` into a libconfig-formatted ``str`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). Returns the formatted string.
libconf.get_array_value_dtype | ( | lst | ) |
Return array value type, raise ConfigSerializeError for invalid arrays Libconfig arrays must only contain scalar values and all elements must be of the same libconfig data type. Raises ConfigSerializeError if these invariants are not met. Returns the value type of the array. If an array contains both int and long int data types, the return datatype will be ``'i64'``.
libconf.get_dump_type | ( | value | ) |
Get the libconfig datatype of a value Return values: ``'d'`` (dict), ``'l'`` (list), ``'a'`` (array), ``'i'`` (integer), ``'i64'`` (long integer), ``'b'`` (bool), ``'f'`` (float), or ``'s'`` (string). Produces the proper type for LibconfList, LibconfArray, LibconfInt64 instances.
libconf.is_long_int | ( | i | ) |
Return True if argument should be dumped as int64 type Either because the argument is an instance of LibconfInt64, or because it exceeds the 32bit integer value range.
libconf.isint | ( | i | ) |
libconf.isstr | ( | s | ) |
libconf.load | ( | f, | |
filename = None, | |||
includedir = '' ) |
Load the contents of ``f`` (a file-like object) to a Python object The returned object is a subclass of ``dict`` that exposes string keys as attributes as well. Example: >>> with open('test/example.cfg') as f: ... config = libconf.load(f) >>> config['window']['title'] 'libconfig example' >>> config.window.title 'libconfig example'
libconf.loads | ( | string, | |
filename = None, | |||
includedir = '' ) |
Load the contents of ``string`` to a Python object The returned object is a subclass of ``dict`` that exposes string keys as attributes as well. Example: >>> config = libconf.loads('window: { title: "libconfig example"; };') >>> config['window']['title'] 'libconfig example' >>> config.window.title 'libconfig example'
libconf.main | ( | ) |
Open the libconfig file specified by sys.argv[1] and pretty-print it
libconf.ESCAPE_SEQUENCE_RE = re.compile(, re.UNICODE | re.VERBOSE) |
libconf.LONGTYPE = long |
libconf.SKIP_RE = re.compile(r'\s+|#.*$|//.*$|/\*(.|\n)*?\*/', re.MULTILINE) |
int libconf.SMALL_INT_MAX = 2**31 - 1 |
int libconf.SMALL_INT_MIN = -2**31 |
libconf.UNPRINTABLE_CHARACTER_RE = re.compile(r'[\x00-\x1F\x7F]') |