Improved lock-setting logic to handle empty locks, and allow customizing locks via .create()'s new generate_default_locks

This commit is contained in:
Andrew Bastien 2023-11-25 18:09:30 -05:00
parent e2a7c54e24
commit a0907ec94d
3 changed files with 118 additions and 30 deletions

View file

@ -338,9 +338,16 @@ class LockHandler:
"""
if isinstance(lockstring, str):
lockdefs = lockstring.split(";")
lockdefs = [
stripped for lockdef in lockstring.split(";") if (stripped := lockdef.strip())
]
else:
lockdefs = [lockdef for locks in lockstring for lockdef in locks.split(";")]
lockdefs = [
stripped
for locks in lockstring
for lockdef in locks.split(";")
if (stripped := lockdef.strip())
]
lockstring = ";".join(lockdefs)
err = ""