[chirp_devel] [PATCH 07/11] Fix pylint issues in settings.py (#159)
Zachary T Welch
Sun Mar 8 16:54:21 PDT 2015
# HG changeset patch
# User Zachary T Welch <zach at mandolincreekfarm.com>
# Fake Node ID 31b2a1456e93f038e88cade466acf0a970b79121
Fix pylint issues in settings.py (#159)
diff --git a/chirp/settings.py b/chirp/settings.py
index 55571a3..50685c7 100644
--- a/chirp/settings.py
+++ b/chirp/settings.py
@@ -13,6 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Provides a heiarchical means of representing device settings.
+"""
+
from chirp import chirp_common
@@ -26,7 +30,7 @@ class InternalError(Exception):
pass
-class RadioSettingValue:
+class RadioSettingValue(object):
"""Base class for a single radio setting"""
def __init__(self):
self._current = None
@@ -35,20 +39,23 @@ class RadioSettingValue:
self._mutable = True
def set_mutable(self, mutable):
+ """Set whether this value can be changed."""
self._mutable = mutable
def get_mutable(self):
+ """Return whether this value can be changed."""
return self._mutable
def changed(self):
- """Returns True if the setting has been changed since init"""
+ """Returns True if the setting has been changed since init."""
return self._has_changed
def set_validate_callback(self, callback):
+ """Set the callback used to validate the value."""
self._validate_callback = callback
def set_value(self, value):
- """Sets the current value, triggers changed"""
+ """Sets the current value, marks it changed, and validates."""
if not self.get_mutable():
raise InvalidValueError("This value is not mutable")
@@ -57,13 +64,15 @@ class RadioSettingValue:
self._current = self._validate_callback(value)
def get_value(self):
- """Gets the current value"""
+ """Gets the current value."""
return self._current
def __trunc__(self):
+ """Return the integer portion of the value."""
return int(self.get_value())
def __str__(self):
+ """Return the string representation of the value."""
return str(self.get_value())
@@ -207,6 +216,7 @@ class RadioSettingValueString(RadioSettingValue):
class RadioSettings(list):
+ """Represents the top-level list of settings."""
def __init__(self, *groups):
list.__init__(self, groups)
@@ -216,7 +226,7 @@ class RadioSettings(list):
class RadioSettingGroup(object):
- """A group of settings"""
+ """Represents a group of settings."""
def _validate(self, element):
# RadioSettingGroup can only contain RadioSettingGroup objects
if not isinstance(element, RadioSettingGroup):
@@ -259,7 +269,7 @@ class RadioSettingGroup(object):
self[element.get_name()] = element
def __iter__(self):
- class RSGIterator:
+ class RSGIterator(object):
"""Iterator for a RadioSettingGroup"""
def __init__(self, rsg):
@@ -312,12 +322,16 @@ class RadioSetting(RadioSettingGroup):
self._apply_callback = None
def set_apply_callback(self, callback, *args):
+ """Set the apply callback to call the given function with the
+ provided arguments."""
self._apply_callback = lambda: callback(self, *args)
def has_apply_callback(self):
+ """Returns True if the apply callback has been set."""
return self._apply_callback is not None
def run_apply_callback(self):
+ """Invokes the apply callback."""
return self._apply_callback()
def _validate(self, value):
diff --git a/tools/cpep8.lintful b/tools/cpep8.lintful
index 00c7919..49f08b2 100644
--- a/tools/cpep8.lintful
+++ b/tools/cpep8.lintful
@@ -95,7 +95,6 @@
./chirp/platform.py
./chirp/pyPEG.py
./chirp/radioreference.py
-./chirp/settings.py
./chirp/ui/bandplans.py
./chirp/ui/bankedit.py
./chirp/ui/clone.py
More information about the chirp_devel
mailing list