Skip to content

Commit 71a9566

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "[IMPR] return a boolean with item_is_in_list and item_has_label"
2 parents 09bdfb2 + 1f7b49b commit 71a9566

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

scripts/create_isbn_edition.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -696,39 +696,39 @@ def get_language_preferences() -> list[str]:
696696
return main_languages
697697

698698

699-
def item_is_in_list(statement_list: list, itemlist: list[str]) -> str:
699+
def item_is_in_list(statement_list: list, itemlist: list[str]) -> bool:
700700
"""Verify if statement list contains at least one item from the itemlist.
701701
702702
param statement_list: Statement list
703703
param itemlist: List of values (string)
704-
return: Matching or empty string
704+
return: Whether the item matches
705705
"""
706706
for seq in statement_list:
707707
with suppress(AttributeError): # Ignore NoneType error
708708
isinlist = seq.getTarget().getID()
709709
if isinlist in itemlist:
710-
return isinlist
711-
return ''
710+
return True
711+
return False
712712

713713

714-
def item_has_label(item, label: str) -> str:
714+
def item_has_label(item, label: str) -> bool:
715715
"""Verify if the item has a label.
716716
717717
:param item: Item
718718
:param label: Item label
719-
:return: Matching string
719+
:return: Whether the item has a label
720720
"""
721721
label = unidecode(label).casefold()
722722
for lang in item.labels:
723723
if unidecode(item.labels[lang]).casefold() == label:
724-
return item.labels[lang]
724+
return True
725725

726726
for lang in item.aliases:
727727
for seq in item.aliases[lang]:
728728
if unidecode(seq).casefold() == label:
729-
return seq
729+
return True
730730

731-
return '' # Must return "False" when no label
731+
return False
732732

733733

734734
def is_in_value_list(statement_list: list, valuelist: list[str]) -> bool:

0 commit comments

Comments
 (0)