Skip to content

Commit

Permalink
Reduce get_services cognitive complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
Taapat committed Nov 12, 2023
1 parent 97af688 commit c7ba474
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/FreeChannelsUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,24 @@ def cancel_scan(self, answer):

@staticmethod
def get_services(ref):
services = []
servicelist = eServiceCenter.getInstance().list(ref)
if servicelist:
while True:
service = servicelist.getNext()
if not service.valid():
if not servicelist:
return []
services = []
while True:
service = servicelist.getNext()
if not service.valid():
break
if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker):
continue
name = eServiceCenter.getInstance().info(service).getName(service)
if not name or name == ".":
continue
for n in (" SID 0X", "(...)", "TEST ", " TEST"):
if n in name.upper():
break
if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker):
continue
name = eServiceCenter.getInstance().info(service).getName(service)
if not name or name == ".":
continue
for n in (" SID 0X", "(...)", "TEST ", " TEST"):
if n in name.upper():
break
else:
services.append((name, service))
else:
services.append((name, service))
if "ORDER BY bouquet" not in ref.toString():
services.sort(key=lambda x: x[0])
return [s[1] for s in services]
Expand Down

0 comments on commit c7ba474

Please sign in to comment.