[chirp_devel] [PATCH 19/35] Fix style issues in tmv71*.py (#2355)

Zachary T Welch
Tue Mar 3 17:48:31 PST 2015


# HG changeset patch
# User Zachary T Welch <zach at mandolincreekfarm.com>
# Fake Node ID 4c2c12250b64b3ddab5a98dd6729e3089b5694f2

Fix style issues in tmv71*.py (#2355)


diff --git a/chirp/drivers/tmv71.py b/chirp/drivers/tmv71.py
index cca737a..94c97a9 100644
--- a/chirp/drivers/tmv71.py
+++ b/chirp/drivers/tmv71.py
@@ -16,6 +16,7 @@
 from chirp import chirp_common, errors, util
 from chirp.drivers import tmv71_ll
 
+
 class TMV71ARadio(chirp_common.CloneModeRadio):
     BAUD_RATE = 9600
     VENDOR = "Kenwood"
@@ -23,7 +24,7 @@ class TMV71ARadio(chirp_common.CloneModeRadio):
 
     mem_upper_limit = 1022
     _memsize = 32512
-    _model = "" # FIXME: REMOVE
+    _model = ""  # FIXME: REMOVE
 
     def get_features(self):
         rf = chirp_common.RadioFeatures()
@@ -55,8 +56,8 @@ class TMV71ARadio(chirp_common.CloneModeRadio):
             try:
                 number = tmv71_ll.V71_SPECIAL[number]
             except KeyError:
-                raise errors.InvalidMemoryLocation("Unknown channel %s" % \
-                                                       number)
+                raise errors.InvalidMemoryLocation("Unknown channel %s" %
+                                                   number)
 
         return tmv71_ll.get_memory(self._mmap, number)
 
diff --git a/chirp/drivers/tmv71_ll.py b/chirp/drivers/tmv71_ll.py
index 201412e..2fd4d86 100644
--- a/chirp/drivers/tmv71_ll.py
+++ b/chirp/drivers/tmv71_ll.py
@@ -13,18 +13,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import struct, time, logging
+import struct
+import time
+import logging
 
 from chirp import memmap, chirp_common, errors
 
 LOG = logging.getLogger(__name__)
 
-POS_MODE   = 5
-POS_DUP    = 6
-POS_TMODE  = 6
-POS_RTONE  = 7
-POS_CTONE  = 8
-POS_DTCS   = 9
+POS_MODE = 5
+POS_DUP = 6
+POS_TMODE = 6
+POS_RTONE = 7
+POS_CTONE = 8
+POS_DTCS = 9
 POS_OFFSET = 10
 
 MEM_LOC_BASE = 0x1700
@@ -43,9 +45,10 @@ V71_SPECIAL["C VHF"] = 1030
 V71_SPECIAL["C UHF"] = 1031
 
 V71_SPECIAL_REV = {}
-for k,v in V71_SPECIAL.items():
+for k, v in V71_SPECIAL.items():
     V71_SPECIAL_REV[v] = k
 
+
 def command(s, cmd, timeout=0.5):
     start = time.time()
 
@@ -57,6 +60,7 @@ def command(s, cmd, timeout=0.5):
     LOG.debug("V71->PC: %s" % data.strip())
     return data.strip()
 
+
 def get_id(s):
     r = command(s, "ID")
     if r.startswith("ID "):
@@ -67,6 +71,7 @@ def get_id(s):
 EXCH_R = "R\x00\x00\x00"
 EXCH_W = "W\x00\x00\x00"
 
+
 def read_block(s, block, count=256):
     s.write(struct.pack("<cHB", "R", block, 0))
     r = s.read(4)
@@ -87,6 +92,7 @@ def read_block(s, block, count=256):
 
     return data
 
+
 def write_block(s, block, map):
     s.write(struct.pack("<cHB", "W", block, 0))
     base = block * 256
@@ -96,6 +102,7 @@ def write_block(s, block, map):
 
     return ack == chr(0x06)
 
+
 def download(radio):
     if command(radio.pipe, "0M PROGRAM") != "0M":
         raise errors.RadioError("No response from radio")
@@ -114,6 +121,7 @@ def download(radio):
 
     return memmap.MemoryMap(data)
 
+
 def upload(radio):
     if command(radio.pipe, "0M PROGRAM") != "0M":
         raise errors.RadioError("No response from radio")
@@ -131,20 +139,24 @@ def upload(radio):
 
     radio.pipe.write("E")
 
+
 def get_mem_offset(number):
     return MEM_LOC_BASE + (MEM_LOC_SIZE * number)
 
+
 def get_raw_mem(map, number):
     base = get_mem_offset(number)
-    #print "Offset for %i is %04x" % (number, base)
+    # print "Offset for %i is %04x" % (number, base)
     return map[base:base+MEM_LOC_SIZE]
 
+
 def get_used(map, number):
     pos = MEM_FLG_BASE + (number * 2)
     flag = ord(map[pos])
     print "Flag byte is %02x" % flag
     return not (flag & 0x80)
 
+
 def set_used(map, number, freq):
     pos = MEM_FLG_BASE + (number * 2)
     if freq == 0:
@@ -155,6 +167,7 @@ def set_used(map, number, freq):
     elif int(freq / 100) == 4:
         map[pos] = "\x08\x00"
 
+
 def get_skip(map, number):
     pos = MEM_FLG_BASE + (number * 2)
     flag = ord(map[pos+1])
@@ -163,6 +176,7 @@ def get_skip(map, number):
     else:
         return ""
 
+
 def set_skip(map, number, skip):
     pos = MEM_FLG_BASE + (number * 2)
     flag = ord(map[pos+1])
@@ -172,111 +186,128 @@ def set_skip(map, number, skip):
         flag &= ~0x01
     map[pos+1] = flag
 
+
 def get_freq(mmap):
     freq, = struct.unpack("<I", mmap[0:4])
     return freq / 1000000.0
 
+
 def set_freq(mmap, freq):
     mmap[0] = struct.pack("<I", int(freq * 1000000))
 
+
 def get_name(map, number):
     base = MEM_TAG_BASE + (8 * number)
     return map[base:base+6].replace("\xff", "")
 
+
 def set_name(mmap, number, name):
     base = MEM_TAG_BASE + (8 * number)
     mmap[base] = name.ljust(6)[:6].upper()
 
+
 def get_tmode(mmap):
     val = ord(mmap[POS_TMODE]) & 0x70
 
     tmodemap = {
-        0x00 : "",
-        0x40 : "Tone",
-        0x20 : "TSQL",
-        0x10 : "DTCS",
+        0x00: "",
+        0x40: "Tone",
+        0x20: "TSQL",
+        0x10: "DTCS",
         }
 
     return tmodemap[val]
 
+
 def set_tmode(mmap, tmode):
     val = ord(mmap[POS_TMODE]) & 0x8F
 
     tmodemap = {
-        ""     : 0x00,
-        "Tone" : 0x40,
-        "TSQL" : 0x20,
-        "DTCS" : 0x10,
+        "":     0x00,
+        "Tone": 0x40,
+        "TSQL": 0x20,
+        "DTCS": 0x10,
         }
 
     mmap[POS_TMODE] = val | tmodemap[tmode]
 
+
 def get_tone(mmap, offset):
     val = ord(mmap[offset])
 
     return chirp_common.TONES[val]
 
+
 def set_tone(mmap, tone, offset):
     print tone
     mmap[offset] = chirp_common.TONES.index(tone)
 
+
 def get_dtcs(mmap):
     val = ord(mmap[POS_DTCS])
 
     return chirp_common.DTCS_CODES[val]
 
+
 def set_dtcs(mmap, dtcs):
     mmap[POS_DTCS] = chirp_common.DTCS_CODES.index(dtcs)
 
+
 def get_duplex(mmap):
     val = ord(mmap[POS_DUP]) & 0x03
 
     dupmap = {
-        0x00 : "",
-        0x01 : "+",
-        0x02 : "-",
+        0x00: "",
+        0x01: "+",
+        0x02: "-",
         }
 
     return dupmap[val]
 
+
 def set_duplex(mmap, duplex):
     val = ord(mmap[POS_DUP]) & 0xFC
 
     dupmap = {
-        ""  : 0x00,
-        "+" : 0x01,
-        "-" : 0x02,
+        "":  0x00,
+        "+": 0x01,
+        "-": 0x02,
         }
 
     mmap[POS_DUP] = val | dupmap[duplex]
 
+
 def get_offset(mmap):
     val, = struct.unpack("<I", mmap[POS_OFFSET:POS_OFFSET+4])
     return val / 1000000.0
 
+
 def set_offset(mmap, offset):
     mmap[POS_OFFSET] = struct.pack("<I", int(offset * 1000000))
 
+
 def get_mode(mmap):
     val = ord(mmap[POS_MODE]) & 0x03
     modemap = {
-        0x00 : "FM",
-        0x01 : "NFM",
-        0x02 : "AM",
+        0x00: "FM",
+        0x01: "NFM",
+        0x02: "AM",
         }
 
     return modemap[val]
 
+
 def set_mode(mmap, mode):
     val = ord(mmap[POS_MODE]) & 0xFC
     modemap = {
-        "FM" : 0x00,
+        "FM":  0x00,
         "NFM": 0x01,
-        "AM" : 0x02,
+        "AM":  0x02,
         }
 
     mmap[POS_MODE] = val | modemap[mode]
 
+
 def get_memory(map, number):
     if number < 0 or number > (max(V71_SPECIAL.values()) + 1):
         raise errors.InvalidMemoryLocation("Number must be between 0 and 999")
@@ -308,15 +339,17 @@ def get_memory(map, number):
     if number > 999:
         mem.immutable = ["number", "bank", "extd_number", "name"]
     if number > 1020 and number < 1030:
-        mem.immutable += ["freq"] # FIXME: ALL
+        mem.immutable += ["freq"]  # FIXME: ALL
 
     return mem
 
+
 def initialize(mmap):
     mmap[0] = \
         "\x80\xc8\xb3\x08\x00\x01\x00\x08" + \
         "\x08\x00\xc0\x27\x09\x00\x00\xff"
 
+
 def set_memory(map, mem):
     if mem.number < 0 or mem.number > (max(V71_SPECIAL.values()) + 1):
         raise errors.InvalidMemoryLocation("Number must be between 0 and 999")
@@ -346,13 +379,13 @@ def set_memory(map, mem):
 
     return map
 
+
 if __name__ == "__main__":
     import sys
     import serial
     s = serial.Serial(port=sys.argv[1], baudrate=9600, dsrdtr=True,
                       timeout=0.25)
-    #s.write("\r\r")
-    #print get_id(s)
+    # s.write("\r\r")
+    # print get_id(s)
     data = download(s)
     file(sys.argv[2], "wb").write(data)
-
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist
index 765b7a8..9181e9c 100644
--- a/tools/cpep8.blacklist
+++ b/tools/cpep8.blacklist
@@ -17,5 +17,3 @@
 ./chirp/drivers/icw32.py
 ./chirp/drivers/icx8x.py
 ./chirp/drivers/icx8x_ll.py
-./chirp/drivers/tmv71.py
-./chirp/drivers/tmv71_ll.py




More information about the chirp_devel mailing list