summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@surroundaustralia.com>2021-12-17 13:38:46 +1000
committerGitHub <noreply@github.com>2021-12-17 13:38:46 +1000
commit5230af3b684aa16840b1e9d2e9e2c5f4b095052b (patch)
tree1c450c8e84cd86d48e0a747c039703032368a507
parent12551ebe4add2a8c1c6b909b61cc118c28d246c0 (diff)
parent5750a725a2c777f2ca54aaad5378ca5888372e65 (diff)
downloadrdflib-5230af3b684aa16840b1e9d2e9e2c5f4b095052b.tar.gz
Merge pull request #1473 from RDFLib/drone_py310
Add Py 3.10 to testing envs
-rw-r--r--.drone.yml20
-rw-r--r--rdflib/namespace/_SDO.py6
-rw-r--r--rdflib/namespace/__init__.py2
-rwxr-xr-xrdflib/plugins/parsers/notation3.py12
-rw-r--r--rdflib/plugins/serializers/xmlwriter.py4
-rw-r--r--rdflib/plugins/shared/jsonld/context.py6
-rw-r--r--rdflib/plugins/shared/jsonld/errors.py1
-rw-r--r--rdflib/plugins/shared/jsonld/util.py1
-rw-r--r--rdflib/tools/defined_namespace_creator.py30
-rw-r--r--rdflib/tools/rdfs2dot.py22
10 files changed, 59 insertions, 45 deletions
diff --git a/.drone.yml b/.drone.yml
index d1c95d08..7a46aea6 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -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
diff --git a/rdflib/namespace/_SDO.py b/rdflib/namespace/_SDO.py
index a572cad9..9745c518 100644
--- a/rdflib/namespace/_SDO.py
+++ b/rdflib/namespace/_SDO.py
@@ -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.
@@ -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.
@@ -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.
diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py
index 8ce4de79..e1f0b52b 100644
--- a/rdflib/namespace/__init__.py
+++ b/rdflib/namespace/__init__.py
@@ -445,7 +445,7 @@ class NamespaceManager(object):
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
diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py
index 31b20036..2bd85688 100755
--- a/rdflib/plugins/parsers/notation3.py
+++ b/rdflib/plugins/parsers/notation3.py
@@ -27,13 +27,10 @@ Modified to work with rdflib by Gunnar Aastrand Grimnes
Copyright 2010, Gunnar A. Grimnes
"""
-
-# Python standard libraries
import sys
import os
import re
import codecs
-import warnings
from decimal import Decimal
@@ -1902,8 +1899,7 @@ class TurtleParser(Parser):
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)
@@ -1957,10 +1953,6 @@ def _test(): # pragma: no cover
doctest.testmod()
-# if __name__ == '__main__':
-# _test()
-
-
def main(): # pragma: no cover
g = ConjunctiveGraph()
@@ -1984,5 +1976,3 @@ def main(): # pragma: no cover
if __name__ == "__main__":
main()
-
-# ends
diff --git a/rdflib/plugins/serializers/xmlwriter.py b/rdflib/plugins/serializers/xmlwriter.py
index 99d1e767..b0f1a06e 100644
--- a/rdflib/plugins/serializers/xmlwriter.py
+++ b/rdflib/plugins/serializers/xmlwriter.py
@@ -100,8 +100,8 @@ class XMLWriter(object):
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)
diff --git a/rdflib/plugins/shared/jsonld/context.py b/rdflib/plugins/shared/jsonld/context.py
index 30bb02ea..2bf38f44 100644
--- a/rdflib/plugins/shared/jsonld/context.py
+++ b/rdflib/plugins/shared/jsonld/context.py
@@ -34,7 +34,11 @@ from .keys import (
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
diff --git a/rdflib/plugins/shared/jsonld/errors.py b/rdflib/plugins/shared/jsonld/errors.py
index 977d2d6f..f1973f14 100644
--- a/rdflib/plugins/shared/jsonld/errors.py
+++ b/rdflib/plugins/shared/jsonld/errors.py
@@ -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")
diff --git a/rdflib/plugins/shared/jsonld/util.py b/rdflib/plugins/shared/jsonld/util.py
index 8a0cfa74..e703c14c 100644
--- a/rdflib/plugins/shared/jsonld/util.py
+++ b/rdflib/plugins/shared/jsonld/util.py
@@ -44,6 +44,7 @@ def source_to_json(source):
finally:
stream.close()
+
VOCAB_DELIMS = ("#", "/", ":")
diff --git a/rdflib/tools/defined_namespace_creator.py b/rdflib/tools/defined_namespace_creator.py
index 82803f9d..f3eeaecf 100644
--- a/rdflib/tools/defined_namespace_creator.py
+++ b/rdflib/tools/defined_namespace_creator.py
@@ -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])))
@@ -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
@@ -134,7 +138,7 @@ if __name__ == "__main__":
"target_namespace",
type=str,
help="The namespace within the ontology that you want to create a "
- "DefinedNamespace for.",
+ "DefinedNamespace for.",
)
parser.add_argument(
@@ -144,11 +148,12 @@ if __name__ == "__main__":
)
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)
@@ -165,8 +170,10 @@ if __name__ == "__main__":
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...")
@@ -175,12 +182,5 @@ if __name__ == "__main__":
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
)
-
-
-
diff --git a/rdflib/tools/rdfs2dot.py b/rdflib/tools/rdfs2dot.py
index cb8d0bfd..97a4b975 100644
--- a/rdflib/tools/rdfs2dot.py
+++ b/rdflib/tools/rdfs2dot.py
@@ -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')