dsml
DSMLv1 parser and generator¶
This module parses and generates LDAP data in the format DSMLv1. It is implemented in pure Python and does not rely on any non-standard modules. Therefore it can be used stand-alone without the rest of the python-ldap package.
-
class
dsml.
DSMLWriter
(f, base64_attrs=[], dsml_comment='', indent=' ')¶ Class for writing LDAP entry records to a DSMLv1 file.
Arguments:
- f
- File object for output.
- base64_attrs
- Attribute types to be base64-encoded.
- dsml_comment
- Text placed in comment lines behind <dsml:dsml>.
- indent
- String used for indentiation of next nested level.
Write the footer
-
writeHeader
()¶ Write the header
-
writeRecord
(dn, entry)¶ - dn
- string-representation of distinguished name
- entry
- dictionary holding the LDAP entry {attr:data}
-
class
dsml.
DSMLParser
(input_file, ContentHandlerClass, ignored_attr_types=None, max_entries=0)¶ Base class for a DSMLv1 parser. Applications should sub-class this class and override method handle() to implement something meaningful.
Public class attributes:
- records_read
- Counter for records processed so far
Arguments:
- input_file
- File-object to read the DSMLv1 input from
- ignored_attr_types
- Attributes with these attribute type names will be ignored.
- max_entries
- If non-zero specifies the maximum number of entries to be read from f.
- line_sep
- String used as line separator
-
handle
(*args, **kwargs)¶ Process a single DSMLv1 entry record. This method should be implemented by applications using DSMLParser.
-
parse
()¶ Continously read and parse DSML records