Skip to content

Commit

Permalink
Update detected models label generation and test
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Oct 3, 2024
1 parent 5835691 commit 841c4eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 10 additions & 2 deletions chirp/wxui/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def is_prolific_warning(string):
return 'PL2303' in string and 'CONTACT YOUR SUPPLIER' in string


def get_model_label(rclass):
detected = ','.join(
detected_value(rclass, m)
for m in rclass.detected_models(include_self=False))
if len(detected) > (32 - 5):
detected = 'others'
return detected


def get_fakes():
return {
'Fake NOP': developer.FakeSerial(),
Expand Down Expand Up @@ -532,8 +541,7 @@ def _select_vendor(self, vendor):
for rclass in self._vendors[vendor]:
display = model_value(rclass)
actual_models.append(display)
detected = ','.join(detected_value(rclass, x) for x in
rclass.detected_models(include_self=False))
detected = get_model_label(rclass)
if detected:
display += ' (+ %s)' % detected
display_models.append(display)
Expand Down
12 changes: 3 additions & 9 deletions tests/unit/test_wxui_radiothread.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,9 @@ def test_detected_model_labels(self):
# be visible in the model box.
for rclass in [x for x in directory.DRV_TO_RADIO.values()
if issubclass(x, chirp_common.DetectableInterface)]:
labels = []
for child_rclass in rclass.detected_models(include_self=False):
label = clone.detected_value(rclass, child_rclass)
self.assertNotEqual('', label)
labels.append(label)
if labels:
label = '%s (+ %s)' % (rclass.MODEL, ','.join(labels))
self.assertLessEqual(len(label), 32,
'Label %r is too long' % label)
label = clone.get_model_label(rclass)
self.assertLessEqual(len(label), 32,
'Label %r is too long' % label)


class TestException(Exception):
Expand Down

0 comments on commit 841c4eb

Please sign in to comment.