def _buildMetadata(self, parse_remote_metadata=False):
self.updateSequence = self._capabilities.attrib.get('<STR_LIT>')<EOL>serviceident = self._capabilities.find(_SERVICE_IDENTIFICATION_TAG)<EOL>self.identification = ServiceIdentification(serviceident)<EOL>serviceprov = self._capabilities.find(_SERVICE_PROVIDER_TAG)<EOL>if serviceprov is not None:<EOL><INDENT>self.provider = ServiceProvider(serviceprov)<EOL><DEDENT>self.operations = []<EOL>serviceop = self._capabilities.find(_OPERATIONS_METADATA_TAG)<EOL>if serviceop is not None:<EOL><INDENT>for elem in serviceop[:]:<EOL><INDENT>self.operations.append(OperationsMetadata(elem))<EOL><DEDENT><DEDENT>self.contents = {}<EOL>caps = self._capabilities.find(_CONTENTS_TAG)<EOL>def gather_layers(parent_elem, parent_metadata):<EOL><INDENT>for index, elem in enumerate(parent_elem.findall(_LAYER_TAG)):<EOL><INDENT>cm = ContentMetadata(<EOL>elem, parent=parent_metadata, index=index + <NUM_LIT:1>,<EOL>parse_remote_metadata=parse_remote_metadata)<EOL>if cm.id:<EOL><INDENT>if cm.id in self.contents:<EOL><INDENT>raise KeyError('<STR_LIT>'<EOL>'<STR_LIT>' % cm.id)<EOL><DEDENT>self.contents[cm.id] = cm<EOL><DEDENT>gather_layers(elem, cm)<EOL><DEDENT><DEDENT>gather_layers(caps, None)<EOL>self.tilematrixsets = {}<EOL>for elem in caps.findall(_TILE_MATRIX_SET_TAG):<EOL><INDENT>tms = TileMatrixSet(elem)<EOL>if tms.identifier:<EOL><INDENT>if tms.identifier in self.tilematrixsets:<EOL><INDENT>raise KeyError('<STR_LIT>'<EOL>'<STR_LIT>' % tms.identifier)<EOL><DEDENT>self.tilematrixsets[tms.identifier] = tms<EOL><DEDENT><DEDENT>self.themes = {}<EOL>for elem in self._capabilities.findall(_THEMES_TAG + '<STR_LIT:/>' + _THEME_TAG):<EOL><INDENT>theme = Theme(elem)<EOL>if theme.identifier:<EOL><INDENT>if theme.identifier in self.themes:<EOL><INDENT>raise KeyError('<STR_LIT>'<EOL>% theme.identifier)<EOL><DEDENT>self.themes[theme.identifier] = theme<EOL><DEDENT><DEDENT>serviceMetadataURL = self._capabilities.find(_SERVICE_METADATA_URL_TAG)<EOL>if serviceMetadataURL is not None:<EOL><INDENT>self.serviceMetadataURL = serviceMetadataURL.attrib[_HREF_TAG]<EOL><DEDENT>else:<EOL><INDENT>self.serviceMetadataURL = None<EOL><DEDENT>
set up capabilities metadata objects