anyconfig.backend.bson

BSON backend:

  • Format to support: BSON, http://bsonspec.org
  • Requirements: bson in pymongo, https://pypi.python.org/pypi/pymongo/
  • Development Status: 3 - Alpha
  • Limitations: It seems that the APIs of bson.decode* were changed a lot in the current version (3.3) of python-bson in pymongo and this backend might not work with it. I don’t have a time to test with that latest version yet and it’s only tested with the older one, 3.3.1.
  • Special options:

Changelog:

    Changed in version 0.8.3:
  • follow changes of options of bson.BSON.{encode,decode} in its upstream and changed or added some keyword options including ones for bson.CodecOptions

    Changed in version 0.5.0:
  • utilize as_class keyword argument to allow container objects made directly on load if C extension is not used and enabled.

  • _load_opts() was removed because C extension looks forced to be enalbed if bson.has_c() == True, that is, C extension was built, installed and used. see also: https://jira.mongodb.org/browse/PYTHON-379

New in version 0.1.0.

anyconfig.backend.bson._codec_options(**options)

bson.BSON.{decode{,_all},encode} can receive bson.CodecOptions.

Returns:CodecOptions
class anyconfig.backend.bson.Parser

Bases: anyconfig.backend.base.StringParser, anyconfig.backend.base.BinaryFilesMixin

Loader/Dumper of BSON files.

_type = 'bson'
_extensions = ['bson', 'bsn']
_load_opts = []
_dump_opts = []
_ordered = False
_dict_opts = []
_load_options(container, **options)
Parameters:container – callble to make a container object later
load_from_string(content, container, **kwargs)

Load BSON config from given string content.

Parameters:
  • content – BSON config content in bytes data string
  • container – callble to make a container object
  • kwargs – optional keyword parameters
Returns:

Dict-like object holding config parameters

dump_to_string(data, **options)

Dump BSON data data to a string.

Parameters:
  • data – BSON Data to dump
  • options – optional keyword parameters to be sanitized
Returns:

string represents the configuration

__module__ = 'anyconfig.backend.bson'