Skip to content

Commit

Permalink
small methods reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
linkfrg committed Jan 6, 2025
1 parent a656514 commit 3d823d0
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions ignis/options_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ def subgroup_changed(self, *args):
option_name: The name of the option.
"""

def __setattr__(self, name: str, value: Any, emit: bool = True) -> None:
if not name.startswith("_"):
self._modified_options[name] = value
if emit:
self.emit("changed", name)
return super().__setattr__(name, value)

def __getattribute__(self, name: str) -> Any:
if name.startswith("set_"):
property_name = name.replace("set_", "")
if hasattr(self, property_name):
return lambda value: setattr(self, property_name, value)
elif name.startswith("get_"):
property_name = name.replace("get_", "")
if hasattr(self, property_name):
return lambda: getattr(self, property_name)

return super().__getattribute__(name)

def bind(self, property_name: str, transform: Callable | None = None) -> Binding:
"""
:meta private:
Expand Down Expand Up @@ -150,6 +131,25 @@ def __yield_subgroups(
if isinstance(value, OptionsGroup):
yield key, value

def __setattr__(self, name: str, value: Any, emit: bool = True) -> None:
if not name.startswith("_"):
self._modified_options[name] = value
if emit:
self.emit("changed", name)
return super().__setattr__(name, value)

def __getattribute__(self, name: str) -> Any:
if name.startswith("set_"):
property_name = name.replace("set_", "")
if hasattr(self, property_name):
return lambda value: setattr(self, property_name, value)
elif name.startswith("get_"):
property_name = name.replace("get_", "")
if hasattr(self, property_name):
return lambda: getattr(self, property_name)

return super().__getattribute__(name)


class OptionsManager(OptionsGroup):
"""
Expand Down

0 comments on commit 3d823d0

Please sign in to comment.