from typing import List
from lxml import objectify
from q2_sdk.models.cores.mappers.update_demographic_info import (
BaseUpdateDemographicInfoMapper,
)
from q2_cores.exceptions import CoreException
from ..queries import CoreAPIBaseQuery
[docs]
class UpdateDemographicInfoMapper(BaseUpdateDemographicInfoMapper):
[docs]
@staticmethod
def parse_returned_queries(list_of_queries: List[CoreAPIBaseQuery]):
assert len(list_of_queries) == 1
assert isinstance(list_of_queries[0], CoreAPIBaseQuery)
root = objectify.fromstring(list_of_queries[0].raw_core_response)
if hasattr(root.SubmitRequestResult.Output.UserAuthentication.Errors, "Error"):
error_txt = root.SubmitRequestResult.Output.UserAuthentication.Errors.Error.ErrorMessage.text
raise CoreException(f"Core returned Error: {error_txt}")
response_base = root.SubmitRequestResult.Output.Responses.ResponseBase
if hasattr(response_base.Errors, "Error"):
raise CoreException(
f"Core returned Error: {response_base.Errors.Error.ErrorMessage.text}"
)
return True