def parse_xml(self, definition_xml): xmlutils = XmlUtils(definition_xml) platform = definition_xml.xpath('platform') if platform != []: self.platform = Platform(platform[0]) shell = definition_xml.xpath('shell') if shell != []: self.shell = Shell(shell[0]) xml_method = definition_xml.xpath('xml-method') for i in xml_method: self.xml_method.append(XmlMethod(i)) common_schema = definition_xml.xpath('common-schema') for i in common_schema: self.common_schema.append(i.xpath('text()')[0]) instance_list = definition_xml.xpath('instances') for i in instance_list: self.instances.append(Instance(i)) meaningful_use = definition_xml.xpath('meaningful-use') if meaningful_use != []: self.meaningful_use = MeaningfulUse(meaningful_use[0]) self.updated_date = xmlutils.get_datetime_by_xpath('updated-date/text()')
def parse_xml(self, platform_xml): xmlutils = XmlUtils(platform_xml) self.url = xmlutils.get_string_by_xpath('url/text()') self.version = xmlutils.get_string_by_xpath('version/text()') for i in platform_xml.xpath('configuration'): self.configuration[i.get('key')] = i.xpath('text()')[0]
def parse_xml(self, thing_type_permission_xml): xmlutils = XmlUtils(thing_type_permission_xml) self.thing_type_id = xmlutils.get_string_by_xpath('thing-type-id/text()') if thing_type_permission_xml.xpath('online-access-permissions') != []: self.online_access_permissions = Permission(thing_type_permission_xml.xpath('online-access-permissions')[0]) if thing_type_permission_xml.xpath('offline-access-permissions') != []: self.offline_access_permissions = Permission(thing_type_permission_xml.xpath('offline-access-permissions')[0])
def parse_xml(self, shell_xml): xmlutils = XmlUtils(shell_xml) self.url = xmlutils.get_string_by_xpath('url/text()') self.redirect_url = xmlutils.get_string_by_xpath('redirect-url/text()') for i in shell_xml.xpath('redirect-token'): self.redirect_token.append(ShellRedirectToken(i))
def parse_response(self, response): self.parse_info(response) for i in self.info.xpath('response-results/person-info'): self.authorized_people.append(PersonInfo(i)) xmlutils = XmlUtils(self.info) self.more_results = xmlutils.get_bool_by_xpath('more-results')
def parse_xml(self, info_element): xmlutils = XmlUtils(info_element) self.personid = xmlutils.get_string_by_xpath('person-id/text()') self.name = xmlutils.get_string_by_xpath('name/text()') self.selected_record_id = xmlutils.get_string_by_xpath('selected-record-id/text()') records = info_element.xpath('record') for i in records: self.records.append(Record(i))
def parse_xml(self, rule_xml): xmlutils = XmlUtils(rule_xml) self.name = xmlutils.get_string('name') self.reason = self.get_culture_specific_dictionary(rule_xml, 'reason') self.display_flags = xmlutils.get_int('display-flags/text()') self.permissions = Permission(rule_xml) for typeid in rule_xml.xpath('target-set/type-id'): self.typeids.append(typeid.xpath('text()')[0])
def parse_xml(self, xml): ''' :param xml: lxml.etree.Element representing a single VocabularyItem ''' xmlutils = XmlUtils(xml) self.code_value = xmlutils.get_string_by_xpath('code-value') self.display_text = xmlutils.get_string_by_xpath('display-text') self.abbreviation_text = xmlutils.get_string_by_xpath('abbreviation-text') info_xml = xml.xpath('info-xml') if info_xml != []: self.info_xml = info_xml[0]
def parse_thing(self): super(Weight, self).parse_thing() if self.thing_xml.xpath('data-xml') != []: xmlutils = XmlUtils(self.thing_xml) when_node = self.thing_xml.xpath('data-xml/weight/when') if len(when_node) > 0: self.when = xmlutils.get_datetime_from_when(when_node[0]) self.value_kg = xmlutils.get_float_by_xpath('data-xml/weight/value/kg/text()') self.display_value = xmlutils.get_float_by_xpath('data-xml/weight/value/display/text()') self.display_unit = xmlutils.get_string_by_xpath('data-xml/weight/value/display/@units') else: self.is_partial = True
def parse_thing(self): super(Height, self).parse_thing() if self.thing_xml.xpath("data-xml") != []: xmlutils = XmlUtils(self.thing_xml) when_node = self.thing_xml.xpath("data-xml/height/when") if len(when_node) > 0: self.when = xmlutils.get_datetime_from_when(when_node[0]) self.value_m = xmlutils.get_float_by_xpath("data-xml/height/value/m/text()") self.display_value = xmlutils.get_float_by_xpath("data-xml/height/value/display/text()") self.display_unit = xmlutils.get_string_by_xpath("data-xml/height/value/display/@units") else: self.is_partial = True
def parse_thing(self): super(BasicDemographicInformation, self).parse_thing() if self.thing_xml.xpath('data-xml') != []: xmlutils = XmlUtils(self.thing_xml) self.gender = xmlutils.get_string_by_xpath('data-xml/basic/gender/text()') self.birthyear = xmlutils.get_int_by_xpath('data-xml/basic/birthyear/text()') country_node = self.thing_xml.xpath('data-xml/basic/country') if country_node: self.country = CodedValue(country_node[0]) self.postcode = xmlutils.get_string_by_xpath('data-xml/basic/postcode/text()') else: self.is_partial = True
def parse_xml(self, record_xml): xmlhelper = XmlUtils(record_xml) self.id = xmlhelper.get_string('id') self.record_custodian = xmlhelper.get_bool('record-custodian') self.rel_type = xmlhelper.get_int('rel-type') self.rel_name = xmlhelper.get_string('rel-name') self.auth_expires = xmlhelper.get_datetime('auth-expires') self.auth_expired = xmlhelper.get_bool('auth-expired') self.display_name = xmlhelper.get_string('display-name') self.date_created = xmlhelper.get_datetime('date-created')
def parse_xml(self, instance_xml): xmlutils = XmlUtils(instance_xml) self.id = xmlutils.get_string_by_xpath('id/text()') self.name = xmlutils.get_string_by_xpath('name/text()') self.description = xmlutils.get_string_by_xpath('description/text()') self.platform_url = xmlutils.get_string_by_xpath('platform-url/text()') self.shell_url = xmlutils.get_string_by_xpath('shell-url/text()')
def parse_xml(self, xml): ''' :param key_xml: lxml.etree.Element representing a single VocabularyCodeSet ''' xmlutils = XmlUtils(xml) self.name = xmlutils.get_string_by_xpath('name') self.family = xmlutils.get_string_by_xpath('family') self.version = xmlutils.get_string_by_xpath('version') for item in xml.xpath('code-item'): self.code_item.append(VocabularyCodeItem(item)) self.is_vocab_truncated = xmlutils.get_bool_by_xpath('is-vocab-truncated') self.language = xmlutils.get_lang()
def __init__(self, coded_value_xml=None): self.text = None self.value = None self.family = None self._type = None self.version = None if coded_value_xml is not None: xmlutils = XmlUtils(coded_value_xml) self.text = xmlutils.get_string_by_xpath('text/text()') self.value = xmlutils.get_string_by_xpath('code/value/text()') self.family = xmlutils.get_string_by_xpath('code/family/text()') self._type = xmlutils.get_string_by_xpath('code/type/text()') self.version = xmlutils.get_string_by_xpath('code/version/text()')
def parse_xml(self, key_xml): ''' Parse a VocabularyKey from an Xml as per Healthvault schema. :param key_xml: lxml.etree.Element representing a single VocabularyKey ''' xmlutils = XmlUtils(key_xml) self.name = xmlutils.get_string_by_xpath('name') self.family = xmlutils.get_string_by_xpath('family') self.version = xmlutils.get_string_by_xpath('version') self.description = xmlutils.get_string_by_xpath('description') self.language = xmlutils.get_lang()
def parse_xml(self, info_element): xmlutils = XmlUtils(info_element) self.id = xmlutils.get_string_by_xpath('application/id/text()') self.name = self.get_culture_specific_dictionary(info_element, 'name') self.app_auth_required = xmlutils.get_bool_by_xpath('application/app-auth-required/text()') self.restrict_app_users = xmlutils.get_bool_by_xpath('application/restrict-app-users/text()') self.is_published = xmlutils.get_bool_by_xpath('application/is-published/text()') self.action_url = xmlutils.get_string_by_xpath('application/action-url/text()') self.description = self.get_culture_specific_dictionary(info_element, 'description') self.auth_reason = self.get_culture_specific_dictionary(info_element, 'auth-reason') large_logo = info_element.xpath('application/large-logo') if large_logo != []: self.large_logo = ApplicationBinaryContent(large_logo[0]) small_logo = info_element.xpath('application/small-logo') if small_logo != []: self.small_logo = ApplicationBinaryContent(small_logo[0]) online_rules = info_element.xpath('application/person-online-base-auth-xml/auth/rules/rule') if online_rules != []: for rule in online_rules: self.online_base_auth_rules.append(AuthRule(rule)) offline_rules = info_element.xpath('application/person-offline-base-auth-xml/auth/rules/rule') if offline_rules != []: for rule in offline_rules: self.offline_base_auth_rules.append(AuthRule(rule)) if info_element.xpath('application/privacy-statement') != []: self.privacy_statement = Statement(info_element.xpath('application/privacy-statement')[0]) if info_element.xpath('application/terms-of-use') != []: self.terms_of_use = Statement(info_element.xpath('application/terms-of-use')[0]) if info_element.xpath('application/dtc-success-message') != []: self.dtc_success_message = Statement(info_element.xpath('application/dtc-success-message')[0])
def parse_response(self, response): self.parse_info(response) xmlutils = XmlUtils(self.info) self.app_id = xmlutils.get_string_by_xpath('app-id/text()') self.shared_secret = xmlutils.get_string_by_xpath('shared-secret/text()') self.app_token = xmlutils.get_string_by_xpath('app-token/text()')
def parse_xml(self, key_xml): xmlutils = XmlUtils(key_xml) self.thing_id = xmlutils.get_string_by_xpath('text()') self.version_stamp = xmlutils.get_string_by_xpath('@version-stamp')
def parse_xml(self, meaningful_use_xml): xmlutils = XmlUtils(meaningful_use_xml) self.enabled = xmlutils.get_bool_by_xpath('enabled/text()') for i in meaningful_use_xml.xpath('configuration'): self.configuration[i.get('key')] = i.xpath('text()')[0]
def parse_xml(self, method_xml): xmlutils = XmlUtils(method_xml) self.name = xmlutils.get_string_by_xpath('name/text()') for i in method_xml.xpath('version'): self.version.append(XmlMethodVersion(i))