fix ci
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Daniel Sun 2023-01-09 19:33:17 +00:00
parent 718588d29a
commit 7ea8452e61
5 changed files with 23 additions and 17 deletions

View File

@ -159,4 +159,5 @@ def search(query, count):
resp = http_get(f'/api/groups/search/{query}/{count}')
result = handle_sync_response(resp)
for cn in result:
if cn != "": click.echo(cn)
if cn != "":
click.echo(cn)

View File

@ -4,7 +4,6 @@ from .SyncRequestController import SyncRequestController
from ceo.tui.views import SearchGroupResponseView
class SearchGroupController(SyncRequestController):
def __init__(self, model, app):
super().__init__(model, app)
@ -18,7 +17,7 @@ class SearchGroupController(SyncRequestController):
def on_next_button_pressed(self, button):
try:
self.model.query = self.get_username_from_view()
#self.model.count = 10
self.model.count = 10
except Controller.InvalidInput:
return
self.on_confirmation_button_pressed(button)

View File

@ -1,12 +1,9 @@
import urwid
from .ColumnResponseView import ColumnResponseView
class SearchGroupResponseView(ColumnResponseView):
def __init__(self, model, controller, app):
super().__init__(model, controller,app)
l = self.model.resp_json.copy()
rows = [(str(i), resp) for i, resp in enumerate(l) if resp != '']
super().__init__(model, controller, app)
matches = self.model.resp_json.copy()
rows = [(str(i), resp) for i, resp in enumerate(matches) if resp != '']
self.set_pairs(rows)

View File

@ -2,6 +2,7 @@ import urwid
from .ColumnView import ColumnView
class SearchGroupView(ColumnView):
def __init__(self, model, controller, app):
super().__init__(model, controller, app)

View File

@ -39,8 +39,10 @@ def get_group(group_name):
def search_group(query, count):
# compute levenshtein edit distance, adapted from rosetta code
def _fuzzy_match(s1, s2):
if len(s1) == 0: return len(s2)
if len(s2) == 0: return len(s1)
if len(s1) == 0:
return len(s2)
if len(s2) == 0:
return len(s1)
edits = [i for i in range(len(s2) + 1)]
for i in range(len(s1)):
corner = i
@ -60,12 +62,18 @@ def search_group(query, count):
self.string = string
self.score = score
# consider a score worse if the edit distance is larger
def __lt__(self, other): return self.score > other.score
def __gt__(self, other): return self.score < other.score
def __le__(self, other): return self.score >= other.score
def __ge__(self, other): return self.score <= other.score
def __eq__(self, other): return self.score == other.score
def __ne__(self, other): return self.score != other.score
def __lt__(self, other):
return self.score > other.score
def __gt__(self, other):
return self.score < other.score
def __le__(self, other):
return self.score >= other.score
def __ge__(self, other):
return self.score <= other.score
def __eq__(self, other):
return self.score == other.score
def __ne__(self, other):
return self.score != other.score
query = str(query)
count = int(count)