[chirp_devel] [PATCH] [csv] Optimize generic csv files load times. Fixes #8991
Kosta Arvanitis
Mon May 24 20:52:47 PDT 2021
Resending patch for consideration.
On Sat, Apr 17, 2021 at 12:11 AM Kosta A. <ve7kcy at gmail.com> wrote:
> # HG changeset patch
> # User Kosta A. <ve7kcy at gmail.com>
> # Date 1618643404 25200
> # Sat Apr 17 00:10:04 2021 -0700
> # Node ID cd3e2444040876b4a19b41c6cfecedb79ff4a8fe
> # Parent 42c5ae551170c33b04f997e3a07a9e1857bdb504
> [csv] Optimize generic csv files load times. Fixes #8991
>
> diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
> --- a/chirp/chirp_common.py
> +++ b/chirp/chirp_common.py
> @@ -268,11 +268,11 @@
> # or an empty list if none
> extra = []
>
> - def __init__(self):
> + def __init__(self, number=0, empty=False, name=""):
> self.freq = 0
> - self.number = 0
> + self.number = number
> self.extd_number = ""
> - self.name = ""
> + self.name = name
> self.vfo = 0
> self.rtone = 88.5
> self.ctone = 88.5
> @@ -290,7 +290,7 @@
>
> self.comment = ""
>
> - self.empty = False
> + self.empty = empty
>
> self.immutable = []
>
> diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py
> --- a/chirp/drivers/generic_csv.py
> +++ b/chirp/drivers/generic_csv.py
> @@ -47,7 +47,7 @@
>
>
> @directory.register
> -class CSVRadio(chirp_common.FileBackedRadio,
> chirp_common.IcomDstarSupport):
> +class CSVRadio(chirp_common.FileBackedRadio):
> """A driver for Generic CSV files"""
> VENDOR = "Generic"
> MODEL = "CSV"
> @@ -67,20 +67,15 @@
> "Mode": (str, "mode"),
> "TStep": (float, "tuning_step"),
> "Skip": (str, "skip"),
> - "URCALL": (str, "dv_urcall"),
> - "RPT1CALL": (str, "dv_rpt1call"),
> - "RPT2CALL": (str, "dv_rpt2call"),
> "Comment": (str, "comment"),
> }
>
> - def _blank(self):
> + def _blank(self, defaults=False):
> self.errors = []
> - self.memories = []
> - for i in range(0, 1000):
> - mem = chirp_common.Memory()
> - mem.number = i
> - mem.empty = True
> - self.memories.append(mem)
> + self.memories = [chirp_common.Memory(i, True) for i in range(0,
> 1000)]
> + if (defaults):
> + self.memories[0].empty = False
> + self.memories[0].freq = 146010000
>
> def __init__(self, pipe):
> chirp_common.FileBackedRadio.__init__(self, None)
> @@ -92,14 +87,14 @@
> if self._filename and os.path.exists(self._filename):
> self.load()
> else:
> - self._blank()
> + self._blank(True)
>
> def get_features(self):
> rf = chirp_common.RadioFeatures()
> rf.has_bank = False
> rf.requires_call_lists = False
> rf.has_implicit_calls = False
> - rf.memory_bounds = (0, len(self.memories))
> + rf.memory_bounds = (0, len(self.memories)-1)
> rf.has_infinite_number = True
> rf.has_nostep_tuning = True
> rf.has_comment = True
> diff --git a/chirp/drivers/ic2200.py b/chirp/drivers/ic2200.py
> --- a/chirp/drivers/ic2200.py
> +++ b/chirp/drivers/ic2200.py
> @@ -217,7 +217,6 @@
> return mem
>
> def get_memories(self, lo=0, hi=199):
> -
> return [m for m in self._memories if m.number >= lo and m.number
> <= hi]
>
> def set_memory(self, mem):
> diff --git a/chirp/ui/bandplans.py b/chirp/ui/bandplans.py
> --- a/chirp/ui/bandplans.py
> +++ b/chirp/ui/bandplans.py
> @@ -47,7 +47,7 @@
> # Check for duplicates.
> duplicates = [x for x in plan.BANDS if x == band]
> if len(duplicates) > 1:
> - LOG.warn("Bandplan %s has duplicates %s" %
> + LOG.info("Bandplan %s has duplicates %s" %
> (name, duplicates))
> # Add repeater inputs.
> rpt_input = band.inverse()
> diff --git a/chirp/ui/editorset.py b/chirp/ui/editorset.py
> --- a/chirp/ui/editorset.py
> +++ b/chirp/ui/editorset.py
> @@ -386,19 +386,6 @@
> "export: {error}").format(error=e),
> self)
>
> - def prime(self):
> - # NOTE: this is only called to prime new CSV files, so assume
> - # only one memory editor for now
> - mem = chirp_common.Memory()
> - mem.freq = 146010000
> -
> - def cb(*args):
> - gobject.idle_add(self.editors["memedit0"].prefill)
> -
> - job = common.RadioJob(cb, "set_memory", mem)
> - job.set_desc(_("Priming memory"))
> - self.rthread.submit(job)
> -
> def tab_selected(self, notebook, foo, pagenum):
> widget = notebook.get_nth_page(pagenum)
> for k, v in self.editors.items():
> diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py
> --- a/chirp/ui/mainapp.py
> +++ b/chirp/ui/mainapp.py
> @@ -271,7 +271,6 @@
> def do_new(self):
> eset = editorset.EditorSet(_("Untitled") + ".csv", self)
> self._connect_editorset(eset)
> - eset.prime()
> eset.show()
>
> tab = self.tabs.append_page(eset, eset.get_tab_label())
> diff --git a/chirp/ui/memedit.py b/chirp/ui/memedit.py
> --- a/chirp/ui/memedit.py
> +++ b/chirp/ui/memedit.py
> @@ -1062,10 +1062,7 @@
> if not mem.empty or self.show_empty:
> gobject.idle_add(self.set_memory, mem)
> else:
> - mem = chirp_common.Memory()
> - mem.number = number
> - mem.name = "ERROR"
> - mem.empty = True
> + mem = chirp_common.Memory(number, True, "Error")
> gobject.idle_add(self.set_memory, mem)
>
> for i in range(lo, hi+1):
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20210524/6bcdff9a/attachment-0001.html
More information about the chirp_devel
mailing list