Module Gnumed.business.gmLinuxMedNewsXML

Import LinuxMedNews XML data.

http://linuxmednews.com/1414243433

Functions

def parse_xml_linuxmednews(xml_text=None, filename=None)
Expand source code
def parse_xml_linuxmednews(xml_text=None, filename=None):
        dob_format = '%Y-%m-%d'

        try:
                if xml_text is None:
                        _log.debug('parsing XML in [%s]', filename)
                        pat = etree.parse(filename)
                else:
                        pat = etree.fromstring(xml_text)
        except etree.ParseError:
                _log.exception('Cannot parse, is this really XML ?')
                return None

        dto = gmPerson.cDTO_person()

        dto.firstnames = pat.find('firstname').text
        dto.lastnames = pat.find('lastname').text
        dto.title = pat.find('name_prefix').text
        dto.gender = pat.find('gender').text
        dob = pyDT.datetime.strptime(pat.find('DOB').text, dob_format)
        dto.dob = dob.replace(tzinfo = gmDateTime.pydt_now_here().tzinfo)
        dto.dob_is_estimated = False
        dto.source = 'LinuxMedNews XML'

        #dto.remember_comm_channel(channel=None, url=None):
        #dto.remember_address(number=None, street=None, urb=None, region_code=None, zip=None, country_code=None, adr_type=None, subunit=None)

        return dto