diff --git a/attributs.py b/attributs.py index acf3f62..324c8a3 100644 --- a/attributs.py +++ b/attributs.py @@ -93,7 +93,6 @@ def attrify(val, attr, conn, Parent=None): unicode est passé en argument. Devrait insulter en cas de potentiel problème d'encodage. """ - if isinstance(val, Attr): return val else: @@ -102,7 +101,7 @@ def attrify(val, attr, conn, Parent=None): return CRANS_ATTRIBUTES.get(attr, Attr)(val, conn, Parent) -class AttrsDict(dict) : +class AttrsDict(dict): def __init__(self, conn, ldif={}, Parent=None): super(AttrsDict, self).__init__(ldif) self._conn = conn @@ -1035,80 +1034,9 @@ class dnsIpv6(boolAttr): class machineAlias(boolAttr): pass -### Les classes -ADHERENT_ATTRS = [ nom, prenom, tel, chbre, postalAddress, mail, uid, - canonicalAlias, mailAlias, etudes, paiement, - solde, carteEtudiant, droits, loginShell, blacklist ] - -MACHINE_ATTRS = [ host, macAddress, hostAlias, ipHostNumber, portTCPout, - portTCPin, portUDPout, portUDPin ] - - -CRANS_ATTRIBUTES = { - 'objectClass' : objectClass, - 'cn' : cn, - 'dn' : dn, - - 'aid': aid, - 'uid': uid, - 'nom' : nom, - 'prenom' : prenom, - 'compteWiki' : compteWiki, - 'tel' : tel, - 'paiement' : paiement, - 'controle': controle, - 'derniereConnexion' : derniereConnexion, - 'carteEtudiant' : carteEtudiant, - 'mailAlias' : mailAlias, - 'canonicalAlias' : canonicalAlias, - 'etudes' : etudes, - 'chbre' : chbre, - 'droits' : droits, - 'solde' : solde, - 'gpgFingerprint' : gpgFingerprint, - 'mid' : mid, - 'rid' : rid, - 'host' : host, - 'sshFingerprint' : sshFingerprint, - 'macAddress': macAddress, - 'ipHostNumber': ipHostNumber, - 'ip6HostNumber': ip6HostNumber, - 'hostAlias' : hostAlias, - 'ipsec' : ipsec, - 'puissance' : puissance, - 'canal' : canal, - 'portTCPout' : portTCPout, - 'portTCPin' : portTCPin, - 'portUDPout' : portUDPout, - 'portUDPin' : portUDPin, - 'exempt' : exempt, - 'prise' : prise, - 'nombrePrises' : nombrePrises, - 'hotspot' : hotspot, - 'mailInvalide' : mailInvalide, - 'positionBorne' : positionBorne, - 'nvram' : nvram, - 'contourneGreylist' : contourneGreylist, - 'imprimeurClub' : imprimeurClub, - 'fid' : fid, - 'dnsIpv6' : dnsIpv6, - 'machineAlias' : machineAlias, - 'modePaiement' : modePaiement, - 'recuPaiement' : recuPaiement, - 'cid' : cid, - 'responsable' : responsable, - 'blacklist' : blacklist, - 'historique' : historique, - 'info': info, - 'homepageAlias': homepageAlias, - 'charteMA': charteMA, - 'mail' : mail, - 'postalAddress': postalAddress, - - # {posix,shadow}Account - 'homeDirectory': homeDirectory, - 'loginShell': loginShell, - 'uidNumber': uidNumber, - 'gecos': gecos, - 'gidNumber': gidNumber -} +## Penser à remplacer ça par un dictionnaire en compréhension quand on sera sous wheezy partout +#: Dictionnaire mappant "nom de l'atttribut" -> classe permettant de l'instancier +CRANS_ATTRIBUTES = {} +for (k, v) in locals().items(): + if type(v) == type and issubclass(v, Attr): + CRANS_ATTRIBUTES[k] = v