Beispiel #1
0
 def finalize(self):
     "Set the initials, in not done explicitly."
     super().finalize()
     if not self.get("initials"):
         value = "".join([n[0] for n in self.get("given", "").split() if n])
         self["initials"] = value
         self["initials_normalized"] = utils.to_ascii(value).lower()
Beispiel #2
0
 def get_researchers(self, family, given=None, initials=None):
     """Get the researcher entities for the family name,
     optionally filtering by given name, and/or initials.
     Return a list of researcher documents.
     """
     family = utils.to_ascii(family).lower()
     result = self.get_docs("researcher", "family", key=family)
     if given:
         given = utils.to_ascii(given).lower()
         result = [p for p in result if p["given_normalized"] == given]
     if initials:
         initials = utils.to_ascii(initials).lower()
         result = [
             p for p in result if p["initials_normalized"].startswith(initials)
         ]
     return result
Beispiel #3
0
 def set_family(self, value=None):
     "Set the family name from form data."
     if value is None:
         value = utils.squish(self.rqh.get_argument("family", ""))
     if not value:
         raise ValueError("No family name provided.")
     self["family"] = value
     self["family_normalized"] = utils.to_ascii(value).lower()
Beispiel #4
0
 def select_author(self, name):
     """Select publication by author name.
     The name must be of the form "Familyname Initials". It is normalized,
     i.e. non-ASCII characters are converted to most similar ASCII,
     and lower-cased. The match is exact, which is problematic;
     e.g. the initials used differs substantially between publications.
     If a wildcard '*' is present at the end, all suffixes are allowed
     from that point.
     """
     name = utils.to_ascii(name).lower().strip()
     if name.endswith("*"):
         name = name[:-1]
         self._select("publication",
                      "author",
                      key=name,
                      last=name + constants.CEILING)
     else:
         self._select("publication", "author", key=name)
Beispiel #5
0
def _normalized(value):
    return utils.to_ascii(value).lower()
Beispiel #6
0
 def set_initials(self, value=None):
     "Set the initials from form data."
     if value is None:
         value = "".join(self.rqh.get_argument("initials", "").split())
     self["initials"] = value
     self["initials_normalized"] = utils.to_ascii(value).lower()
Beispiel #7
0
 def set_given(self, value=None):
     "Set the given name from form data."
     if value is None:
         value = utils.squish(self.rqh.get_argument("given", ""))
     self["given"] = value
     self["given_normalized"] = utils.to_ascii(value).lower()
Beispiel #8
0
 def set_value(self, value):
     self["value"] = value
     self["normalized_value"] = utils.to_ascii(value).lower()