From: Edward Z. Yang Date: Thu, 9 Jul 2009 02:14:56 +0000 (-0400) Subject: Incorporate broder code review number 2: X-Git-Tag: 0.1.0~23^2 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/python-afs.git/commitdiff_plain/c7607e2c1d074431922b99adb8b83c3fa8c16ae7?hp=5f5cebd0db4f7c3723d5cf916f5d9d78eab87962 Incorporate broder code review number 2: * Remove space-aligned fields * Rename crights to readRights * Group functions together * Add space between comma Signed-off-by: Edward Z. Yang --- diff --git a/afs/_acl.pyx b/afs/_acl.pyx index 06736f9..ef65388 100644 --- a/afs/_acl.pyx +++ b/afs/_acl.pyx @@ -16,12 +16,12 @@ cdef struct vcxstat2: afs_int32 anyAccess char mvstat -READ = PRSFS_READ -WRITE = PRSFS_WRITE -INSERT = PRSFS_INSERT -LOOKUP = PRSFS_LOOKUP -DELETE = PRSFS_DELETE -LOCK = PRSFS_LOCK +READ = PRSFS_READ +WRITE = PRSFS_WRITE +INSERT = PRSFS_INSERT +LOOKUP = PRSFS_LOOKUP +DELETE = PRSFS_DELETE +LOCK = PRSFS_LOCK ADMINISTER = PRSFS_ADMINISTER USR0 = PRSFS_USR0 USR1 = PRSFS_USR1 diff --git a/afs/acl.py b/afs/acl.py index a245aa2..da0821f 100644 --- a/afs/acl.py +++ b/afs/acl.py @@ -4,11 +4,11 @@ from _acl import READ, WRITE, INSERT, LOOKUP, DELETE, LOCK, ADMINISTER, \ from _acl import getCallerAccess _canonical = { - "read": "rl", - "write": "rwlidwk", - "all": "rwlidwka", - "mail": "lik", - "none": "", + "read": "rl", + "write": "rwlidwk", + "all": "rwlidwka", + "mail": "lik", + "none": "", } _charBitAssoc = [ @@ -32,27 +32,11 @@ _charBitAssoc = [ _char2bit = dict(_charBitAssoc) -def crights(s): +def readRights(s): """Canonicalizes string rights to bitmask""" if s in _canonical: s = _canonical[s] return _parseRights(s) -class ACL(object): - def __init__(self, pos, neg): - """ - ``pos`` - Dictionary of usernames to positive ACL bitmasks - ``neg`` - Dictionary of usernames to negative ACL bitmasks - """ - self.pos = pos - self.neg = neg - @staticmethod - def retrieve(dir,follow=1): - """Retrieve the ACL for an AFS directory""" - pos, neg = _parseAcl(_acl.getAcl(dir, follow)) - return ACL(pos, neg) - def showRights(r): """Takes a bitmask and returns a rwlidka string""" s = "" @@ -86,3 +70,19 @@ def _parseAcl(inp): neg[name] = int(acl) return (pos, neg) +class ACL(object): + def __init__(self, pos, neg): + """ + ``pos`` + Dictionary of usernames to positive ACL bitmasks + ``neg`` + Dictionary of usernames to negative ACL bitmasks + """ + self.pos = pos + self.neg = neg + @staticmethod + def retrieve(dir, follow=1): + """Retrieve the ACL for an AFS directory""" + pos, neg = _parseAcl(_acl.getAcl(dir, follow)) + return ACL(pos, neg) +