From d407224f354c4c901b24b293cbe7c359ee9659eb Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 15 Jun 2021 00:08:24 +0200 Subject: [PATCH] Add two methods to Item class --- matcher/model.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/matcher/model.py b/matcher/model.py index 653eeca..3f4d0de 100644 --- a/matcher/model.py +++ b/matcher/model.py @@ -58,6 +58,13 @@ class Item(Base): if d_list: return d_list[0]['value'] + def get_aliases(self, lang='en'): + if lang not in self.aliases: + if 'en' not in self.aliases: + return [] + lang = 'en' + return [a['value'] for a in self.aliases[lang]] + def get_part_of_names(self): if not self.claims: return set() @@ -128,6 +135,9 @@ class Item(Base): return dict(d) or None + def is_street(self): + return any(v and v["id"] == 'Q79007' for v in self.get_claim("P31")) + # class Claim(Base): # __tablename__ = "claim"