def __init__(self, terms, term_id, doc_xml, concept):
        """
        Parse the document to get its names.

        Only use name strings which have not be rejected, or
        marked as excluded from the glossifier. the list of
        names is augmented from the external_map table.
        """

        self.terms = terms
        self.id = term_id
        self.concept = concept
        self.names = { "en": [], "es": [] }
        root = etree.fromstring(doc_xml.encode("utf-8"))
        if cdr.get_text(root.find("TermNameStatus")) != "Rejected":
            for node in root.findall("TermName"):
                if node.get("ExcludeFromGlossifier") != "Yes":
                    name = cdr.get_text(node.find("TermNameString"))
                    self.names["en"].append(self.Name(name))
        for node in root.findall("TranslatedName"):
            status = cdr.get_text(node.find("TranslatedNameStatus"))
            if status != "Rejected":
                if node.get("ExcludeFromGlossifier") != "Yes":
                    name = cdr.get_text(node.find("TermNameString"))
                    self.names["es"].append(self.Name(name))
        for language in self.USAGES:
            for name in terms.extra_names[language].get(term_id, []):
                self.names[language].append(self.Name(name))
Esempio n. 2
0
 def __init__(self, node):
     self.type = node.get("Type")
     self.name = Partner.normalize(get_text(node.find("ContactName")))
     self.id = self.email = None
     detail = node.find("ContactDetail")
     if detail is not None:
         self.id = detail.get("{cips.nci.nih.gov/cdr}id")
         self.email = get_text(detail.find("Email"), "").strip()
Esempio n. 3
0
 def __init__(self, doc_id, root):
     self.doc_id = doc_id
     self.name = self.normalize(get_text(root.find(self.NAME)))
     licensee_type = get_text(root.find(self.TYPE), "").lower()
     status = get_text(root.find(self.STATUS), "").lower()
     if status.startswith("test"):
         self.activated = get_text(root.find(self.TEST_ACT))
         self.deactivated = get_text(root.find(self.TEST_OFF))
         self.status = "T"
     elif status:
         self.activated = get_text(root.find(self.PROD_ACT))
         self.deactivated = get_text(root.find(self.PROD_OFF))
         self.status = "S" if licensee_type == "special" else "A"
     else:
         self.status = self.activated = self.deactivated = None
     if "deactivated" in status:
         self.deactivated = True
     self.renewed = get_text(root.find(self.TEST_EXT))
     self.username = get_text(root.find(self.USERNAME))
     if self.username is not None:
         self.username = self.normalize(self.username)
     self.key = self.status, self.name.lower()
     self.contacts = []
     for node in root.findall("ContactPersons/ContactPerson"):
         contact = self.Contact(node)
         if contact.type in ("I", "P", "S") and contact.email:
             self.contacts.append(contact)
Esempio n. 4
0
    def __init__(self, control, node):
        """
        Extract the partner/contact information from the XML node.

        Also determine whether the partner's account (if it is
        a temporary, test account) has expired (or is about to
        expire).
        """

        self.control = control
        self.logger = control.logger
        self.job = control.job
        self.contact_id = node.get("pid")
        self.email = cdr.get_text(node.find("email_address"))
        self.person = cdr.get_text(node.find("person_name"))
        self.org = cdr.get_text(node.find("org_name"))
        self.type = cdr.get_text(node.find("org_status"))
        self.type_string = "%s Vendor" % self.TYPE_STRINGS[self.type]
        self.activated = cdr.get_text(node.find("activation_date"))
        self.renewed = cdr.get_text(node.find("renewal_date"))
        self.notified = cdr.get_text(node.find("notified_date"))
        self.org_id = cdr.get_text(node.find("org_id"))
        self.display = "%s at %s <%s>" % (self.person, self.org, self.email)
        self.expired = self.expiring = False
        if self.type == "T":
            start = self.renewed or self.activated
            if start < self.EXPIRATION_THRESHOLD:
                self.expired = True
            elif start < self.WARNING_THRESHOLD:
                start = datetime.datetime.strptime(start[:10], "%Y-%m-%d")
                self.expiring = start + datetime.timedelta(100)
        self.logger.debug(self.display)
Esempio n. 5
0
    def get_summary_language(self, filename):
        """
        Parse the summary document to determine its language.

        Pass:
          filename - string naming the file to examine
        """

        path = "{}/Summary/{}".format(self.job_path, filename)
        root = etree.parse(path).getroot()
        language = cdr.get_text(root.find("SummaryMetaData/SummaryLanguage"))
        return self.LANGUAGES[language]
Esempio n. 6
0
 def __init__(self, doc_id, root):
     self.doc_id = doc_id
     self.name = self.normalize(get_text(root.find(self.NAME)))
     licensee_type = get_text(root.find(self.TYPE), "").lower()
     status = get_text(root.find(self.STATUS), "").lower()
     if status.startswith("test"):
         self.activated = get_text(root.find(self.TEST_ACT))
         self.deactivated = get_text(root.find(self.TEST_OFF))
         self.status = "T"
     else:
         self.activated = get_text(root.find(self.PROD_ACT))
         self.deactivated = get_text(root.find(self.PROD_OFF))
         self.status = "S" if licensee_type == "special" else "A"
     self.username = get_text(root.find(self.USERNAME))
     if self.username is not None:
         self.username = self.normalize(self.username)
     self.key = self.status, self.name.lower()
Esempio n. 7
0
 def __init__(self, node):
     self.oid = int(node.get("oid"))
     self.name = cdr.get_text(node.find("org_name"))
     self.status = cdr.get_text(node.find("org_status"))
     self.uid = cdr.get_text(node.find("ftp_userid"))
     self.terminated = cdr.get_text(node.find("terminated"))