[chirp_devel] [csv] Friendlier defaults for missing cToneFreq/rToneFreq columns in csv import - Fixes #1577

Tom Hayward
Thu Apr 24 20:59:40 PDT 2014


On Thu, Apr 24, 2014 at 8:09 PM,  <chirp.cordless at xoxy.net> wrote:
> Patch attached.
> -dan

I haven't tested it yet, but I see a few issues with style.

- Don't mix tabs and spaces. We prefer spaces.

- 0 is a number. You can (and should) use True and False in Python to
represent booleans. This is a style thing, but it becomes important
when another developer does a test like "1 is True". This evaluates
False because the "is" operator is testing identity; 1 and True are
different things.

Here's a Python trick you may not be aware of:
+        _file_has_rTone = 0
+        _file_has_cTone = 0
+        for header in headers:
+    if header == "rToneFreq":
+                _file_has_rTone = 1
+    elif header == "cToneFreq":
+                _file_has_cTone = 1

Is equivalent to:
_file_has_rTone = "rToneFreq" in headers
_file_has_cTone = "cToneFreq" in headers

Short and sweet. It will iterate the list twice instead of once, but I
think that's acceptable for readability.

Tom KD7LXL



More information about the chirp_devel mailing list