Add a mechanism for converting an identifier to a PTS ID.
authorEvan Broder <broder@mit.edu>
Wed, 18 Mar 2009 00:45:56 +0000 (20:45 -0400)
committerEvan Broder <broder@mit.edu>
Wed, 18 Mar 2009 00:46:43 +0000 (20:46 -0400)
Signed-off-by: Evan Broder <broder@mit.edu>

afs/_pts.pyx

index 83fa010..8a8937c 100644 (file)
@@ -212,6 +212,17 @@ cdef class PTS:
         ubik_ClientDestroy(self.client)
         rx_Finalize()
 
+    def NameOrId(self, ident):
+        """
+        Given an identifier, convert it to a PTS ID by looking up the
+        name if it's a string, or otherwise just converting it to an
+        integer.
+        """
+        if isinstance(ident, (str, unicode)):
+            return self.NameToId(ident)
+        else:
+            return int(ident)
+
     def NameToId(self, name):
         """
         Converts a user or group to an AFS ID.