Base Dumper¶
dumper
contains Dumper
only,
which is an abstract base class for all dumpers, eg. VueJS
,
JSON
, PLIST
,
Tree
, and XML
.
Dumper class¶
-
class
dictdumper.dumper.
Dumper
(fname, **kwargs)[source]¶ Bases:
object
Abstract base class of all dumpers.
>>> dumper = Dumper(file_name) >>> dumper(content_dict_1, name=content_name_1) >>> dumper(content_dict_2, name=content_name_2) ............
- Variables
-
_hsrt
= ''¶ Dumper head string.
-
_hend
= ''¶ Dumper tail string.
-
static
make_object
(o, value, **kwargs)[source]¶ Create an object with convertion information.
- Parameters
o (Any) – object to convert
value (Any) – converted value of
o
**kwargs – additional information for the convertion
- Returns
Information context of the convertion.
- Return type
Dict[str, Any]
-
object_hook
(o)[source]¶ Convert content for function call.
- Parameters
o (Any) – object to convert
- Returns
the converted object
- Return type
Any
-
default
(o)[source]¶ Check content type for function call.
- Parameters
o (Any) – object to check
- Raises
DumperError –
o
is an unsupported content type
-
__init__
(fname, **kwargs)[source]¶ Initialise dumper.
- Parameters
fname (str) – output file name
**kwargs – addition keyword arguments for initialisation
-
_dump_header
(**kwargs)[source]¶ Initially dump file heads and tails.
- Keyword Arguments
**kwargs – Arbitrary keyword arguments.
-
_encode_value
(o)[source]¶ Convert content for function call.
- Parameters
o (Any) – object to convert
- Returns
the converted object
- Return type
Any
See also
The function is a direct wrapper for
object_hook()
.
-
abstract
_append_value
(value, file, name)[source]¶ Call this function to write contents.
- Parameters
value (Dict[str, Any]) – content to be dumped
file (io.TextIOWrapper) – output file
name (str) – name of current content block