[chirp_devel] [PATCH] Fix .tpe driver to work with CSV dialects update. #1097 #917
Tom Hayward
Sat Sep 14 11:20:08 PDT 2013
# HG changeset patch
# User Tom Hayward <tom at tomh.us>
# Date 1379182691 25200
# Node ID 2a2290fbc2995b53d223b2e99be124d8e68f27e0
# Parent c60b1cdee0f0549b7c1ae56507b3738778fc5b5d
Fix .tpe driver to work with CSV dialects update. #1097 #917
diff -r c60b1cdee0f0 -r 2a2290fbc299 chirp/generic_tpe.py
--- a/chirp/generic_tpe.py Mon Sep 09 14:06:23 2013 -0700
+++ b/chirp/generic_tpe.py Sat Sep 14 11:18:11 2013 -0700
@@ -16,25 +16,6 @@
import UserDict
from chirp import chirp_common, directory, generic_csv
-class TpeMap(UserDict.UserDict):
- """Pretend we're a dict"""
- def items(self):
- return [
- ("Sequence Number" , (int, "number")),
- ("Location" , (str, "comment")),
- ("Call Sign" , (str, "name")),
- ("Output Frequency", (chirp_common.parse_freq, "freq")),
- ("Input Frequency" , (str, "duplex")),
- ("CTCSS Tones" , (lambda v: "Tone"
- if float(v) in chirp_common.TONES
- else "", "tmode")),
- ("CTCSS Tones" , (lambda v: float(v)
- if float(v) in chirp_common.TONES
- else 88.5, "rtone")),
- ("CTCSS Tones" , (lambda v: float(v)
- if float(v) in chirp_common.TONES
- else 88.5, "ctone")),
- ]
@directory.register
class TpeRadio(generic_csv.CSVRadio):
@@ -43,7 +24,32 @@
MODEL = "Travel Plus"
FILE_EXTENSION = "tpe"
- ATTR_MAP = TpeMap()
+ ATTR_MAP = {
+ "Sequence Number" : (int, "number"),
+ "Location" : (str, "comment"),
+ "Call Sign" : (str, "name"),
+ "Output Frequency": (chirp_common.parse_freq, "freq"),
+ "Input Frequency" : (str, "duplex"),
+ "CTCSS Tones" : (lambda v: float(v)
+ if v and float(v) in chirp_common.TONES
+ else 88.5, "rtone"),
+ "Repeater Notes": (str, "comment"),
+ }
+
+ def _clean_tmode(self, headers, line, mem):
+ try:
+ val = generic_csv.get_datum_by_header(headers, line, "CTCSS Tones")
+ if val and float(val) in chirp_common.TONES:
+ mem.tmode = "Tone"
+ except generic_csv.OmittedHeaderError:
+ pass
+
+ return mem
+
+ def _clean_ctone(self, headers, line, mem):
+ # TPE only stores a single tone value
+ mem.ctone = mem.rtone
+ return mem
@classmethod
def match_model(cls, filedata, filename):
More information about the chirp_devel
mailing list