Drop python2 support
This mostly consists in removing the dependency on "six" and updating
the code to use only Python3 idioms.
Notice that we previously used TemporaryDirectory from
cubicweb.devtools.testlib for compatibility with Python2. We now
directly import it from tempfile.
from cubicweb.server import SOURCE_TYPES
from cubicweb.server.serverconfig import (SourceConfiguration,
generate_source_config)
sync_schema_props_perms('EmailAddress')
def update_config(source, **config):
cfg = source.dictconfig
cfg.update(config)
options = SOURCE_TYPES[source.type].options
sconfig = SourceConfiguration(source._cw.vreg.config, options=options)
for opt, val in cfg.items():
try:
sconfig.set_option(opt, val)
except OptionError:
continue
cfgstr = str(generate_source_config(sconfig), source._cw.encoding)
source.cw_set(config=cfgstr)
for source in rql('CWSource X WHERE X type "ldapuser"').entities():
config = source.dictconfig
host = config.pop('host', u'ldap')
protocol = config.pop('protocol', u'ldap')
source.cw_set(url=u'%s://%s' % (protocol, host))
update_config(source, **config)
commit()