Skip to content

Commit

Permalink
Ran prettier and fixed most ShapeChecker errors and warnings
Browse files Browse the repository at this point in the history
There's still more ShapeChecker errors and warnings. But this is a good start.
  • Loading branch information
Jim Amsden committed Apr 25, 2024
1 parent f752499 commit eb7fdc3
Show file tree
Hide file tree
Showing 4 changed files with 1,046 additions and 843 deletions.
40 changes: 33 additions & 7 deletions specs/sysml/Resources/genVocabAndShapes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,28 @@
},
{
"cell_type": "code",
"execution_count": 80,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'this is a test.'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s = '<p>this is a test.</p>'\n",
"s[3:-4]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -30,15 +51,20 @@
"# Get the description of the model element as the first paragraph\n",
"# with markdown removed (rdfs:comment is a string, not an XMLLiteral)\n",
"def comment(eModelElement, strip=True):\n",
" desc = f'{eModelElement.name}.' # rdfs:comment is required in the vocabulary, this is the default\n",
" a = eModelElement.getEAnnotation('http://www.eclipse.org/emf/2002/GenModel')\n",
" if a is None: return None\n",
" if a is None: return desc\n",
" description = a.details['documentation']\n",
" root = BeautifulSoup(str(description))\n",
" description = root.find('p') \n",
" if strip:\n",
" return description.get_text() # the first paragraph with the HTML stripped out\n",
" text = description.get_text() # the first paragraph with the HTML stripped out\n",
" if not (text is None or text==''): desc = text\n",
" else:\n",
" return description # include the markup\n",
" # strip off the <p> and </p>, they are not needed and cause the period to appear to be missing to shapechecker\n",
" desc = str(description)[3:-4] # but include the rest of the markup\n",
" if not desc.endswith('.'): desc = desc + '.'\n",
" return desc\n",
"\n",
"\n",
"# some useful RDF namespaces\n",
Expand Down Expand Up @@ -151,7 +177,7 @@
},
{
"cell_type": "code",
"execution_count": 82,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -204,7 +230,6 @@
" if isinstance(c, EClass):\n",
" shape = oslc_sysml_shapes.term(c.name+'Shape')\n",
" g.add((shape, RDF.type, oslc.ResourceShape)) # only Element\n",
" g.add((shape, oslc.name, Literal(c.name+'Shape')))\n",
" g.add((shape, DCTERMS.title, Literal(c.name+'Shape', datatype=RDF.XMLLiteral)))\n",
" g.add((shape, DCTERMS.description, Literal(comment(c,strip=False),datatype=RDF.XMLLiteral)))\n",
" g.add((shape, oslc.describes, URIRef(oslc_sysmlv2.term(c.name))))\n",
Expand All @@ -224,8 +249,9 @@
" if isinstance(a, EReference):\n",
" g.add((s, oslc.valueType, oslc.Resource))\n",
" g.add((s, oslc.range, oslc_sysmlv2.term(a.eType.name)))\n",
" g.add((s, oslc.representation, oslc.Either))\n",
" elif isinstance(a, EAttribute):\n",
" g.add((s, oslc.valueType, valueType(a)))\n",
" g.add((s, oslc.range, valueType(a)))\n",
" g.add((s, DCTERMS.description, Literal(comment(a,strip=False), datatype=RDF.XMLLiteral)))\n",
"\n",
"\n",
Expand Down
Loading

0 comments on commit eb7fdc3

Please sign in to comment.