def parse_resource_map_from_str(resource_map_xml): resource_map = d1_common.resource_map.ResourceMap() try: resource_map.deserialize(data=resource_map_xml, format='xml') except xml.sax.SAXException as e: raise d1_common.types.exceptions.InvalidRequest( 0, u'Invalid Resource Map. error="{}"'.format(str(e))) return resource_map
def parse_resource_map_from_str(resource_map_xml): resource_map = d1_common.resource_map.ResourceMap() try: resource_map.deserialize(data=resource_map_xml, format="xml") except xml.sax.SAXException as e: raise d1_common.types.exceptions.InvalidRequest( 0, 'Invalid Resource Map. error="{}"'.format(str(e)) ) return resource_map
def _parse_resource_map_from_file(resource_map_path): resource_map = d1_common.resource_map.ResourceMap() try: with open(resource_map_path, 'rb') as f: resource_map.deserialize(file=f, format='xml') except xml.sax.SAXException as e: raise d1_common.types.exceptions.InvalidRequest( 0, u'Invalid Resource Map. error="{}"'.format(str(e))) return resource_map
def _parse_resource_map_from_file(resource_map_path): resource_map = d1_common.resource_map.ResourceMap() try: with open(resource_map_path, "rb") as f: resource_map.deserialize(file=f, format="xml") except xml.sax.SAXException as e: raise d1_common.types.exceptions.InvalidRequest( 0, 'Invalid Resource Map. error="{}"'.format(str(e)) ) return resource_map