pymantic
Advanced tools
+4
-5
| Metadata-Version: 2.1 | ||
| Name: pymantic | ||
| Version: 0.2.6 | ||
| Version: 0.3.0 | ||
| Summary: Semantic Web and RDF library for Python | ||
@@ -21,3 +21,2 @@ Home-page: https://github.com/norcalrdf/pymantic/ | ||
| >>> from __future__ import print_function | ||
| >>> from pymantic.rdf import * | ||
@@ -38,3 +37,3 @@ >>> from pymantic.parsers import turtle_parser | ||
| ``pymantic`` requires Python 2.7 or higher. | ||
| ``pymantic`` requires Python 3.6 or higher. | ||
| ``lark`` is used for the Turtle and NTriples parser. | ||
@@ -74,6 +73,6 @@ The ``requests`` library is used for HTTP requests and the SPARQL client. | ||
| Classifier: Topic :: Text Processing :: Markup | ||
| Classifier: Programming Language :: Python :: 2.7 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Provides-Extra: testing |
| Metadata-Version: 2.1 | ||
| Name: pymantic | ||
| Version: 0.2.6 | ||
| Version: 0.3.0 | ||
| Summary: Semantic Web and RDF library for Python | ||
@@ -21,3 +21,2 @@ Home-page: https://github.com/norcalrdf/pymantic/ | ||
| >>> from __future__ import print_function | ||
| >>> from pymantic.rdf import * | ||
@@ -38,3 +37,3 @@ >>> from pymantic.parsers import turtle_parser | ||
| ``pymantic`` requires Python 2.7 or higher. | ||
| ``pymantic`` requires Python 3.6 or higher. | ||
| ``lark`` is used for the Turtle and NTriples parser. | ||
@@ -74,6 +73,6 @@ The ``requests`` library is used for HTTP requests and the SPARQL client. | ||
| Classifier: Topic :: Text Processing :: Markup | ||
| Classifier: Programming Language :: Python :: 2.7 | ||
| Classifier: Programming Language :: Python :: 3.5 | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Provides-Extra: testing |
@@ -5,3 +5,3 @@ requests | ||
| rdflib | ||
| lark-parser<0.7.2,>=0.7.0 | ||
| lark-parser<0.12.0,>=0.11.1 | ||
| pyld | ||
@@ -8,0 +8,0 @@ |
| # | ||
| version = '0.2.6' | ||
| version = '0.3.0' | ||
| release = version |
@@ -15,2 +15,3 @@ from collections import defaultdict | ||
| def __init__(self, environment=None): | ||
| super().__init__() | ||
| self.env = environment or pymantic.primitives.RDFEnvironment() | ||
@@ -17,0 +18,0 @@ self.profile = self.env.createProfile() |
@@ -65,3 +65,3 @@ """Parse RDF serialized as ntriples files. | ||
| class NTriplesTransformer(Transformer, BaseParser): | ||
| class NTriplesTransformer(BaseParser, Transformer): | ||
| """Transform the tokenized ntriples into RDF primitives. | ||
@@ -68,0 +68,0 @@ """ |
@@ -46,12 +46,12 @@ """Parse RDF serialized as turtle files. | ||
| RDF_TYPE = NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type') | ||
| RDF_NIL = NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#nil') | ||
| RDF_FIRST = NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#first') | ||
| RDF_REST = NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#rest') | ||
| RDF_TYPE = NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") | ||
| RDF_NIL = NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil") | ||
| RDF_FIRST = NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#first") | ||
| RDF_REST = NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest") | ||
| XSD_DECIMAL = NamedNode('http://www.w3.org/2001/XMLSchema#decimal') | ||
| XSD_DOUBLE = NamedNode('http://www.w3.org/2001/XMLSchema#double') | ||
| XSD_INTEGER = NamedNode('http://www.w3.org/2001/XMLSchema#integer') | ||
| XSD_BOOLEAN = NamedNode('http://www.w3.org/2001/XMLSchema#boolean') | ||
| XSD_STRING = NamedNode('http://www.w3.org/2001/XMLSchema#string') | ||
| XSD_DECIMAL = NamedNode("http://www.w3.org/2001/XMLSchema#decimal") | ||
| XSD_DOUBLE = NamedNode("http://www.w3.org/2001/XMLSchema#double") | ||
| XSD_INTEGER = NamedNode("http://www.w3.org/2001/XMLSchema#integer") | ||
| XSD_BOOLEAN = NamedNode("http://www.w3.org/2001/XMLSchema#boolean") | ||
| XSD_STRING = NamedNode("http://www.w3.org/2001/XMLSchema#string") | ||
@@ -130,3 +130,3 @@ | ||
| if not LEGAL_IRI.match(iri): | ||
| raise ValueError('Illegal characters in IRI: ' + iri) | ||
| raise ValueError("Illegal characters in IRI: " + iri) | ||
| return iri | ||
@@ -146,3 +146,3 @@ | ||
| if isinstance(predicate, Token): | ||
| if predicate.value != 'a': | ||
| if predicate.value != "a": | ||
| raise ValueError(predicate) | ||
@@ -164,5 +164,5 @@ predicate = RDF_TYPE | ||
| class TurtleTransformer(Transformer, BaseParser): | ||
| def __init__(self, base_iri=''): | ||
| super(TurtleTransformer, self).__init__() | ||
| class TurtleTransformer(BaseParser, Transformer): | ||
| def __init__(self, base_iri=""): | ||
| super().__init__() | ||
| self.base_iri = base_iri | ||
@@ -175,7 +175,8 @@ self.prefixes = self.profile.prefixes | ||
| def iri(self, children): | ||
| iriref_or_pname, = children | ||
| (iriref_or_pname,) = children | ||
| if iriref_or_pname.startswith('<'): | ||
| return self.make_named_node(smart_urljoin( | ||
| self.base_iri, self.decode_iriref(iriref_or_pname))) | ||
| if iriref_or_pname.startswith("<"): | ||
| return self.make_named_node( | ||
| smart_urljoin(self.base_iri, self.decode_iriref(iriref_or_pname)) | ||
| ) | ||
@@ -198,4 +199,4 @@ return iriref_or_pname | ||
| def prefixed_name(self, children): | ||
| pname, = children | ||
| ns, _, ln = pname.partition(':') | ||
| (pname,) = children | ||
| ns, _, ln = pname.partition(":") | ||
| return self.make_named_node(self.prefixes[ns] + decode_literal(ln)) | ||
@@ -218,7 +219,6 @@ | ||
| # Workaround for lalr parser token ambiguity in python 2.7 | ||
| if base_directive.startswith('@') and base_directive != '@base': | ||
| raise ValueError('Unexpected @base: ' + base_directive) | ||
| if base_directive.startswith("@") and base_directive != "@base": | ||
| raise ValueError("Unexpected @base: " + base_directive) | ||
| self.base_iri = smart_urljoin( | ||
| self.base_iri, self.decode_iriref(base_iriref)) | ||
| self.base_iri = smart_urljoin(self.base_iri, self.decode_iriref(base_iriref)) | ||
@@ -231,7 +231,7 @@ return [] | ||
| def blank_node(self, children): | ||
| bn, = children | ||
| (bn,) = children | ||
| if bn.type == 'ANON': | ||
| if bn.type == "ANON": | ||
| return self.make_blank_node() | ||
| elif bn.type == 'BLANK_NODE_LABEL': | ||
| elif bn.type == "BLANK_NODE_LABEL": | ||
| return self.make_blank_node(bn.value) | ||
@@ -265,9 +265,9 @@ else: | ||
| def numeric_literal(self, children): | ||
| numeric, = children | ||
| (numeric,) = children | ||
| if numeric.type == 'DECIMAL': | ||
| if numeric.type == "DECIMAL": | ||
| return self.make_datatype_literal(numeric, datatype=XSD_DECIMAL) | ||
| elif numeric.type == 'DOUBLE': | ||
| elif numeric.type == "DOUBLE": | ||
| return self.make_datatype_literal(numeric, datatype=XSD_DOUBLE) | ||
| elif numeric.type == 'INTEGER': | ||
| elif numeric.type == "INTEGER": | ||
| return self.make_datatype_literal(numeric, datatype=XSD_INTEGER) | ||
@@ -285,22 +285,22 @@ else: | ||
| return self.make_datatype_literal(literal_string, type_) | ||
| elif len(children) == 2 and children[1].type == 'LANGTAG': | ||
| elif len(children) == 2 and children[1].type == "LANGTAG": | ||
| lang = children[1][1:] # Remove @ | ||
| return self.make_language_literal(literal_string, lang) | ||
| else: | ||
| return self.make_datatype_literal( | ||
| literal_string, datatype=XSD_STRING) | ||
| return self.make_datatype_literal(literal_string, datatype=XSD_STRING) | ||
| def boolean_literal(self, children): | ||
| boolean, = children | ||
| (boolean,) = children | ||
| return self.make_datatype_literal(boolean, datatype=XSD_BOOLEAN) | ||
| def string(self, children): | ||
| literal, = children | ||
| (literal,) = children | ||
| if literal.type in ( | ||
| 'STRING_LITERAL_QUOTE', 'STRING_LITERAL_SINGLE_QUOTE', | ||
| "STRING_LITERAL_QUOTE", | ||
| "STRING_LITERAL_SINGLE_QUOTE", | ||
| ): | ||
| string = decode_literal(literal[1:-1]) | ||
| if literal.type in ( | ||
| 'STRING_LITERAL_LONG_SINGLE_QUOTE', | ||
| 'STRING_LITERAL_LONG_QUOTE', | ||
| "STRING_LITERAL_LONG_SINGLE_QUOTE", | ||
| "STRING_LITERAL_LONG_QUOTE", | ||
| ): | ||
@@ -318,4 +318,4 @@ string = decode_literal(literal[3:-3]) | ||
| def parse(string_or_stream, graph=None, base=''): | ||
| if hasattr(string_or_stream, 'readline'): | ||
| def parse(string_or_stream, graph=None, base=""): | ||
| if hasattr(string_or_stream, "readline"): | ||
| string = string_or_stream.read() | ||
@@ -327,3 +327,3 @@ else: | ||
| if isinstance(string_or_stream, binary_type): | ||
| string = string_or_stream.decode('utf-8') | ||
| string = string_or_stream.decode("utf-8") | ||
| else: | ||
@@ -343,3 +343,3 @@ string = string_or_stream | ||
| def parse_string(string_or_bytes, graph=None, base=''): | ||
| def parse_string(string_or_bytes, graph=None, base=""): | ||
| return parse(string_or_bytes, graph, base) |
+1
-2
@@ -13,3 +13,2 @@ ======== | ||
| >>> from __future__ import print_function | ||
| >>> from pymantic.rdf import * | ||
@@ -30,3 +29,3 @@ >>> from pymantic.parsers import turtle_parser | ||
| ``pymantic`` requires Python 2.7 or higher. | ||
| ``pymantic`` requires Python 3.6 or higher. | ||
| ``lark`` is used for the Turtle and NTriples parser. | ||
@@ -33,0 +32,0 @@ The ``requests`` library is used for HTTP requests and the SPARQL client. |
+3
-3
@@ -29,6 +29,6 @@ from setuptools import setup, find_packages | ||
| 'Topic :: Text Processing :: Markup', | ||
| 'Programming Language :: Python :: 2.7', | ||
| 'Programming Language :: Python :: 3.5', | ||
| 'Programming Language :: Python :: 3.6', | ||
| 'Programming Language :: Python :: 3.7', | ||
| 'Programming Language :: Python :: 3.8', | ||
| 'Programming Language :: Python :: 3.9', | ||
| ], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
@@ -49,3 +49,3 @@ keywords='RDF N3 Turtle Semantics Web3.0', | ||
| 'rdflib', | ||
| 'lark-parser>=0.7.0,<0.7.2', | ||
| 'lark-parser>=0.11.1,<0.12.0', | ||
| 'pyld', | ||
@@ -52,0 +52,0 @@ ], |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
4540
0.02%220215
-0.06%