Skip to content

Commit

Permalink
Merge pull request selfcustody#447 from tadeubas/simplified_translations
Browse files Browse the repository at this point in the history
Removing pl-PL translation until we have a maintainer
  • Loading branch information
odudex authored Aug 27, 2024
2 parents 04e7cca + ea6cf56 commit 1b03495
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 590 deletions.
295 changes: 0 additions & 295 deletions i18n/translations/pl-PL.json

This file was deleted.

22 changes: 22 additions & 0 deletions src/krux/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ def __init__(self, attr, default_value, categories):
super().__init__(attr, default_value)
self.categories = categories

def __get__(self, obj, objtype=None):
if obj is None:
return self

stored_val = store.get(obj.namespace, self.attr, self.default_value)
if stored_val not in self.categories:
return self.default_value
return stored_val


class NumberSetting(Setting):
"""Setting that can be a number within a defined range"""
Expand All @@ -104,6 +113,19 @@ def __init__(self, numtype, attr, default_value, value_range):
self.numtype = numtype
self.value_range = value_range

def __get__(self, obj, objtype=None):
if obj is None:
return self

stored_val = store.get(obj.namespace, self.attr, self.default_value)
if (
(self.numtype is int and isinstance(stored_val, self.numtype))
or (self.numtype is float and isinstance(stored_val, (self.numtype, int)))
) and self.value_range[0] <= stored_val <= self.value_range[1]:
return stored_val

return self.default_value


class Store:
"""Acts as a simple JSON file store for settings, falling back to an in-memory dict if no SD"""
Expand Down
Loading

0 comments on commit 1b03495

Please sign in to comment.