Skip to content

Commit

Permalink
Merge pull request #1473 from RDFLib/drone_py310
Browse files Browse the repository at this point in the history
Add Py 3.10 to testing envs
  • Loading branch information
nicholascar committed Dec 17, 2021
2 parents 12551eb + 5750a72 commit 5230af3
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 45 deletions.
20 changes: 20 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@ steps:
- black --config black.toml --check ./rdflib || true
- flake8 --exit-zero rdflib
- ./with-fuseki.sh pytest -ra

---
kind: pipeline
name: python-3-10
type: docker
platform:
os: linux
arch: amd64

steps:
- name: test
image: python:3.10
commands:
- apt-get update && apt-get install -y openjdk-11-jdk-headless
- pip install --default-timeout 60 -r requirements.txt
- pip install --default-timeout 60 -r requirements.dev.txt
- python setup.py install
- black --config black.toml --check ./rdflib | true
- flake8 --exit-zero rdflib
- ./with-fuseki.sh pytest -ra
6 changes: 3 additions & 3 deletions rdflib/namespace/_SDO.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ class SDO(DefinedNamespace):
MayTreatHealthAspect: URIRef # Related topics may be treated by a Topic.
MeasurementTypeEnumeration: URIRef # Enumeration of common measurement types (or dimensions), for example "chest" for a person, "inseam" for pants, "gauge" for screws, or "wheel" for bicycles.
MediaGallery: URIRef # Web page type: Media gallery page. A mixed-media page that can contains media such as images, videos, and other multimedia.
MediaManipulationRatingEnumeration: URIRef # Codes for use with the [[mediaAuthenticityCategory]] property, indicating the authenticity of a media object (in the context of how it was published or shared). In general these codes are not mutually exclusive, although some combinations (such as 'original' versus 'transformed', 'edited' and 'staged') would be contradictory if applied in the same [[MediaReview]]. Note that the application of these codes is with regard to a piece of media shared or published in a particular context.
MediaManipulationRatingEnumeration: URIRef # Codes for use with the [[mediaAuthenticityCategory]] property, indicating the authenticity of a media object (in the context of how it was published or shared). In general these codes are not mutually exclusive, although some combinations (such as 'original' versus 'transformed', 'edited' and 'staged') would be contradictory if applied in the same [[MediaReview]]. Note that the application of these codes is with regard to a piece of media shared or published in a particular context.
MediaObject: URIRef # A media object, such as an image, video, or audio object embedded in a web page or a downloadable dataset i.e. DataDownload. Note that a creative work may have many media objects associated with it on the same web page. For example, a page about a single song (MusicRecording) may have a music video (VideoObject), and a high and low bandwidth audio stream (2 AudioObject's).
MediaReview: URIRef # A [[MediaReview]] is a more specialized form of Review dedicated to the evaluation of media content online, typically in the context of fact-checking and misinformation. For more general reviews of media in the broader sense, use [[UserReview]], [[CriticReview]] or other [[Review]] types. This definition is a work in progress. While the [[MediaManipulationRatingEnumeration]] list reflects significant community review amongst fact-checkers and others working to combat misinformation, the specific structures for representing media objects, their versions and publication context, is still evolving. Similarly, best practices for the relationship between [[MediaReview]] and [[ClaimReview]] markup has not yet been finalized.
MediaReviewItem: URIRef # Represents an item or group of closely related items treated as a unit for the sake of evaluation in a [[MediaReview]]. Authorship etc. apply to the items rather than to the curation/grouping or reviewing party.
Expand Down Expand Up @@ -965,7 +965,7 @@ class SDO(DefinedNamespace):
Pulmonary: URIRef # A specific branch of medical science that pertains to the study of the respiratory system and its respective disease states.
QAPage: URIRef # A QAPage is a WebPage focussed on a specific Question and its Answer(s), e.g. in a question answering site or documenting Frequently Asked Questions (FAQs).
QualitativeValue: URIRef # A predefined value for a product characteristic, e.g. the power cord plug type 'US' or the garment sizes 'S', 'M', 'L', and 'XL'.
QuantitativeValue: URIRef # A point value or interval for product characteristics and other purposes.
QuantitativeValue: URIRef # A point value or interval for product characteristics and other purposes.
QuantitativeValueDistribution: URIRef # A statistical distribution of values.
Quantity: URIRef # Quantities such as distance, time, mass, weight, etc. Particular instances of say Mass are entities like '3 Kg' or '4 milligrams'.
Question: URIRef # A specific question - e.g. from a user seeking answers online, or collected in a Frequently Asked Questions (FAQ) document.
Expand Down Expand Up @@ -2247,7 +2247,7 @@ class SDO(DefinedNamespace):
observationDate: URIRef # The observationDate of an [[Observation]].
observedNode: URIRef # The observedNode of an [[Observation]], often a [[StatisticalPopulation]].
occupancy: URIRef # The allowed total occupancy for the accommodation in persons (including infants etc). For individual accommodations, this is not necessarily the legal maximum but defines the permitted usage as per the contractual agreement (e.g. a double room used by a single person). Typical unit code(s): C62 for person
occupationLocation: URIRef # The region/country for which this occupational description is appropriate. Note that educational requirements and qualifications can vary between jurisdictions.
occupationLocation: URIRef # The region/country for which this occupational description is appropriate. Note that educational requirements and qualifications can vary between jurisdictions.
occupationalCategory: URIRef # A category describing the job, preferably using a term from a taxonomy such as [BLS O*NET-SOC](http://www.onetcenter.org/taxonomy.html), [ISCO-08](https://www.ilo.org/public/english/bureau/stat/isco/isco08/) or similar, with the property repeated for each applicable value. Ideally the taxonomy should be identified, and both the textual label and formal code for the category should be provided.\n Note: for historical reasons, any textual label and formal code provided as a literal may be assumed to be from O*NET-SOC.
occupationalCredentialAwarded: URIRef # A description of the qualification, award, certificate, diploma or other occupational credential awarded as a consequence of successful completion of this course or program.
offerCount: URIRef # The number of offers for the product.
Expand Down
2 changes: 1 addition & 1 deletion rdflib/namespace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def compute_qname(self, uri, generate=True):
pl_namespace = get_longest_namespace(self.__strie[namespace], uri)
if pl_namespace is not None:
namespace = pl_namespace
name = uri[len(namespace):]
name = uri[len(namespace) :]

namespace = URIRef(namespace)
prefix = self.store.prefix(namespace) # warning multiple prefixes problem
Expand Down
12 changes: 1 addition & 11 deletions rdflib/plugins/parsers/notation3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@
Copyright 2010, Gunnar A. Grimnes
"""

# Python standard libraries
import sys
import os
import re
import codecs
import warnings

from decimal import Decimal

Expand Down Expand Up @@ -1902,8 +1899,7 @@ def parse(self, source, graph, encoding="utf-8", turtle=True):

if encoding not in [None, "utf-8"]:
raise ParserError(
("N3/Turtle files are always utf-8 encoded, I was passed: %s")
% encoding
"N3/Turtle files are always utf-8 encoded, I was passed: %s" % encoding
)

sink = RDFSink(graph)
Expand Down Expand Up @@ -1957,10 +1953,6 @@ def _test(): # pragma: no cover
doctest.testmod()


# if __name__ == '__main__':
# _test()


def main(): # pragma: no cover
g = ConjunctiveGraph()

Expand All @@ -1984,5 +1976,3 @@ def main(): # pragma: no cover

if __name__ == "__main__":
main()

# ends
4 changes: 2 additions & 2 deletions rdflib/plugins/serializers/xmlwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def qname(self, uri):
for pre, ns in self.extra_ns.items():
if uri.startswith(ns):
if pre != "":
return ":".join(pre, uri[len(ns):])
return ":".join(pre, uri[len(ns) :])
else:
return uri[len(ns):]
return uri[len(ns) :]

return self.nm.qname_strict(uri)
6 changes: 5 additions & 1 deletion rdflib/plugins/shared/jsonld/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
VERSION,
VOCAB,
)
from .errors import INVALID_REMOTE_CONTEXT, RECURSIVE_CONTEXT_INCLUSION
from .errors import (
INVALID_REMOTE_CONTEXT,
RECURSIVE_CONTEXT_INCLUSION,
INVALID_CONTEXT_ENTRY,
)
from .util import source_to_json, urljoin, urlsplit, split_iri, norm_url


Expand Down
1 change: 1 addition & 0 deletions rdflib/plugins/shared/jsonld/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ class JSONLDException(ValueError):
# http://www.w3.org/TR/json-ld-api/#idl-def-JsonLdErrorCode.{code-message}
RECURSIVE_CONTEXT_INCLUSION = JSONLDException("recursive context inclusion")
INVALID_REMOTE_CONTEXT = JSONLDException("invalid remote context")
INVALID_CONTEXT_ENTRY = JSONLDException("invalid context entry")
1 change: 1 addition & 0 deletions rdflib/plugins/shared/jsonld/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def source_to_json(source):
finally:
stream.close()


VOCAB_DELIMS = ("#", "/", ":")


Expand Down
30 changes: 15 additions & 15 deletions rdflib/tools/defined_namespace_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def get_target_namespace_elements(g, target_namespace):
# only get results for the target namespace (supplied by user)
FILTER STRSTARTS(STR(?s), "xxx")
}
""".replace("xxx", target_namespace)
""".replace(
"xxx", target_namespace
)
elements = []
for r in g.query(q, initNs=namespaces):
elements.append((str(r[0]), str(r[1])))
Expand All @@ -92,7 +94,9 @@ def get_target_namespace_elements(g, target_namespace):
elements_strs = []
for e in elements:
desc = e[1].replace('\n', ' ')
elements_strs.append(f" {e[0].replace(args.target_namespace, '')}: URIRef # {desc}\n")
elements_strs.append(
f" {e[0].replace(args.target_namespace, '')}: URIRef # {desc}\n"
)

return elements, elements_strs

Expand Down Expand Up @@ -134,7 +138,7 @@ class {object_id}(DefinedNamespace):
"target_namespace",
type=str,
help="The namespace within the ontology that you want to create a "
"DefinedNamespace for.",
"DefinedNamespace for.",
)

parser.add_argument(
Expand All @@ -144,11 +148,12 @@ class {object_id}(DefinedNamespace):
)

parser.add_argument(
'-f', "--fail",
'-f',
"--fail",
dest='fail',
action='store_true',
help="Whether (true) or not (false) to mimic ClosedNamespace and fail on "
"non-element use"
"non-element use",
)
parser.add_argument('--no-fail', dest='fail', action='store_false')
parser.set_defaults(feature=False)
Expand All @@ -165,8 +170,10 @@ class {object_id}(DefinedNamespace):

validate_object_id(args.object_id)

print(f"Creating DefinedNamespace file {args.object_id} "
f"for {args.target_namespace}...")
print(
f"Creating DefinedNamespace file {args.object_id} "
f"for {args.target_namespace}..."
)
print(f"Ontology with {len(g)} triples loaded...")

print("Getting all namespace elements...")
Expand All @@ -175,12 +182,5 @@ class {object_id}(DefinedNamespace):
output_file_name = Path().cwd() / f"_{args.object_id}.py"
print(f"Creating DefinedNamespace Python file {output_file_name}")
make_dn_file(
output_file_name,
args.target_namespace,
elements[1],
args.object_id,
args.fail
output_file_name, args.target_namespace, elements[1], args.object_id, args.fail
)



22 changes: 10 additions & 12 deletions rdflib/tools/rdfs2dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,19 @@ def rdfs2dot(g, stream, opts={}):
fields = collections.defaultdict(set)
nodes = {}

def node(x):

if x not in nodes:
nodes[x] = "node%d" % len(nodes)
return nodes[x]

def label(x, g):

l_ = g.value(x, RDFS.label)
if l_ is None:
def node(nd):
if nd not in nodes:
nodes[nd] = "node%d" % len(nodes)
return nodes[nd]

def label(xx, grf):
lbl = grf.value(xx, RDFS.label)
if lbl is None:
try:
l_ = g.namespace_manager.compute_qname(x)[2]
lbl = grf.namespace_manager.compute_qname(xx)[2]
except:
pass # bnodes and some weird URIs cannot be split
return l_
return lbl

stream.write('digraph { \n node [ fontname="DejaVu Sans" ] ; \n')

Expand Down

0 comments on commit 5230af3

Please sign in to comment.