Ejemplo n.º 1
0
 def test_parseNameAbbreviation(self):
     abbr = "C.Wollam"
     self.assertEqual(util.parseNameAbbreviation(abbr), ("^c.*", "^wollam"),
                      abbr)
     abbr = "C Wollam"
     self.assertEqual(util.parseNameAbbreviation(abbr), ("^c.*", "^wollam"),
                      abbr)
     abbr = "C.Wollam Jr."
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^wollam( *jr)*"), abbr)
     abbr = "C Wollam Jr."
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^wollam( *jr)*"), abbr)
     abbr = "C.Wollam Jr"
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^wollam( *jr)*"), abbr)
     abbr = "C Wollam Jr"
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^wollam( *jr)*"), abbr)
     abbr = "C.Wollam II"
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^wollam( *ii)*"), abbr)
     abbr = "C Wollam II"
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^wollam( *ii)*"), abbr)
     abbr = "C.St. Wollam"
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      ("^c.*", "^st[\\. ]*wollam"), abbr)
     abbr = "TOUCHBACK"
     self.assertEqual(util.parseNameAbbreviation(abbr),
                      (None, "^touchback"), abbr)
Ejemplo n.º 2
0
 def _getQueryModel(self, **kwargs) -> QueryModel:
     qm = QueryModel()
     if "teams" in kwargs and kwargs["teams"] is not None:
         qm.cstart("team", kwargs["teams"], Operator.IN)
         if "include_previous_teams" in kwargs and kwargs[
                 "include_previous_teams"]:
             qm.cor("previous_teams", kwargs["teams"], Operator.IN)
     cmap = {
         "position":
         kwargs["positions"] if "positions" in kwargs else None,
         "last_name":
         kwargs["last_names"] if "last_names" in kwargs else None,
         "first_name":
         kwargs["first_names"] if "first_names" in kwargs else None,
         "profile_id":
         kwargs["profile_ids"] if "profile_ids" in kwargs else None
     }
     for name in cmap:
         if cmap[name] is not None:
             qm.cand(name, cmap[name], Operator.IN)
     if "player_abbreviations" in kwargs and kwargs[
             "player_abbreviations"] is not None:
         paqm = QueryModel()
         for pabb in kwargs["player_abbreviations"]:
             if not (pabb is None or pabb == ""):
                 curqm = QueryModel()
                 fi, ln = util.parseNameAbbreviation(pabb)
                 if not (fi is None and ln is None):
                     if fi is not None:
                         curqm.cstart("first_name", fi, Operator.REGEX, "i")
                     curqm.cand("last_name", ln, Operator.REGEX, "i")
                     paqm.cor(query_model=curqm)
         qm.cand(query_model=paqm)
     return qm