Skip to content

Commit

Permalink
Have created a PyPI distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
iherman committed Oct 30, 2018
1 parent 0b21268 commit ef311a7
Show file tree
Hide file tree
Showing 42 changed files with 9,571 additions and 10 deletions.
33 changes: 33 additions & 0 deletions LICENSE
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.
5 changes: 0 additions & 5 deletions LICENSE.txt

This file was deleted.

4 changes: 2 additions & 2 deletions PKG-INFO
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]
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Note: the development and maintenance of this package has been stalled for a lon

Historically, the core of this repository content was part to the core RDFLib package as a parser, i.e., it could be used without further ado. However, this setup created some problems and, in 2018, it was decided to remove it from the core distribution of RDFLib, starting with version 5.0.0. Users wishing to use this parser should import _both_ rdflib and pyrdfa3 before using the parser, ie, before invoking `graph.parse( ..., format='rdfa')`. The package can also be used as a standalone tool, in the documentation; this is maintained to secure that deployed applications would not break.

2013-10-29
The package can be downloaded from [PyPI](https://pypi.org/project/pyRdfa3/) via `pip install pyRdfa3`.

2013-10-30

---

Expand Down
936 changes: 936 additions & 0 deletions build/lib/pyRdfa/__init__.py

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions build/lib/pyRdfa/embeddedRDF.py
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

4 changes: 4 additions & 0 deletions build/lib/pyRdfa/extras/__init__.py
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
"""
Loading

0 comments on commit ef311a7

Please sign in to comment.