[chirp_devel] [PATCH 06/12] Fix style issues (2/4) (#2355)
Zach Welch
Fri Feb 27 02:24:43 PST 2015
# HG changeset patch
# User Zach Welch <zach at mandolincreekfarm.com>
# Fake Node ID 7434dd966941f72b17ceedc67717095e01756bbd
Fix style issues (2/4) (#2355)
This patch fixes the style in a handful of files and removes them
from pep8.blacklist.
diff --git a/chirp/bandplan.py b/chirp/bandplan.py
index f2b8541..97f2425 100644
--- a/chirp/bandplan.py
+++ b/chirp/bandplan.py
@@ -15,6 +15,7 @@
from chirp import chirp_common
+
class Band(object):
def __init__(self, limits, name, mode=None, step_khz=None,
input_offset=None, output_offset=None, tones=None):
@@ -79,6 +80,6 @@ class Band(object):
self.step_khz and 'step_khz: %s ' % (self.step_khz,) or '',
self.offset and 'offset: %s ' % (self.offset,) or '',
self.tones and 'tones: %s ' % (self.tones,) or '')
-
+
return "%s-%s %s %s %s" % (
self.limits[0], self.limits[1], self.name, self.duplex, desc)
diff --git a/csvdump/__init__.py b/csvdump/__init__.py
index 833c0c7..e418fca 100644
--- a/csvdump/__init__.py
+++ b/csvdump/__init__.py
@@ -14,4 +14,3 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
diff --git a/locale/check_parameters.py b/locale/check_parameters.py
index 431faec..f0f3d51 100755
--- a/locale/check_parameters.py
+++ b/locale/check_parameters.py
@@ -15,16 +15,17 @@ for name, po in pos.iteritems():
if len(entry.msgstr) > 0:
try:
ids = [field_name
- for literal_text, field_name, format_spec, conversion
- in formatter.parse(entry.msgid)]
+ for literal_text, field_name, format_spec, conversion
+ in formatter.parse(entry.msgid)]
tids = [field_name
- for literal_text, field_name, format_spec, conversion
- in formatter.parse(entry.msgstr)]
+ for literal_text, field_name, format_spec, conversion
+ in formatter.parse(entry.msgstr)]
except Exception as e:
print "Got exception!", e, "for entry", entry.msgid
else:
- if tids != None:
+ if tids is not None:
missing = [name for name in tids
- if name is not None and name not in ids]
+ if name is not None and name not in ids]
if len(missing) > 0:
- print "Missing parameters", missing, "in translation of", entry.msgid
+ print "Missing parameters", missing, \
+ "in translation of", entry.msgid
diff --git a/tests/unit/base.py b/tests/unit/base.py
index 47d16d4..ee6884c 100644
--- a/tests/unit/base.py
+++ b/tests/unit/base.py
@@ -4,6 +4,7 @@ import mox
import warnings
warnings.simplefilter('ignore', Warning)
+
class BaseTest(unittest.TestCase):
def setUp(self):
__builtins__['_'] = lambda s: s
diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py
index 611836f..aabc7b3 100644
--- a/tests/unit/test_bitwise.py
+++ b/tests/unit/test_bitwise.py
@@ -18,6 +18,7 @@ import unittest
from chirp import bitwise
from chirp import memmap
+
class BaseTest(unittest.TestCase):
def _compare_structure(self, obj, primitive):
for key, value in primitive.iteritems():
@@ -26,6 +27,7 @@ class BaseTest(unittest.TestCase):
else:
self.assertEqual(type(value)(getattr(obj, key)), value)
+
class TestBitwiseBaseIntTypes(BaseTest):
def _test_type(self, datatype, _data, value):
data = memmap.MemoryMap(_data)
@@ -78,6 +80,7 @@ class TestBitwiseBaseIntTypes(BaseTest):
obj.foo[i] = i * 2
self.assertEqual('\x00\x02\x04\x06', data.get_packed())
+
class TestBitfieldTypes(BaseTest):
def test_bitfield_u8(self):
defn = "u8 foo:4, bar:4;"
@@ -139,6 +142,7 @@ class TestBitfieldTypes(BaseTest):
def test_bitfield_ul24(self):
self._test_bitfield_24("l", "\xC2\x40\x00")
+
class TestBitType(BaseTest):
def test_bit_array(self):
defn = "bit foo[24];"
@@ -153,6 +157,7 @@ class TestBitType(BaseTest):
def test_bit_array_fail(self):
self.assertRaises(ValueError, bitwise.parse, "bit foo[23];", "000")
+
class TestBitwiseBCDTypes(BaseTest):
def _test_def(self, definition, name, _data, value):
data = memmap.MemoryMap(_data)
@@ -181,6 +186,7 @@ class TestBitwiseBCDTypes(BaseTest):
def test_lbcd_array(self):
self._test_def("lbcd foo[2];", "foo", "\x12\x34", 3412)
+
class TestBitwiseCharTypes(BaseTest):
def test_char(self):
data = memmap.MemoryMap("c")
@@ -202,7 +208,6 @@ class TestBitwiseCharTypes(BaseTest):
data = memmap.MemoryMap("\xFFoobar1")
obj = bitwise.parse("struct {char foo[7];} bar;", data)
self.assertIn('\\xffoobar1', repr(obj.bar))
-
def test_string_wrong_length(self):
data = memmap.MemoryMap("foobar")
@@ -210,6 +215,7 @@ class TestBitwiseCharTypes(BaseTest):
self.assertRaises(ValueError, setattr, obj, "foo", "bazfo")
self.assertRaises(ValueError, setattr, obj, "foo", "bazfooo")
+
class TestBitwiseStructTypes(BaseTest):
def _test_def(self, definition, data, primitive):
obj = bitwise.parse(definition, data)
@@ -218,12 +224,12 @@ class TestBitwiseStructTypes(BaseTest):
def test_struct_one_element(self):
defn = "struct { u8 bar; } foo;"
- value = {"foo" : {"bar": 128}}
+ value = {"foo": {"bar": 128}}
self._test_def(defn, "\x80", value)
def test_struct_two_elements(self):
defn = "struct { u8 bar; u16 baz; } foo;"
- value = {"foo" : {"bar": 128, "baz": 256}}
+ value = {"foo": {"bar": 128, "baz": 256}}
self._test_def(defn, "\x80\x01\x00", value)
def test_struct_writes(self):
@@ -234,6 +240,7 @@ class TestBitwiseStructTypes(BaseTest):
obj.foo.baz = 0x34
self.assertEqual(data.get_packed(), "\x12\x34")
+
class TestBitwiseSeek(BaseTest):
def test_seekto(self):
defn = "#seekto 4; char foo;"
@@ -246,10 +253,12 @@ class TestBitwiseSeek(BaseTest):
self.assertEqual(str(obj.foo), "A")
self.assertEqual(str(obj.bar), "Z")
+
class TestBitwiseErrors(BaseTest):
def test_missing_semicolon(self):
self.assertRaises(SyntaxError, bitwise.parse, "u8 foo", "")
+
class TestBitwiseComments(BaseTest):
def test_comment_inline_cppstyle(self):
obj = bitwise.parse('u8 foo; // test', '\x10')
diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py
index 1a75cbf..8393c40 100644
--- a/tests/unit/test_chirp_common.py
+++ b/tests/unit/test_chirp_common.py
@@ -2,6 +2,7 @@ from tests.unit import base
from chirp import chirp_common
from chirp import errors
+
class TestUtilityFunctions(base.BaseTest):
def test_parse_freq_whole(self):
self.assertEqual(chirp_common.parse_freq("146.520000"), 146520000)
@@ -47,6 +48,7 @@ class TestUtilityFunctions(base.BaseTest):
self.assertEqual(chirp_common.format_freq(1), "0.000001")
self.assertEqual(chirp_common.format_freq(1250000000), "1250.000000")
+
class TestSplitTone(base.BaseTest):
def _test_split_tone_decode(self, tx, rx, **vals):
mem = chirp_common.Memory()
@@ -184,6 +186,7 @@ class TestSplitTone(base.BaseTest):
(('', None, None),
('Tone', 100.0, None)))
+
class TestStepFunctions(base.BaseTest):
_625 = [145856250,
445856250,
diff --git a/tests/unit/test_mappingmodel.py b/tests/unit/test_mappingmodel.py
index 5a3c706..7ccbc86 100644
--- a/tests/unit/test_mappingmodel.py
+++ b/tests/unit/test_mappingmodel.py
@@ -17,6 +17,7 @@ from tests.unit import base
from chirp import chirp_common
from chirp import icf
+
class TestBaseMapping(base.BaseTest):
CLS = chirp_common.MemoryMapping
@@ -37,9 +38,11 @@ class TestBaseMapping(base.BaseTest):
self.assertEqual(mapping1, mapping2)
self.assertNotEqual(mapping1, mapping3)
+
class TestBaseBank(TestBaseMapping):
CLS = chirp_common.Bank
+
class _TestBaseClass(base.BaseTest):
ARGS = tuple()
@@ -51,6 +54,7 @@ class _TestBaseClass(base.BaseTest):
self.assertRaises(NotImplementedError,
getattr(self.model, method), *args)
+
class TestBaseMappingModel(_TestBaseClass):
CLS = chirp_common.MappingModel
ARGS = tuple([None, 'Foo'])
@@ -69,6 +73,7 @@ class TestBaseMappingModel(_TestBaseClass):
def test_get_name(self):
self.assertEqual(self.model.get_name(), 'Foo')
+
class TestBaseBankModel(TestBaseMappingModel):
ARGS = tuple([None])
CLS = chirp_common.BankModel
@@ -76,6 +81,7 @@ class TestBaseBankModel(TestBaseMappingModel):
def test_get_name(self):
self.assertEqual(self.model.get_name(), 'Banks')
+
class TestBaseMappingModelIndexInterface(_TestBaseClass):
CLS = chirp_common.MappingModelIndexInterface
@@ -88,12 +94,14 @@ class TestBaseMappingModelIndexInterface(_TestBaseClass):
for method, args in methods:
self._test_base(method, *args)
+
class TestIcomBanks(TestBaseMapping):
def test_icom_bank(self):
bank = icf.IcomBank(None, 1, 'Foo')
# IcomBank has an index attribute used by IcomBankModel
self.assertTrue(hasattr(bank, 'index'))
+
class TestIcomBankModel(base.BaseTest):
CLS = icf.IcomBankModel
@@ -209,6 +217,7 @@ class TestIcomBankModel(base.BaseTest):
self.assertEqual(self._model.get_memory_mappings(mem1)[0], banks[2])
self.assertEqual(self._model.get_memory_mappings(mem2), [])
+
class TestIcomIndexedBankModel(TestIcomBankModel):
CLS = icf.IcomIndexedBankModel
diff --git a/tests/unit/test_platform.py b/tests/unit/test_platform.py
index c69c743..2148499 100644
--- a/tests/unit/test_platform.py
+++ b/tests/unit/test_platform.py
@@ -20,6 +20,7 @@ import os
from tests.unit import base
from chirp import platform
+
class Win32PlatformTest(base.BaseTest):
def _test_init(self):
self.mox.StubOutWithMock(platform, 'comports')
diff --git a/tests/unit/test_shiftdialog.py b/tests/unit/test_shiftdialog.py
index 83a0370..46f83ce 100644
--- a/tests/unit/test_shiftdialog.py
+++ b/tests/unit/test_shiftdialog.py
@@ -6,6 +6,7 @@ from chirpui import shiftdialog
from chirp import chirp_common
from chirp import errors
+
class FakeRadio(object):
def __init__(self, *memories):
self._mems = {}
@@ -44,6 +45,7 @@ class FakeRadioThread(object):
def unlock(self):
pass
+
class ShiftDialogTest(base.BaseTest):
def _test_hole(self, fn, starting, arg, expected):
radio = FakeRadio(*tuple(starting))
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist
index 1aad90b..5e8f29b 100644
--- a/tools/cpep8.blacklist
+++ b/tools/cpep8.blacklist
@@ -5,7 +5,6 @@
./chirp/alinco.py
./chirp/anytone.py
./chirp/ap510.py
-./chirp/bandplan.py
./chirp/bandplan_au.py
./chirp/bandplan_iaru_r1.py
./chirp/bandplan_iaru_r2.py
@@ -114,22 +113,14 @@
./chirpui/reporting.py
./chirpui/settingsedit.py
./chirpui/shiftdialog.py
-./csvdump/__init__.py
./csvdump/csvapp.py
./csvdump/csvdump.py
-./locale/check_parameters.py
./rpttool
./setup.py
./share/make_supported.py
./tests/run_tests
-./tests/unit/base.py
-./tests/unit/test_bitwise.py
-./tests/unit/test_chirp_common.py
./tests/unit/test_import_logic.py
-./tests/unit/test_mappingmodel.py
./tests/unit/test_memedit_edits.py
-./tests/unit/test_platform.py
./tests/unit/test_settings.py
-./tests/unit/test_shiftdialog.py
./tools/bitdiff.py
./tools/img2thd72.py
More information about the chirp_devel
mailing list