forked from Georg/pyacl
Formatting
For a better code style: - consistent trailing commas - use constant instead of repeated "magic" values Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
191c0fac6a
commit
031593d470
13
pyacl/acl.py
13
pyacl/acl.py
@ -1,4 +1,3 @@
|
||||
#!/usr/bin/python3
|
||||
"""
|
||||
pyacl - high level abstractions over pylibacl
|
||||
Copyright 2024, Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
|
||||
@ -33,16 +32,18 @@ DEFAULT_ENTRYTYPES = [
|
||||
'user',
|
||||
'group',
|
||||
'mask',
|
||||
'other'
|
||||
'other',
|
||||
]
|
||||
|
||||
MAX_PERMBITS = 3
|
||||
|
||||
def acl_reduce_entries(acl):
|
||||
entries = acl.to_any_text().decode().split()
|
||||
entries = [entry for entry in entries if entry not in DEFAULT_ENTRIES]
|
||||
return entries
|
||||
|
||||
def acl_parse_permission(strpermission):
|
||||
if len(strpermission) != 3:
|
||||
if len(strpermission) != MAX_PERMBITS:
|
||||
return ValueError('Invalid permission')
|
||||
|
||||
permap = {
|
||||
@ -78,13 +79,13 @@ def acl_parse_entry(strentry):
|
||||
elif not entryvalue:
|
||||
return ValueError('Invalid entry value')
|
||||
|
||||
if len(permissions) != 3:
|
||||
if len(permissions) != MAX_PERMBITS:
|
||||
raise ValueError('Unsupported amount of permissions')
|
||||
|
||||
return {
|
||||
entrytype: {
|
||||
entryvalue: acl_parse_permission(permissions)
|
||||
}
|
||||
entryvalue: acl_parse_permission(permissions),
|
||||
},
|
||||
}
|
||||
|
||||
def acl_parse_entries(acl):
|
||||
|
Loading…
Reference in New Issue
Block a user