[cimetiere] Le module cimetiere est stateless et ne dépend pas d'une connection ldap
On ajoute une fonction ppour chercher dans le cimetière à la classe lc_ldap : gravedig
This commit is contained in:
parent
2a6f5d6a9a
commit
c0054a070c
2 changed files with 15 additions and 9 deletions
13
cimetiere.py
13
cimetiere.py
|
@ -1,12 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
import shortcuts
|
||||
import lc_ldap
|
||||
import filter2 as filter
|
||||
|
||||
conn=shortcuts.lc_ldap_admin()
|
||||
|
||||
cimetiere_root = '/home/cimetiere_lc'
|
||||
|
||||
def find_in_filter(lf, key):
|
||||
|
@ -24,9 +21,9 @@ def find_in_filter(lf, key):
|
|||
def valide_filter(lf, ldif):
|
||||
if lf:
|
||||
if lf[0] == '=':
|
||||
return True if [i for i in ldif.get(lf[1], [lf[2]]) if lf[2] in i] else False
|
||||
return True if [i for i in ldif.get(lf[1], [lf[2]]) if lf[2].lower() in i.lower()] else False
|
||||
elif lf[0] == '!=':
|
||||
return False if [i for i in ldif.get(lf[1], []) if lf[2] in i] else True
|
||||
return False if [i for i in ldif.get(lf[1], []) if lf[2].lower() in i.lower()] else True
|
||||
elif lf[0] == '|':
|
||||
return reduce(lambda x,y: x or y, [valide_filter(i, ldif) for i in lf[1:]] + [False, False])
|
||||
elif lf[0] == '&':
|
||||
|
@ -47,7 +44,7 @@ def condition((fdate, ftime, fdn, path), date=None, aid=None, mid=None, fl=None)
|
|||
if not ("mid=%s," % mid) in fdn:
|
||||
return False
|
||||
if fl:
|
||||
(dn, ldif)= conn.ressuscite_build_ldif(path)
|
||||
(dn, ldif)= lc_ldap.lc_ldap.ressuscite_build_ldif(path)
|
||||
return valide_filter(fl, ldif)
|
||||
return True
|
||||
|
||||
|
@ -68,5 +65,5 @@ def find(type, fl=None, date=None):
|
|||
name=os.path.basename(file)
|
||||
(fdate, time, dn) = name.split('_')
|
||||
if condition((fdate, time, dn, file), fl=fl, aid=aid, mid=mid, date=date):
|
||||
valid.append(conn.ressuscite(file))
|
||||
valid.append(file)
|
||||
return valid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue