-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
9,571 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
W3C SOFTWARE NOTICE AND LICENSE | ||
|
||
Copyright (c) 2018 W3C® (MIT, ERCIM, Keio, Beihang) | ||
|
||
License | ||
|
||
By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply | ||
with the following terms and conditions. | ||
|
||
Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee | ||
or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, | ||
including modifications: | ||
|
||
- The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. | ||
- Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, | ||
the W3C Software and Document Short Notice should be included, see | ||
https://www.w3.org/Consortium/Legal/2015/copyright-software-short-notice.html | ||
- Notice of any changes or modifications, through a copyright statement on the new code or document such as | ||
"This software or document includes material copied from or derived from [title and URI of the W3C document]. | ||
Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." | ||
|
||
Disclaimers | ||
|
||
THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF | ||
THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. | ||
|
||
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY | ||
USE OF THE SOFTWARE OR DOCUMENT. | ||
|
||
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work | ||
without specific, written prior permission. Title to copyright in this work will at all times remain with copyright | ||
holders. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Metadata-Version: 1.0 | ||
Name: pyRdfa | ||
Version: 3.4.3 | ||
Name: pyRdfa3 | ||
Version: 3.5.0 | ||
Summary: RDFa 1.1 distiller | ||
Author: Ivan Herman | ||
Author-email: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Extracting possible embedded RDF/XML content from the file and parse it separately into the Graph. This is used, for example | ||
by U{SVG 1.2 Tiny<http://www.w3.org/TR/SVGMobile12/>}. | ||
@author: U{Ivan Herman<a href="http://www.w3.org/People/Ivan/">} | ||
@license: This software is available for use under the | ||
U{W3C® SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">} | ||
@contact: Ivan Herman, [email protected] | ||
@version: $Id: embeddedRDF.py,v 1.15 2012/11/16 17:51:53 ivan Exp $ | ||
""" | ||
|
||
# Python 3 foolproof way... | ||
try : | ||
from io import StringIO | ||
except : | ||
from StringIO import StringIO | ||
|
||
from .host import HostLanguage, accept_embedded_rdf_xml, accept_embedded_turtle | ||
from .utils import return_XML | ||
import re, sys | ||
|
||
def handle_embeddedRDF(node, graph, state) : | ||
""" | ||
Handles embedded RDF. There are two possibilities: | ||
- the file is one of the XML dialects that allows for an embedded RDF/XML portion. See the L{host.accept_embedded_rdf_xml} for those (a typical example is SVG). | ||
- the file is HTML and there is a turtle portion in the C{<script>} element with type text/turtle. | ||
@param node: a DOM node for the top level element | ||
@param graph: target rdf graph | ||
@type graph: RDFLib's Graph object instance | ||
@param state: the inherited state (namespaces, lang, etc) | ||
@type state: L{state.ExecutionContext} | ||
@return: whether an RDF/XML or turtle content has been detected or not. If TRUE, the RDFa processing should not occur on the node and its descendents. | ||
@rtype: Boolean | ||
""" | ||
#def _get_prefixes_in_turtle() : | ||
# retval = "" | ||
# for key in state.term_or_curie.ns : | ||
# retval += "@prefix %s: <%s> .\n" % (key, state.term_or_curie.ns[key]) | ||
# retval += '\n' | ||
# return retval | ||
|
||
# This feature is optional! | ||
def _get_literal(Pnode): | ||
""" | ||
Get the full text | ||
@param Pnode: DOM Node | ||
@return: string | ||
""" | ||
rc = "" | ||
for node in Pnode.childNodes: | ||
if node.nodeType in [node.TEXT_NODE, node.CDATA_SECTION_NODE] : | ||
rc = rc + node.data | ||
# Sigh... the HTML5 parser does not recognize the CDATA escapes, ie, it just passes on the <![CDATA[ and ]]> strings:-( | ||
return rc.replace("<![CDATA[","").replace("]]>","") | ||
|
||
if state.options.embedded_rdf : | ||
# Embedded turtle, per the latest Turtle draft | ||
if state.options.host_language in accept_embedded_turtle and node.nodeName.lower() == "script" : | ||
if node.hasAttribute("type") and node.getAttribute("type") == "text/turtle" : | ||
#prefixes = _get_prefixes_in_turtle() | ||
#content = _get_literal(node) | ||
#rdf = StringIO(prefixes + content) | ||
content = _get_literal(node) | ||
rdf = StringIO(content) | ||
try : | ||
graph.parse(rdf, format="n3", publicID = state.base) | ||
state.options.add_info("The output graph includes triples coming from an embedded Turtle script") | ||
except : | ||
(type,value,traceback) = sys.exc_info() | ||
state.options.add_error("Embedded Turtle content could not be parsed (problems with %s?); ignored" % value) | ||
return True | ||
elif state.options.host_language in accept_embedded_rdf_xml and node.localName == "RDF" and node.namespaceURI == "http://www.w3.org/1999/02/22-rdf-syntax-ns#" : | ||
rdf = StringIO(return_XML(state, node)) | ||
try : | ||
graph.parse(rdf) | ||
state.options.add_info("The output graph includes triples coming from an embedded RDF/XML subtree") | ||
except : | ||
(type,value,traceback) = sys.exc_info() | ||
state.options.add_error("Embedded RDF/XML content could not parsed (problems with %s?); ignored" % value) | ||
return True | ||
else : | ||
return False | ||
else : | ||
return False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Collection of external modules that are used by pyRdfa and are added for an easier | ||
distribution | ||
""" |
Oops, something went wrong.