Skip to content

Commit

Permalink
Fix bug with fetch_plugins function in login.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrench56 committed Jul 15, 2024
1 parent c216660 commit fe87d82
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/backend/plugins/priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
_PRIORITIES: List[Tuple[str, int]] = []


def fetch_plugins() -> Generator[Tuple[str, int], None, None]:
def fetch_plugins(reload: bool = False) -> Generator[Tuple[str, int], None, None]:
if not reload and len(_PRIORITIES) > 0:
for pp_pair in _PRIORITIES:
yield ((pp_pair[0], pp_pair[1]))
return

with open(f'{PLUGINS_DIR}/priorities.csv', 'r', encoding='utf-8') as f:
name, priority = f.readline().strip().split(',')
_PRIORITIES.append((name, int(priority)))
yield (name, int(priority))
while True:
line = f.readline()
if not line:
# EOF
break
name, priority = line.strip().split(',')
_PRIORITIES.append((name, int(priority)))
yield (name, int(priority))
f.close()


Expand Down

0 comments on commit fe87d82

Please sign in to comment.