from .config import LDAPMigrationConfiguration
from .idict import CaseInsensitiveDict
-__version__ = '0.5.3'
+__version__ = '0.5.4'
LOG = logging.getLogger(__name__)
CFG_BASENAME = 'ldap-migration.ini'
self.all_dns_file = None
self.structural_dns_file = None
- self.object_classes = {}
- self.attribute_types = {}
+ self.object_classes = CaseInsensitiveDict()
+ self.attribute_types = CaseInsensitiveDict()
self.dns = CaseInsensitiveDict()
self.struct_dns = CaseInsensitiveDict()
"""
res = super(LDAPMigrationApplication, self).as_dict(short=short)
+ res['object_classes'] = self.object_classes.as_dict(short=short)
+ res['attribute_types'] = self.attribute_types.as_dict(short=short)
res['cfg_dir'] = self.cfg_dir
res['cfg_file'] = self.cfg_file
res['dns'] = self.dns.as_dict(short=short)
first = False
if is_sequence(object_class.name):
for oc_name in object_class.name:
- name_lc = oc_name.lower()
oc = {
- 'single_name': oc_name,
'name': object_class.name,
'oid': object_class.oid,
'description': object_class.description,
'experimental': object_class.experimental,
'raw_definition': object_class.raw_definition,
}
- self.object_classes[name_lc] = oc
+ self.object_classes[oc_name] = oc
else:
- name_lc = object_class.name.lower()
+ oc_name = object_class.name
oc = {
- 'single_name': object_class.name,
'name': object_class.name,
'oid': object_class.oid,
'description': object_class.description,
'experimental': object_class.experimental,
'raw_definition': object_class.raw_definition,
}
- self.object_classes[name_lc] = oc
+ self.object_classes[oc_name] = oc
- LOG.debug("Found {} ObjectClasses.".format(len(self.object_classes.keys())))
+ LOG.debug("Found {} ObjectClasses.".format(len(self.object_classes)))
if self.verbose > 2:
if self.verbose > 3:
- LOG.debug("Discovered ObjectClasses:\n" + pp(self.object_classes))
+ LOG.debug("Discovered ObjectClasses:\n" + pp(self.object_classes.as_dict()))
else:
- tmp_dict = {}
- for oc_name in self.object_classes.keys():
- tmp_dict[oc_name] = self.object_classes[oc_name]['single_name']
- LOG.debug("Discovered ObjectClasses:\n" + pp(tmp_dict))
+ LOG.debug("Discovered ObjectClasses:\n" + pp(list(self.object_classes.keys())))
# -------------------------------------------------------------------------
def discover_target_attribute_types(self):
if is_sequence(atype.name):
for at_name in atype.name:
- name_lc = at_name.lower()
at = {
- 'single_name': at_name,
'name': atype.name,
'oid': atype.oid,
'description': atype.description,
'syntax': atype.syntax,
'usage': atype.usage,
}
- self.attribute_types[name_lc] = at
+ self.attribute_types[at_name] = at
else:
- name_lc = atype.name.lower()
+ at_name = atype.name
at = {
- 'single_name': atype.name,
'name': atype.name,
'oid': atype.oid,
'description': atype.description,
'syntax': atype.syntax,
'usage': atype.usage,
}
- self.attribute_types[name_lc] = at
+ self.attribute_types[at_name] = at
- LOG.debug("Found {} AttributeTypes.".format(len(self.attribute_types.keys())))
- if self.verbose > 2:
+ LOG.debug("Found {} AttributeTypes.".format(len(self.attribute_types)))
+ if self.verbose > 1:
if self.verbose > 3:
- LOG.debug("Discovered AttributeTypes:\n" + pp(self.attribute_types))
+ LOG.debug("Discovered AttributeTypes:\n" + pp(self.attribute_types.as_dict()))
else:
- tmp_dict = {}
- for name_lc in self.attribute_types.keys():
- tmp_dict[name_lc] = self.attribute_types[name_lc]['single_name']
- LOG.debug("Discovered AttributeTypes:\n" + pp(tmp_dict))
+ LOG.debug("Discovered AttributeTypes:\n" + pp(list(self.attribute_types.keys())))
# -------------------------------------------------------------------------
def check_tmp_dir(self):
def lookup_for_attrtype(self, attrtype, silent=True):
at_lc = attrtype.lower()
- if at_lc not in self.attribute_types:
+ canon_attrtype = self.attribute_types.get_key(attrtype, strict=False)
+ if canon_attrtype is None:
msg = "AttributeType {!r} not found.".format(attrtype)
if silent:
if self.verbose > 2:
LOG.error(msg)
return None
- new_at = self.attribute_types[at_lc]['single_name']
- return new_at
+ return canon_attrtype
# -------------------------------------------------------------------------
def mangle_dn_token(self, old_token):
LOG.info("Found {nr} structural items in subtree of {sfx!r}.".format(
nr=count_dns, sfx=self.config.suffix))
- if self.verbose > 2:
+ if self.verbose > 3:
LOG.debug("Registred structural DN tokens:\n{}".format(pp(self.struct_dns.as_dict())))
# -------------------------------------------------------------------------