[attributs.py] On génère CRANS_ATTRIBUTES plutôt que de le hardcoder.
C'est dommage que j'aie pas le droit de faire un dico en compréhension…
This commit is contained in:
parent
aca08a4773
commit
d47b2febc7
1 changed files with 7 additions and 79 deletions
86
attributs.py
86
attributs.py
|
@ -93,7 +93,6 @@ def attrify(val, attr, conn, Parent=None):
|
||||||
unicode est passé en argument.
|
unicode est passé en argument.
|
||||||
Devrait insulter en cas de potentiel problème d'encodage.
|
Devrait insulter en cas de potentiel problème d'encodage.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(val, Attr):
|
if isinstance(val, Attr):
|
||||||
return val
|
return val
|
||||||
else:
|
else:
|
||||||
|
@ -102,7 +101,7 @@ def attrify(val, attr, conn, Parent=None):
|
||||||
return CRANS_ATTRIBUTES.get(attr, Attr)(val, conn, Parent)
|
return CRANS_ATTRIBUTES.get(attr, Attr)(val, conn, Parent)
|
||||||
|
|
||||||
|
|
||||||
class AttrsDict(dict) :
|
class AttrsDict(dict):
|
||||||
def __init__(self, conn, ldif={}, Parent=None):
|
def __init__(self, conn, ldif={}, Parent=None):
|
||||||
super(AttrsDict, self).__init__(ldif)
|
super(AttrsDict, self).__init__(ldif)
|
||||||
self._conn = conn
|
self._conn = conn
|
||||||
|
@ -1035,80 +1034,9 @@ class dnsIpv6(boolAttr):
|
||||||
class machineAlias(boolAttr):
|
class machineAlias(boolAttr):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
### Les classes
|
## Penser à remplacer ça par un dictionnaire en compréhension quand on sera sous wheezy partout
|
||||||
ADHERENT_ATTRS = [ nom, prenom, tel, chbre, postalAddress, mail, uid,
|
#: Dictionnaire mappant "nom de l'atttribut" -> classe permettant de l'instancier
|
||||||
canonicalAlias, mailAlias, etudes, paiement,
|
CRANS_ATTRIBUTES = {}
|
||||||
solde, carteEtudiant, droits, loginShell, blacklist ]
|
for (k, v) in locals().items():
|
||||||
|
if type(v) == type and issubclass(v, Attr):
|
||||||
MACHINE_ATTRS = [ host, macAddress, hostAlias, ipHostNumber, portTCPout,
|
CRANS_ATTRIBUTES[k] = v
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue