anyconfig.backend.bson

BSON backend.

New in version 0.1.0.

anyconfig.backend.bson._load_opts(use_c=None)

Decide loading options by bson._use_c.

  • No keyword args are permitted for decode_all() if bson._use_c == True
  • bson._use_c looks missing in python 3 version.
Parameters:use_c – bson._use_c
>>> _load_opts(True)
[]
>>> _load_opts(False)
['as_class', 'tz_aware', 'uuid_subtype']

# >>> _load_opts() # <result varies depends on environment...>

class anyconfig.backend.bson.Parser

Bases: anyconfig.backend.base.FromStringLoader, anyconfig.backend.base.ToStringDumper

Loader/Dumper of BSON files.

_type = 'bson'
_extensions = ['bson', 'bsn']
_load_opts = []
_dump_opts = ['check_keys', 'uuid_subtype']
_open_flags = ('rb', 'wb')
dump_to_string(*args, **kwargs)

Encode a document to a new BSON instance.

A document can be any mapping type (like dict).

Raises TypeError if document is not a mapping type, or contains keys that are not instances of basestring (str in python 3). Raises InvalidDocument if document cannot be converted to BSON.

Parameters:
  • document: mapping type representing a document
  • check_keys (optional): check if keys start with ‘$’ or contain ‘.’, raising InvalidDocument in either case

New in version 1.9.

load_from_string(content, **kwargs)

Load BSON config from given string content.

Parameters:
  • content – BSON config content in bytes data string
  • kwargs – optional keyword parameters
Returns:

self.container() object holding config parameters

__module__ = 'anyconfig.backend.bson'

Previous topic

anyconfig.backend.base

Next topic

anyconfig.backend.configobj

This Page