Add method to clamp a config value between minimum and maximum values.

This commit is contained in:
auouymous 2022-09-29 21:19:01 -06:00
parent 1dbc8288d1
commit 9a4d5e34cd
1 changed files with 10 additions and 0 deletions

View File

@ -430,3 +430,13 @@ class Config(object):
logger.debug("setting config.device_sync.max_filename_length=120"
" (999 is bad for NTFS and ext{2-4})")
self.device_sync.max_filename_length = 120
def clamp_range(self, name, min, max):
value = getattr(self, name)
if value < min:
setattr(self, name, min)
return True
if value > max:
setattr(self, name, max)
return True
return False