From 09b4d45674f9d37d44c68f52c9a965b14b7e336f Mon Sep 17 00:00:00 2001 From: Jonathan Reed Date: Fri, 13 Nov 2009 17:04:41 -0500 Subject: [PATCH] Change order of bits in list of tuples to return ACLS in same format as AFS (rlidwka vs rwildka). Add ability to turn a rights string into a canonical name Signed-off-by: Jonathan Reed --- afs/acl.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/afs/acl.py b/afs/acl.py index c49f374..a5293bd 100644 --- a/afs/acl.py +++ b/afs/acl.py @@ -11,12 +11,14 @@ _canonical = { "none": "", } +_reverseCanonical = dict((y, x) for (x, y) in _canonical.iteritems()) + _charBitAssoc = [ ('r', READ), - ('w', WRITE), - ('i', INSERT), ('l', LOOKUP), + ('i', INSERT), ('d', DELETE), + ('w', WRITE), ('k', LOCK), ('a', ADMINISTER), ('A', USR0), @@ -32,6 +34,13 @@ _charBitAssoc = [ _char2bit = dict(_charBitAssoc) +def rightsToEnglish(s): + """Turns a rlwidwka string into a canonical name if possible""" + if s in _reverseCanonical: + return _reverseCanonical[s] + else: + return '' + def readRights(s): """Canonicalizes string rights to bitmask""" if s in _canonical: s = _canonical[s] -- 1.7.9.5