Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if val is not None:
couplingtype = etree.SubElement(resident, util.nspath_eval('srv:couplingType', self.namespaces))
etree.SubElement(couplingtype, util.nspath_eval('srv:SV_CouplingType', self.namespaces), codeListValue=val, codeList='%s#SV_CouplingType' % CODELIST).text = val
if esn in ['summary', 'full']:
# all service resources as coupled resources
coupledresources = util.getqattr(result, queryables['apiso:OperatesOn']['dbcol'])
operations = util.getqattr(result, queryables['apiso:Operation']['dbcol'])
if coupledresources:
for val2 in coupledresources.split(','):
coupledres = etree.SubElement(resident, util.nspath_eval('srv:coupledResource', self.namespaces))
svcoupledres = etree.SubElement(coupledres, util.nspath_eval('srv:SV_CoupledResource', self.namespaces))
opname = etree.SubElement(svcoupledres, util.nspath_eval('srv:operationName', self.namespaces))
etree.SubElement(opname, util.nspath_eval('gco:CharacterString', self.namespaces)).text = _get_resource_opname(operations)
sid = etree.SubElement(svcoupledres, util.nspath_eval('srv:identifier', self.namespaces))
etree.SubElement(sid, util.nspath_eval('gco:CharacterString', self.namespaces)).text = val2
# service operations
if operations:
for i in operations.split(','):
oper = etree.SubElement(resident, util.nspath_eval('srv:containsOperations', self.namespaces))
tmp = etree.SubElement(oper, util.nspath_eval('srv:SV_OperationMetadata', self.namespaces))
tmp2 = etree.SubElement(tmp, util.nspath_eval('srv:operationName', self.namespaces))
etree.SubElement(tmp2, util.nspath_eval('gco:CharacterString', self.namespaces)).text = i
tmp3 = etree.SubElement(tmp, util.nspath_eval('srv:DCP', self.namespaces))
etree.SubElement(tmp3, util.nspath_eval('srv:DCPList', self.namespaces), codeList='%s#DCPList' % CODELIST, codeListValue='HTTPGet').text = 'HTTPGet'
tmp4 = etree.SubElement(tmp, util.nspath_eval('srv:DCP', self.namespaces))
etree.SubElement(tmp4, util.nspath_eval('srv:DCPList', self.namespaces), codeList='%s#DCPList' % CODELIST, codeListValue='HTTPPost').text = 'HTTPPost'
# Metadata Point of Contact
poc = etree.SubElement(ex_caps,
util.nspath_eval('inspire_common:MetadataPointOfContact', self.inspire_namespaces))
etree.SubElement(poc,
util.nspath_eval('inspire_common:OrganisationName', self.inspire_namespaces)).text = self.inspire_config['contact_name']
etree.SubElement(poc,
util.nspath_eval('inspire_common:EmailAddress', self.inspire_namespaces)).text = self.inspire_config['contact_email']
# Metadata Date
etree.SubElement(ex_caps,
util.nspath_eval('inspire_common:MetadataDate', self.inspire_namespaces)).text = self.inspire_config['date']
# Spatial Data Service Type
etree.SubElement(ex_caps,
util.nspath_eval('inspire_common:SpatialDataServiceType', self.inspire_namespaces)).text = 'discovery'
# Mandatory Keyword
mkey = etree.SubElement(ex_caps,
util.nspath_eval('inspire_common:MandatoryKeyword', self.inspire_namespaces))
mkey.attrib[util.nspath_eval('xsi:type', self.context.namespaces)] = 'inspire_common:classificationOfSpatialDataService'
etree.SubElement(mkey,
util.nspath_eval('inspire_common:KeywordValue', self.inspire_namespaces)).text = 'infoCatalogueService'
# Gemet Keywords
for gkw in self.inspire_config['gemet_keywords'].split(','):
gkey = etree.SubElement(ex_caps,
util.nspath_eval('inspire_common:Keyword', self.inspire_namespaces))
if operationsmetadata:
LOGGER.debug('Writing section OperationsMetadata.')
operationsmetadata = etree.SubElement(node,
util.nspath_eval('ows:OperationsMetadata',
self.parent.context.namespaces))
for operation in self.parent.context.model['operations_order']:
oper = etree.SubElement(operationsmetadata,
util.nspath_eval('ows:Operation', self.parent.context.namespaces),
name=operation)
dcp = etree.SubElement(oper, util.nspath_eval('ows:DCP',
self.parent.context.namespaces))
http = etree.SubElement(dcp, util.nspath_eval('ows:HTTP',
self.parent.context.namespaces))
if self.parent.context.model['operations'][operation]['methods']['get']:
get = etree.SubElement(http, util.nspath_eval('ows:Get',
self.parent.context.namespaces))
get.attrib[util.nspath_eval('xlink:type',\
self.parent.context.namespaces)] = 'simple'
get.attrib[util.nspath_eval('xlink:href',\
self.parent.context.namespaces)] = self.parent.config.get('server', 'url')
if self.parent.context.model['operations'][operation]['methods']['post']:
post = etree.SubElement(http, util.nspath_eval('ows:Post',
self.parent.context.namespaces))
post.attrib[util.nspath_eval('xlink:type',
# decipher typename
dvtype = None
if self.parent.profiles is not None:
for prof in self.parent.profiles['loaded'].keys():
for prefix in self.parent.profiles['loaded'][prof].prefixes:
if pname2.find(prefix) != -1:
dvtype = self.parent.profiles['loaded'][prof].typename
break
if not dvtype:
dvtype = 'csw30:Record'
domainvalue = etree.SubElement(node,
util.nspath_eval('csw30:DomainValues', self.parent.context.namespaces),
type=dvtype, resultType='available')
etree.SubElement(domainvalue,
util.nspath_eval('csw30:ValueReference',
self.parent.context.namespaces)).text = pname
try:
LOGGER.debug(
'Querying repository property %s, typename %s, \
domainquerytype %s',
pname2, dvtype, self.parent.domainquerytype)
results = self.parent.repository.query_domain(
pname2, dvtype, self.parent.domainquerytype, True)
LOGGER.debug('Results: %d', len(results))
if self.parent.domainquerytype == 'range':
rangeofvalues = etree.SubElement(domainvalue,
http = etree.SubElement(dcp, util.nspath_eval('ows20:HTTP',
self.parent.context.namespaces))
if self.parent.context.model['operations'][operation]['methods']['get']:
get = etree.SubElement(http, util.nspath_eval('ows20:Get',
self.parent.context.namespaces))
get.attrib[util.nspath_eval('xlink:type',\
self.parent.context.namespaces)] = 'simple'
get.attrib[util.nspath_eval('xlink:href',\
self.parent.context.namespaces)] = self.parent.config.get('server', 'url')
if self.parent.context.model['operations'][operation]['methods']['post']:
post = etree.SubElement(http, util.nspath_eval('ows20:Post',
self.parent.context.namespaces))
post.attrib[util.nspath_eval('xlink:type',
self.parent.context.namespaces)] = 'simple'
post.attrib[util.nspath_eval('xlink:href',
self.parent.context.namespaces)] = \
self.parent.config.get('server', 'url')
for parameter in \
sorted(self.parent.context.model['operations'][operation]['parameters']):
param = etree.SubElement(oper,
util.nspath_eval('ows20:Parameter',
self.parent.context.namespaces), name=parameter)
param.append(self._write_allowed_values(self.parent.context.model['operations'][operation]['parameters'][parameter]['values']))
if operation == 'GetRecords': # advertise queryables, MaxRecordDefault
schema_location_ns = util.nspath_eval('xsi:schemaLocation',
self.context.namespaces)
node.attrib[schema_location_ns] = '%s %s' % (
self.context.namespaces['soapenv'],
self.context.namespaces['soapenv']
)
node2 = etree.SubElement(
node, util.nspath_eval('soapenv:Body', self.context.namespaces))
if self.exception:
node3 = etree.SubElement(
node2,
util.nspath_eval('soapenv:Fault', self.context.namespaces)
)
node4 = etree.SubElement(
node3,
util.nspath_eval('soapenv:Code', self.context.namespaces)
)
etree.SubElement(
node4,
util.nspath_eval('soapenv:Value', self.context.namespaces)
).text = 'soap:Server'
node4 = etree.SubElement(
node3,
util.nspath_eval('soapenv:Reason', self.context.namespaces)
)
etree.SubElement(
node4,
def _get_pt_freetext(val, language):
freetext = etree.Element(util.nspath_eval('gm03:GM03_2_1Core.Core.PT_FreeText', NAMESPACES))
textgroup = etree.SubElement(freetext, util.nspath_eval('gm03:textGroup', NAMESPACES))
ptgroup = etree.SubElement(textgroup, util.nspath_eval('gm03:GM03_2_1Core.Core.PT_Group', NAMESPACES))
if language:
etree.SubElement(ptgroup, util.nspath_eval('gm03:language', NAMESPACES)).text = language
etree.SubElement(ptgroup, util.nspath_eval('gm03:plainText', NAMESPACES)).text = val
return freetext
def _write_verboseresponse(self, insertresults):
''' show insert result identifiers '''
insertresult = etree.Element(util.nspath_eval('csw:InsertResult',
self.parent.context.namespaces))
for ir in insertresults:
briefrec = etree.SubElement(insertresult,
util.nspath_eval('csw:BriefRecord',
self.parent.context.namespaces))
etree.SubElement(briefrec,
util.nspath_eval('dc:identifier',
self.parent.context.namespaces)).text = ir['identifier']
etree.SubElement(briefrec,
util.nspath_eval('dc:title',
self.parent.context.namespaces)).text = ir['title']
return insertresult
fltcaps = etree.SubElement(node,
util.nspath_eval('ogc:Filter_Capabilities', self.parent.context.namespaces))
spatialcaps = etree.SubElement(fltcaps,
util.nspath_eval('ogc:Spatial_Capabilities', self.parent.context.namespaces))
geomops = etree.SubElement(spatialcaps,
util.nspath_eval('ogc:GeometryOperands', self.parent.context.namespaces))
for geomtype in \
fes1.MODEL['GeometryOperands']['values']:
etree.SubElement(geomops,
util.nspath_eval('ogc:GeometryOperand',
self.parent.context.namespaces)).text = geomtype
spatialops = etree.SubElement(spatialcaps,
util.nspath_eval('ogc:SpatialOperators', self.parent.context.namespaces))
for spatial_comparison in \
fes1.MODEL['SpatialOperators']['values']:
etree.SubElement(spatialops,
util.nspath_eval('ogc:SpatialOperator', self.parent.context.namespaces),
name=spatial_comparison)
scalarcaps = etree.SubElement(fltcaps,
util.nspath_eval('ogc:Scalar_Capabilities', self.parent.context.namespaces))
etree.SubElement(scalarcaps, util.nspath_eval('ogc:LogicalOperators',
self.parent.context.namespaces))
cmpops = etree.SubElement(scalarcaps,
util.nspath_eval('ogc:ComparisonOperators', self.parent.context.namespaces))
def _write_date(dateval, datetypeval, nsmap):
date1 = etree.Element(util.nspath_eval('gmd:date', nsmap))
date2 = etree.SubElement(date1, util.nspath_eval('gmd:CI_Date', nsmap))
date3 = etree.SubElement(date2, util.nspath_eval('gmd:date', nsmap))
if dateval.find('T') != -1:
dateel = 'gco:DateTime'
else:
dateel = 'gco:Date'
etree.SubElement(date3, util.nspath_eval(dateel, nsmap)).text = dateval
datetype = etree.SubElement(date2, util.nspath_eval('gmd:dateType', nsmap))
datetype.append(_write_codelist_element('gmd:CI_DateTypeCode', datetypeval, nsmap))
return date1