Skip to content

Commit

Permalink
Add openonly filter to Repeaterbook queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alrs committed May 27, 2024
1 parent e17c021 commit 58d1034
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions chirp/sources/repeaterbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ def do_fetch(self, status, params):
bands = params.pop('bands', [])
modes = params.pop('modes', [])
fmconv = params.pop('fmconv', False)
openonly = params.pop('openonly')

data_file = self.get_data(status,
params.get('country'),
params.pop('state'),
Expand Down Expand Up @@ -244,6 +246,12 @@ def match(item):
return (not search_filter or
search_filter.lower() in content.lower())

def open_repeater(item):
print(item)
if item['Use'] == 'OPEN':
return True
return False

def included_band(item):
if not bands:
return True
Expand All @@ -257,6 +265,8 @@ def included_band(item):
key=sorter):
if not item:
continue
if openonly == True and open_repeater(item) == False:
continue
if item['Operational Status'] != 'On-air':
continue
if dist and lat and lon and (
Expand Down
7 changes: 7 additions & 0 deletions chirp/wxui/query_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ def build(self):
self.Bind(wx.EVT_CHECKBOX, self._select_modes, self._modefilter)
self._add_grid(grid, _('Limit Modes'), self._modefilter)

self._openonly = wx.CheckBox(panel, label=_('Open repeaters only'))
self._openonly.SetValue(CONF.get_bool('openonly', 'repeaterbook'))
self._openonly.SetToolTip(_('Exclude private and closed repeaters'))
self._add_grid(grid, _('Limit use'), self._openonly)

self._fmconv = wx.CheckBox(panel, label=_('Convert to FM'))
self._fmconv.SetValue(CONF.get_bool('fmconv', 'repeaterbook'))
self._fmconv.SetToolTip(_('Dual-mode digital repeaters that support '
Expand Down Expand Up @@ -420,6 +425,7 @@ def do_query(self):
CONF.set('country', self._country.GetStringSelection(), 'repeaterbook')
CONF.set('service', self._service.GetStringSelection(), 'repeaterbook')
CONF.set_bool('fmconv', self._fmconv.IsChecked(), 'repeaterbook')
CONF.set_bool('openonly', self._openonly.IsChecked(), 'repeaterbook')
self.result_radio = repeaterbook.RepeaterBook()
super().do_query()

Expand All @@ -437,6 +443,7 @@ def get_params(self):
'service': 'gmrs' if service == _('GMRS') else '',
'service_display': self._service.GetStringSelection(),
'fmconv': self._fmconv.IsChecked(),
'openonly': self._openonly.IsChecked(),
}


Expand Down

0 comments on commit 58d1034

Please sign in to comment.