Skip to content

Commit

Permalink
Always return dicts or exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
elupus committed Oct 13, 2022
1 parent ea41a1c commit 258f041
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions haphilipsjs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,11 +1254,10 @@ async def getStrings(
language: Optional[str] = None,
country: Optional[str] = None,
variant: Optional[str] = None,
) -> Union[Dict[str, str], None]:
) -> Dict[str, str]:
res: Dict[str, str] = {}
for group in chunked_iterator(MAXIMUM_ITEMS_IN_REQUEST, strings):
if (data := await self._getStrings(group, language=language, country=country, variant=variant)) is None:
return None
data = await self._getStrings(group, language=language, country=country, variant=variant)
res.update(data)
return res

Expand All @@ -1268,7 +1267,7 @@ async def _getStrings(
language: Optional[str] = None,
country: Optional[str] = None,
variant: Optional[str] = None,
):
) -> Dict[str, str]:
data: StringsRequest = {
"strings": [{"string_id": string} for string in strings],
"locale": {
Expand All @@ -1284,7 +1283,7 @@ async def _getStrings(
for translation in res["translations"]
if translation["string_translation"]
}
return None
return {}

async def getMenuItemsSettingsStructure(self, force=False) -> Optional[MenuItemsSettingsStructure]:
if self.json_feature_supported("menuitems", "Setup_Menu") or force:
Expand Down

0 comments on commit 258f041

Please sign in to comment.