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:
Georg Pfuetzenreuter 2024-09-16 03:47:31 +02:00
parent 191c0fac6a
commit 031593d470
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57

View File

@ -1,4 +1,3 @@
#!/usr/bin/python3
""" """
pyacl - high level abstractions over pylibacl pyacl - high level abstractions over pylibacl
Copyright 2024, Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net> Copyright 2024, Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
@ -33,16 +32,18 @@ DEFAULT_ENTRYTYPES = [
'user', 'user',
'group', 'group',
'mask', 'mask',
'other' 'other',
] ]
MAX_PERMBITS = 3
def acl_reduce_entries(acl): def acl_reduce_entries(acl):
entries = acl.to_any_text().decode().split() entries = acl.to_any_text().decode().split()
entries = [entry for entry in entries if entry not in DEFAULT_ENTRIES] entries = [entry for entry in entries if entry not in DEFAULT_ENTRIES]
return entries return entries
def acl_parse_permission(strpermission): def acl_parse_permission(strpermission):
if len(strpermission) != 3: if len(strpermission) != MAX_PERMBITS:
return ValueError('Invalid permission') return ValueError('Invalid permission')
permap = { permap = {
@ -78,13 +79,13 @@ def acl_parse_entry(strentry):
elif not entryvalue: elif not entryvalue:
return ValueError('Invalid entry value') return ValueError('Invalid entry value')
if len(permissions) != 3: if len(permissions) != MAX_PERMBITS:
raise ValueError('Unsupported amount of permissions') raise ValueError('Unsupported amount of permissions')
return { return {
entrytype: { entrytype: {
entryvalue: acl_parse_permission(permissions) entryvalue: acl_parse_permission(permissions),
} },
} }
def acl_parse_entries(acl): def acl_parse_entries(acl):