# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 6abe32d19ca3ba161e896624f4a1ec6b0479d1c7
Fix style issues in csvdump scripts (#2355)
diff --git a/csvdump/csvapp.py b/csvdump/csvapp.py index 2d675cc..aaae614 100644 --- a/csvdump/csvapp.py +++ b/csvdump/csvapp.py @@ -24,19 +24,19 @@ import os import csvdump from chirpui import inputdialog, cloneprog
-gobject.threads_init() - import chirp from chirp import ic9x, id800, ic2820, ic2200, errors - from chirp import platform
-RADIOS = { "ic9x:A": ic9x.IC9xRadioA, - "ic9x:B": ic9x.IC9xRadioB, - "id800" : id800.ID800v2Radio, - "ic2820": ic2820.IC2820Radio, - "ic2200": ic2200.IC2200Radio, -} +gobject.threads_init() + +RADIOS = {"ic9x:A": ic9x.IC9xRadioA, + "ic9x:B": ic9x.IC9xRadioB, + "id800": id800.ID800v2Radio, + "ic2820": ic2820.IC2820Radio, + "ic2200": ic2200.IC2200Radio, + } +
class CsvDumpApp: def update_status(self, s): @@ -57,7 +57,7 @@ class CsvDumpApp:
print "Sync done, saving to: %s" % fn radio.save_mmap(fn) - + self.refresh_radio() except serial.SerialException, e: gobject.idle_add(self.mainwin.set_status, @@ -107,7 +107,7 @@ class CsvDumpApp: def upload_img(self): t = threading.Thread(target=self._upload_img) t.start() - + def _export_file_mmap(self, fname): count = 0
@@ -173,7 +173,6 @@ class CsvDumpApp: return low, high else: return None, None -
def export_file(self, fname): if not fname.lower().endswith(".csv"): @@ -185,7 +184,7 @@ class CsvDumpApp: return
t = threading.Thread(target=self._export_file_live, - args=(fname,l,h)) + args=(fname, l, h)) t.start() else: self._export_file_mmap(fname) @@ -200,7 +199,7 @@ class CsvDumpApp: except Exception, e: print "Failed to parse `%s': %s" % (line, e) return None - + return m
def _import_file_live(self, fname): @@ -226,7 +225,7 @@ class CsvDumpApp: continue except Exception, e: print "Parse error on line %i: %s" % (lineno, e) - break # FIXME: Report error here + break # FIXME: Report error here
lineno += 1 memories.append(m) @@ -242,7 +241,7 @@ class CsvDumpApp: # try: # self.radio.get_memory(m.number, 2) # except errors.InvalidMemoryLocation: -# m +# m
try: self.radio.set_memory(m) @@ -333,7 +332,7 @@ class CsvDumpApp: self.rtype = radio self.rport = port self.refresh_radio() - + def __init__(self): self.mainwin = csvdump.CsvDumpWindow(self.select_radio, self.download_img, @@ -344,7 +343,7 @@ class CsvDumpApp: self.progwin = cloneprog.CloneProg() self.progwin.set_transient_for(self.mainwin) self.progwin.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) - + self.radio = None
def run(self): @@ -353,6 +352,7 @@ class CsvDumpApp:
gtk.main()
+ if __name__ == "__main__": a = CsvDumpApp() a.run() diff --git a/csvdump/csvdump.py b/csvdump/csvdump.py index 3b1f550..048cac9 100644 --- a/csvdump/csvdump.py +++ b/csvdump/csvdump.py @@ -19,7 +19,8 @@ import gtk
from chirp import platform
-RADIOS = [ "ic2820", "id800", "ic9x:A", "ic9x:B", "ic2200" ] +RADIOS = ["ic2820", "id800", "ic9x:A", "ic9x:B", "ic2200"] +
def make_choice(options, editable=True, default=None): if editable: @@ -39,12 +40,14 @@ def make_choice(options, editable=True, default=None):
return sel
+ class StdButton(gtk.Button): def __init__(self, *args): gtk.Button.__init__(self, *args)
self.set_size_request(75, 25)
+ class CsvDumpWindow(gtk.Window): def set_image_info(self, canUpload, canCsv, info): self.w_imginfo.set_text(info) @@ -66,16 +69,16 @@ class CsvDumpWindow(gtk.Window):
hbox = gtk.HBox(False, 2) hbox.set_border_width(2) - + self.w_radio = make_choice(RADIOS, False, RADIOS[0]) self.w_radio.connect("changed", self.select_radio) self.tips.set_tip(self.w_radio, "Select radio model") self.w_radio.show() - hbox.pack_start(self.w_radio, 1,1,1) + hbox.pack_start(self.w_radio, 1, , )
l = gtk.Label(" on port ") l.show() - hbox.pack_start(l, 0,0,0) + hbox.pack_start(l, 0, , )
ports = platform.get_platform().list_serial_ports() if len(ports) > 0: @@ -86,7 +89,7 @@ class CsvDumpWindow(gtk.Window): self.w_port.connect("changed", self.select_radio) self.tips.set_tip(self.w_port, "Select serial port") self.w_port.show() - hbox.pack_start(self.w_port, 1,1,1) + hbox.pack_start(self.w_port, 1, , )
f.add(hbox) hbox.show() @@ -102,7 +105,7 @@ class CsvDumpWindow(gtk.Window):
self.w_imginfo = gtk.Label("No image") self.w_imginfo.show() - vbox.pack_start(self.w_imginfo, 0,0,0) + vbox.pack_start(self.w_imginfo, 0, , )
hbox = gtk.HBox(True, 2) hbox.set_border_width(2) @@ -111,17 +114,17 @@ class CsvDumpWindow(gtk.Window): self.w_dli.connect("clicked", lambda x: self.fn_download()) self.tips.set_tip(self.w_dli, "Download image from radio") self.w_dli.show() - hbox.pack_start(self.w_dli, 0,0,0) + hbox.pack_start(self.w_dli, 0, , )
self.w_uli = StdButton("Upload") self.w_uli.set_sensitive(False) self.w_uli.connect("clicked", lambda x: self.fn_upload()) self.tips.set_tip(self.w_uli, "Upload image to radio") self.w_uli.show() - hbox.pack_start(self.w_uli, 0,0,0) + hbox.pack_start(self.w_uli, 0, , )
hbox.show() - vbox.pack_start(hbox, 0,0,0) + vbox.pack_start(hbox, 0, , )
vbox.show() self.w_imgframe.add(vbox) @@ -151,45 +154,47 @@ class CsvDumpWindow(gtk.Window):
l = gtk.Label("File") l.show() - hbox.pack_start(l, 0,0,0) + hbox.pack_start(l, 0, , )
self.w_filename = gtk.Entry() self.w_filename.connect("changed", self.file_changed) self.tips.set_tip(self.w_filename, "Path to CSV file") self.w_filename.show() - hbox.pack_start(self.w_filename, 1,1,1) - + hbox.pack_start(self.w_filename, 1, , ) + bb = StdButton("Browse") bb.connect("clicked", self.pick_file) bb.show() - hbox.pack_start(bb, 0,0,0) + hbox.pack_start(bb, 0, , )
hbox.show() - vbox.pack_start(hbox, 0,0,0) + vbox.pack_start(hbox, 0, , )
hbox = gtk.HBox(True, 2) hbox.set_border_width(2)
+ def export_handler(x): + return self.fn_eport(self.w_filename.get_text()) self.w_export = StdButton("Export") self.w_export.set_sensitive(False) - self.w_export.connect("clicked", - lambda x: self.fn_eport(self.w_filename.get_text())) + self.w_export.connect("clicked", export_handler) self.tips.set_tip(self.w_export, "Export radio memories to CSV file") self.w_export.show() - hbox.pack_start(self.w_export, 0,0,0) + hbox.pack_start(self.w_export, 0, , )
+ def import_handler(x): + return self.fn_iport(self.w_filename.get_text()) self.w_import = StdButton("Import") self.w_import.set_sensitive(False) - self.w_import.connect("clicked", - lambda x: self.fn_iport(self.w_filename.get_text())) + self.w_import.connect("clicked", import_handler) self.tips.set_tip(self.w_import, "Import radio memories from CSV file") self.w_import.show() - hbox.pack_start(self.w_import, 0,0,0) + hbox.pack_start(self.w_import, 0, , )
hbox.show() - vbox.pack_start(hbox, 0,0,0) + vbox.pack_start(hbox, 0, , )
vbox.show() self.w_fileframe.add(vbox) @@ -220,10 +225,10 @@ class CsvDumpWindow(gtk.Window):
vbox = gtk.VBox(False, 2)
- vbox.pack_start(self.make_radio_sel(), 0,0,0) - vbox.pack_start(self.make_image_ctl(), 0,0,0) - vbox.pack_start(self.make_file_ctl(), 0,0,0) - vbox.pack_start(self.make_status_bar(), 0,0,0) + vbox.pack_start(self.make_radio_sel(), 0, , ) + vbox.pack_start(self.make_image_ctl(), 0, , ) + vbox.pack_start(self.make_file_ctl(), 0, , ) + vbox.pack_start(self.make_status_bar(), 0, , )
vbox.show() self.add(vbox) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 5cf2b23..3d7e95c 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -90,8 +90,6 @@ ./chirpui/memedit.py ./chirpui/miscwidgets.py ./chirpui/reporting.py -./csvdump/csvapp.py -./csvdump/csvdump.py ./share/make_supported.py ./tools/bitdiff.py ./tools/img2thd72.py