lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1642 - nss-pam-ldapd/pynslcd

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1642 - nss-pam-ldapd/pynslcd



Author: arthur
Date: Fri Mar 16 16:00:02 2012
New Revision: 1642
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1642&view=revision

Log:
support the upper and lower functions in attribute mapping expressions

Modified:
   nss-pam-ldapd/pynslcd/attmap.py

Modified: nss-pam-ldapd/pynslcd/attmap.py
==============================================================================
--- nss-pam-ldapd/pynslcd/attmap.py     Fri Mar 16 14:53:17 2012        (r1641)
+++ nss-pam-ldapd/pynslcd/attmap.py     Fri Mar 16 16:00:02 2012        (r1642)
@@ -99,6 +99,16 @@
                 return
             self.op = c + value.next()
             self.expr = Expression(value, endat='}')
+        elif c == '(':
+            self.name = None
+            self.op = value.get_name()
+            c = value.next()
+            if c != '(':
+                raise ValueError("Expecting '('")
+            self.expr = Expression(value, endat=')')
+            c = value.next()
+            if c != ')':
+                raise ValueError("Expecting ')'")
         else:
             value.back()
             self.name = value.get_name()
@@ -111,11 +121,16 @@
             return value if value else self.expr.value(variables)
         elif self.op == ':+':
             return self.expr.value(variables) if value else ''
+        elif self.op == 'lower':
+            return self.expr.value(variables).lower()
+        elif self.op == 'upper':
+            return self.expr.value(variables).upper()
         return value
 
     def variables(self, results):
         """Add the variables used in the expression to results."""
-        results.add(self.name)
+        if self.name:
+            results.add(self.name)
         if self.expr:
             self.expr.variables(results)
 
@@ -159,7 +174,7 @@
         return res
 
     def variables(self, results=None):
-        """Return the attributes defined in the expression."""
+        """Return the variables defined in the expression."""
         if not results:
             results = set()
         for x in self.expr:
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/