Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Rewrite parser as generator
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Aug 22, 2024
1 parent 316504d commit 44db71b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions python/nav/bin/update_ouis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import logging

from typing import List, Iterable
from typing import List, Iterable, Generator

import requests
from requests.exceptions import RequestException
Expand Down Expand Up @@ -53,16 +53,14 @@ def _download_oui_file(url: str) -> str:
return response.text


def _parse_ouis(oui_data: str) -> List[OUI]:
def _parse_ouis(oui_data: str) -> Generator[OUI, None, None]:
"""Returns lists of tuples containing OUI and vendor name for
each vendor
"""
oui_list = []
for line in oui_data.split('\n'):
if "(hex)" not in line:
continue
oui_list.append(_parse_line(line))
return oui_list
yield _parse_line(line)


def _parse_line(line: str) -> OUI:
Expand Down

0 comments on commit 44db71b

Please sign in to comment.