Skip to content

Commit 516b73f

Browse files
committed
0.17.0: fixed issues with reqif_io QUERY_PASSWORD and selecting configuraiton
1 parent 698835a commit 516b73f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3052
-1917
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.15.0
2+
current_version = 0.17.0
33
commit = True
44
tag = True
55

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
SPDX-License-Identifier: MIT
1010

11-
version="0.15.0"
11+
version="0.17.0"
1212

1313

1414
Introduction

elmclient/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
app = 'elmoslcquery'
1111
description = 'Commandline OSLC query for ELM'
12-
version = '0.15.0'
12+
version = '0.17.0'
1313
license = 'MIT'
1414
author_name = 'Ian Barnard'
1515
author_mail = '[email protected]'

elmclient/_qm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def load_components_and_configurations(self,force=False):
104104
# get all components
105105
crx = self.execute_get_xml( components_uri, intent="Retrieve component definition" )
106106
logger.info( f"{crx=}" )
107-
print( f"{crx=}" )
108107
# <oslc_config:Component rdf:about="https://jazz.ibm.com:9443/qm/oslc_config/resources/com.ibm.team.vvc.Component/_iw4s4EB3Eeus6Zk4qsm_Cw">
109108
# <dcterms:title rdf:parseType="Literal">SGC Agile</dcterms:title>
110109
# <oslc:instanceShape rdf:resource="https://jazz.ibm.com:9443/qm/oslc_config/resourceShapes/com.ibm.team.vvc.Component"/>

elmclient/_queryparser.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def term(self, s):
247247
#
248248
if op == "in":
249249
# the "value" is actually a list of values, each of which must be resolved if it is an identifier
250-
print( f"{value=}" )
250+
logger.info( f"{value=}" )
251251
if not isinstance(value, list):
252252
value = [value]
253253
resultlist = []
@@ -516,7 +516,6 @@ def inop(self, s):
516516

517517
def scoped_term(self, s):
518518
logger.info( f"scoped_term {s=}" )
519-
print( f"scoped_term {s=}" )
520519
return [s[0], "scope", s[1:]]
521520

522521
# from https://tools.oasis-open.org/version-control/svn/oslc-core/trunk/specs/oslc-core.html#selectiveProperties
@@ -533,7 +532,7 @@ def scoped_term(self, s):
533532
| "'" SPACYNAME "'"
534533
535534
URI_REF_ESC : /<https?:.*>/
536-
NAME : /[a-zA-Z0-9_]\w*/
535+
NAME : /[a-zA-Z0-9_][^, ]*/
537536
SPACYNAME : /[a-zA-Z0-9_][^']*/
538537
"""
539538

@@ -578,9 +577,11 @@ def wildcard(self,s):
578577
return "*"
579578

580579
def properties(self,s):
580+
logger.info( f"properties {s=} {s[0]=}" )
581581
return s
582582

583583
def property(self,s):
584+
logger.info( f"property {s=} {s[0]=}" )
584585
return s[0]
585586

586587
def sort_terms(self,s):
@@ -590,14 +591,17 @@ def sort_term(self,s):
590591
return s[0]
591592

592593
def signedterm(self,s):
594+
logger.info( f"signedterm {s=} {s[0]=}" )
593595
# mapping to always + or -
594596
signs = { ">": "+", "<": '-', "+": "+", "-": "-"}
595597
return signs[s[0]]+s[1]
596598

597599
def scoped_sort_terms(self,s):
600+
logger.info( f"scoped_sort_terms {s=} {s[0]=}" )
598601
return s
599602

600603
def identifier(self, s):
604+
logger.info( f"identifier {s=} {s[0]=}" )
601605
if len(s) == 1:
602606
resultname = s[0].value
603607
elif len(s) > 1:
@@ -622,7 +626,10 @@ def identifier(self, s):
622626
raise Exception( f"Cannot resolve {resultname} - no name resolver provided! " )
623627
else:
624628
# a prefixed name is assumed to be usable directly (the prefix has been added to prefixes)
629+
prefix = resultname.split( ":",1 )[0]
630+
self.prefixes[rdfxml.RDF_DEFAULT_PREFIX[prefix]] = prefix
625631
result = resultname
632+
logger.info( f"identifier1 {result=}" )
626633
return result
627634

628635
def dottedname(self,s):
@@ -641,3 +648,4 @@ def dottedname(self,s):
641648
self.mapping_uri_to_identifer[result] = f"{shapename}.{propname}"
642649
logger.info( f"dottedname {s=} {s[0]=} returns {result}" )
643650
return result
651+

elmclient/_rm.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,31 @@ def _load_type_from_resource_shape(self, el, supershape=None):
567567
logger.debug( f"ALREADY KNOWN" )
568568
continue
569569

570+
# get the property definition
571+
# a link has a Reference oslc:representation
572+
if rdfxml.xml_find_element( el, "oslc:representation[@rdf:resource='http://open-services.net/ns/core#Reference']") is not None:
573+
if propuri is not None:
574+
# this could be a link type or an attribute datatype reference
575+
# confirm this is a link type by checking for oslc:representation rdf:resource="http://open-services.net/ns/core#Reference"
576+
577+
# record the link type in the typesystem
578+
if propuri.startswith( self.reluri() ):
579+
linktype_x = self._get_typeuri_rdf(propuri)
580+
label = rdfxml.xml_find_element(linktype_x, './/rdfs:label').text
581+
ilabel = rdfxml.xml_find_element(linktype_x, './/rdfs:inverseLabel')
582+
inverselabel = ilabel.text if ilabel is not None else None
583+
rdfuri = None
584+
else:
585+
rdfuri = propuri
586+
label = property_title
587+
inverselabel = None
588+
589+
self.register_linktype( property_title, propuri, label, inverselabel=inverselabel, rdfuri=rdfuri, shape_uri=uri )
570590
logger.info( f"Defining property {name}.{property_title} {propuri=} +++++++++++++++++++++++++++++++++++++++" )
571591
# print( f"Defining property {name}.{property_title} {propuri=} {uri=} +++++++++++++++++++++++++++++++++++++++" )
572592
# self.register_property(property_title,propuri, shape_uri=uri)
573593
self.register_property(property_title,propuri)
574-
594+
# load the attribute definitions
575595
n += 1
576596
for range_el in rdfxml.xml_find_elements(el, 'oslc:range'):
577597
range_uri = range_el.get("{%s}resource" % rdfxml.RDF_DEFAULT_PREFIX["rdf"])

elmclient/_typesystem.py

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self,*args,**kwargs):
2626
def clear_typesystem(self):
2727
self.shapes = {}
2828
self.properties = {}
29+
self.linktypes = {}
2930
self.enums = {}
3031
self.values = {}
3132
self.typesystem_loaded = False
@@ -47,9 +48,11 @@ def addtoreport(s, end='\n'):
4748
report += s + end
4849

4950
reportedproperties = []
51+
reportedlinktypes = []
5052
# print a nicely sorted report with shapes at left, then properties (with type, if defined) in that shape, then enumerations in that property
5153
for shapeuri in sorted(self.shapes.keys(),key=lambda k: self.shapes[k]['name'].lower()):
5254
rows.append( [f"{quote(self.shapes[shapeuri]['name']):25}"] )
55+
# properties
5356
for propertyuri in sorted(self.shapes[shapeuri]['properties'], key=lambda k: self.properties[k]['name'].lower()):
5457
reportedproperties.append(propertyuri)
5558
rows.append( [ "",f"{quote(self.properties[propertyuri]['name'])}"] )
@@ -68,6 +71,21 @@ def addtoreport(s, end='\n'):
6871
eid = self.enums[enum_uri].get('id') or enum_uri
6972
rows.append( [""]*newrowlen+[f"{quote(self.enums[enum_uri]['name'])}",eid,enum_uri ] )
7073
logger.info( f"appended for enum {rows[-1]}" )
74+
# linktypes not reported on the shape as they're common to all shapes
75+
# # link types
76+
# for linktypeuri in sorted(self.shapes[shapeuri].get('linktypes',[]), key=lambda k: self.linktypes[k]['name'].lower()):
77+
# reportedlinktypes.append(linktypeuri)
78+
# rows.append( [ "",f"{quote(self.linktypes[linktypeuri]['name'])}"] )
79+
# rows[-1].append( f"{rdfxml.uri_to_default_prefixed_tag(linktypeuri)}" )
80+
# if self.linktypes[linktypeuri]['rdfuri'] is not None:
81+
# rows[-1].append( f"{rdfxml.uri_to_default_prefixed_tag(self.linktypes[linktypeuri]['rdfuri'])}" )
82+
# else:
83+
# rows[-1].append("")
84+
# rows[-1].append( f"{self.linktypes[linktypeuri]['label']}" )
85+
# rows[-1].append( f"{self.linktypes[linktypeuri]['inverselabel']}" )
86+
87+
newrowlen = len(rows[-1])-3
88+
7189
if len(rows)>0:
7290
addtoreport( "<h2>Shapes<h2>\n" )
7391
report += utils.print_in_html( rows,['Shape','Property Name','Property label','URI'] )
@@ -93,10 +111,26 @@ def addtoreport(s, end='\n'):
93111
eid = self.enums[enum_uri].get('id') or enum_uri
94112
rows.append( [""]*newrowlen+[f"{quote(self.enums[enum_uri]['name'])}",eid,enum_uri ] )
95113
logger.info( f"appended for enum {rows[-1]}" )
96-
97114
if len(rows)>0:
98115
addtoreport( "<h2>Properties with no shape</h2>\n" )
99116
report += utils.print_in_html( rows,['Shape','Property Name','Property label','URI'] )
117+
118+
# now report link types
119+
rows = []
120+
for linktypeuri in sorted(self.linktypes, key=lambda k: self.linktypes[k]['name'].lower()):
121+
rows.append( [ f"{quote(self.linktypes[linktypeuri]['name'])}"] )
122+
rows[-1].append( f"{rdfxml.uri_to_default_prefixed_tag(linktypeuri)}" )
123+
if self.linktypes[linktypeuri]['rdfuri'] is not None:
124+
rows[-1].append( f"{rdfxml.uri_to_default_prefixed_tag(self.linktypes[linktypeuri]['rdfuri'])}" )
125+
else:
126+
rows[-1].append("")
127+
rows[-1].append( f"{self.linktypes[linktypeuri]['label']}" )
128+
rows[-1].append( f"{self.linktypes[linktypeuri]['inverselabel']}" )
129+
130+
if len(rows)>0:
131+
addtoreport( "<h2>Link Types</h2>\n" )
132+
report += utils.print_in_html( rows,['Name', 'URI', 'RDF URI','Label','Inverse Label'] )
133+
100134

101135
return report
102136

@@ -127,7 +161,7 @@ def register_shape( self, shape_name, shape_uri ):
127161
if shape_uri in self.shapes:
128162
raise Exception( f"Shape {shape_uri} already defined!" )
129163
# add the URI as the main registration for the shape
130-
self.shapes[shape_uri] = {'name':shape_name,'shape':shape_uri,'properties':[]}
164+
self.shapes[shape_uri] = {'name':shape_name,'shape':shape_uri,'properties':[], 'linktypes':[]}
131165
self.loaded = True
132166

133167
def get_shape_uri( self, shape_name ):
@@ -173,6 +207,17 @@ def register_property( self, property_name, property_uri, *, property_value_type
173207
self.shapes[shape_uri]['properties'].append(property_uri)
174208
self.loaded = True
175209

210+
def register_linktype( self, linktype_name, linktype_uri, label, *, inverselabel=None, rdfuri=None, shape_uri=None ):
211+
logger.info( f"register_linktype {linktype_name=} {linktype_uri=} {label=} {inverselabel=} {rdfuri=}" )
212+
linktype_uri = self.normalise_uri( linktype_uri )
213+
shape_uri = self.normalise_uri( shape_uri )
214+
if linktype_uri not in self.linktypes:
215+
# self.linktypes[linktype_uri] = {'name': label, 'inverselabel': inverselabel, 'shape': shape_uri, 'rdfuri': rdfuri }
216+
self.linktypes[linktype_uri] = {'name': linktype_name, 'label': label, 'inverselabel': inverselabel, 'rdfuri': rdfuri }
217+
if shape_uri is not None:
218+
self.shapes[shape_uri]['linktypes'].append(linktype_uri)
219+
self.loaded = True
220+
176221
def get_property_uri( self, property_name, *, shape_uri=None ):
177222
logger.info( f"get_property_uri {property_name=} {shape_uri=}" )
178223
shape_uri = self.normalise_uri( shape_uri )
@@ -269,5 +314,15 @@ def get_uri_name( self, uri ):
269314
return result
270315

271316
def get_name_uri( self, name ):
272-
result = self.get_shape_uri(name) or self.get_property_uri(name) or self.get_enum_uri(name) or self.get_value_uri(name)
317+
result = self.get_shape_uri(name) or self.get_property_uri(name) or self.get_enum_uri(name) or self.get_value_uri(name) or self.get_linktype_uri(name)
273318
return result
319+
320+
def get_linktype_uri( self, name ):
321+
linktypes = [k for k,v in self.linktypes.items() if v['name']==name]
322+
if len(linktypes) > 1:
323+
raise Exception( f"Multiple link types with same name '{name}'" )
324+
if len(linktypes) == 0:
325+
return None
326+
327+
return linktypes[0]
328+

0 commit comments

Comments
 (0)