Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed the module path references to relative paths (to embed the mo…

…dule into RDLib core)
  • Loading branch information...
commit 69ff41981838001e664ef14902c034019219a803 1 parent ab38d06
@iherman iherman authored
View
34 pyRdfa/__init__.py
@@ -187,7 +187,7 @@
from rdflib.RDF import RDFNS as ns_rdf
from rdflib.Graph import Graph
-from pyRdfa.extras.httpheader import acceptable_content_type, content_type
+from .extras.httpheader import acceptable_content_type, content_type
import xml.dom.minidom
@@ -291,12 +291,12 @@ class pyRdfaError(Exception) :
#############################################################################################
-from pyRdfa.state import ExecutionContext
-from pyRdfa.parse import parse_one_node
-from pyRdfa.options import Options
-from pyRdfa.transform import top_about, empty_safe_curie, vocab_for_role
-from pyRdfa.utils import URIOpener
-from pyRdfa.host import HostLanguage, MediaTypes, preferred_suffixes, content_to_host_language
+from .state import ExecutionContext
+from .parse import parse_one_node
+from .options import Options
+from .transform import top_about, empty_safe_curie, vocab_for_role
+from .utils import URIOpener
+from .host import HostLanguage, MediaTypes, preferred_suffixes, content_to_host_language
# Environment variable used to characterize cache directories for RDFa vocabulary files.
CACHE_DIR_VAR = "PyRdfaCacheDir"
@@ -502,7 +502,7 @@ def copyGraph(tog, fromg) :
# If the RDFS expansion has to be made, here is the place...
if self.options.vocab_expansion :
- from pyRdfa.rdfs.process import process_rdfa_sem
+ from .rdfs.process import process_rdfa_sem
process_rdfa_sem(default_graph, self.options)
# What should be returned depends on the way the options have been set up
@@ -608,7 +608,7 @@ def copyErrors(tog, options) :
input = self._get_input(name)
else :
input.seek(0)
- from pyRdfa.host import adjust_html_version
+ from .host import adjust_html_version
self.rdfa_version = adjust_html_version(input, self.rdfa_version)
except :
# if anyting goes wrong, it is not really important; rdfa version stays what it was...
@@ -616,7 +616,7 @@ def copyErrors(tog, options) :
else :
# in other cases an XML parser has to be used
- from pyRdfa.host import adjust_xhtml_and_version
+ from .host import adjust_xhtml_and_version
parse = xml.dom.minidom.parse
dom = parse(input)
(adjusted_host_language, version) = adjust_xhtml_and_version(dom, self.options.host_language, self.rdfa_version)
@@ -763,26 +763,26 @@ def _get_option(param, compare_value, default) :
transformers = []
if "rdfa_lite" in list(form.keys()) and form.getfirst("rdfa_lite").lower() == "true" :
- from pyRdfa.transform.lite import lite_prune
+ from .transform.lite import lite_prune
transformers.append(lite_prune)
# The code below is left for backward compatibility only. In fact, these options are not exposed any more,
# they are not really in use
if "extras" in list(form.keys()) and form.getfirst("extras").lower() == "true" :
- from pyRdfa.transform.metaname import meta_transform
- from pyRdfa.transform.OpenID import OpenID_transform
- from pyRdfa.transform.DublinCore import DC_transform
+ from .transform.metaname import meta_transform
+ from .transform.OpenID import OpenID_transform
+ from .transform.DublinCore import DC_transform
for t in [OpenID_transform, DC_transform, meta_transform] :
transformers.append(t)
else :
if "extra-meta" in list(form.keys()) and form.getfirst("extra-meta").lower() == "true" :
- from pyRdfa.transform.metaname import meta_transform
+ from .transform.metaname import meta_transform
transformers.append(meta_transform)
if "extra-openid" in list(form.keys()) and form.getfirst("extra-openid").lower() == "true" :
- from pyRdfa.transform.OpenID import OpenID_transform
+ from .transform.OpenID import OpenID_transform
transformers.append(OpenID_transform)
if "extra-dc" in list(form.keys()) and form.getfirst("extra-dc").lower() == "true" :
- from pyRdfa.transform.DublinCore import DC_transform
+ from .transform.DublinCore import DC_transform
transformers.append(DC_transform)
output_default_graph = True
View
4 pyRdfa/embeddedRDF.py
@@ -16,8 +16,8 @@
except :
from StringIO import StringIO
-from pyRdfa.host import HostLanguage, accept_embedded_rdf_xml, accept_embedded_turtle
-from pyRdfa.utils import return_XML
+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) :
View
4 pyRdfa/host/__init__.py
@@ -35,8 +35,8 @@
"""
__version__ = "3.0"
-from pyRdfa.host.atom import atom_add_entry_type
-from pyRdfa.host.html5 import html5_extra_attributes, remove_rel
+from .atom import atom_add_entry_type
+from .html5 import html5_extra_attributes, remove_rel
class HostLanguage :
"""An enumeration style class: recognized host language types for this processor of RDFa. Some processing details may depend on these host languages. "rdfa_core" is the default Host Language is nothing else is defined."""
View
6 pyRdfa/options.py
@@ -30,9 +30,9 @@
from rdflib.RDFS import RDFSNS as ns_rdfs
from rdflib.RDF import RDFNS as ns_rdf
-from pyRdfa.host import HostLanguage, MediaTypes, content_to_host_language, predefined_1_0_rel, require_embedded_rdf
-from pyRdfa import ns_xsd, ns_distill, ns_rdfa
-from pyRdfa import RDFA_Error, RDFA_Warning, RDFA_Info
+from .host import HostLanguage, MediaTypes, content_to_host_language, predefined_1_0_rel, require_embedded_rdf
+from . import ns_xsd, ns_distill, ns_rdfa
+from . import RDFA_Error, RDFA_Warning, RDFA_Info
ns_dc = Namespace("http://purl.org/dc/terms/")
ns_ht = Namespace("http://www.w3.org/2006/http#")
View
12 pyRdfa/parse.py
@@ -21,10 +21,10 @@
import sys
-from pyRdfa.state import ExecutionContext
-from pyRdfa.property import ProcessProperty
-from pyRdfa.embeddedRDF import handle_embeddedRDF
-from pyRdfa.host import HostLanguage, host_dom_transforms
+from .state import ExecutionContext
+from .property import ProcessProperty
+from .embeddedRDF import handle_embeddedRDF
+from .host import HostLanguage, host_dom_transforms
import rdflib
from rdflib import URIRef
@@ -40,8 +40,8 @@
from rdflib.RDFS import RDFSNS as ns_rdfs
from rdflib.RDF import RDFNS as ns_rdf
-from pyRdfa import IncorrectBlankNodeUsage, err_no_blank_node
-from pyRdfa.utils import has_one_of_attributes
+from . import IncorrectBlankNodeUsage, err_no_blank_node
+from .utils import has_one_of_attributes
#######################################################################
def parse_one_node(node, graph, parent_object, incoming_state, parent_incomplete_triples) :
View
6 pyRdfa/property.py
@@ -31,9 +31,9 @@
from rdflib.RDF import RDFNS as ns_rdf
from rdflib.Literal import XSDToPython
-from pyRdfa import IncorrectBlankNodeUsage, IncorrectLiteral, err_no_blank_node, ns_xsd
-from pyRdfa.utils import has_one_of_attributes, return_XML
-from pyRdfa.host.html5 import handled_time_types
+from . import IncorrectBlankNodeUsage, IncorrectLiteral, err_no_blank_node, ns_xsd
+from .utils import has_one_of_attributes, return_XML
+from .host.html5 import handled_time_types
XMLLiteral = ns_rdf["XMLLiteral"]
HTMLLiteral = URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML")
View
4 pyRdfa/rdfs/__init__.py
@@ -32,8 +32,8 @@
from rdflib.RDF import RDFNS as ns_rdf
from rdflib.Graph import Graph
-from pyRdfa import RDFaError, pyRdfaError
-from pyRdfa import ns_rdfa, ns_xsd, ns_distill
+from .. import RDFaError, pyRdfaError
+from .. import ns_rdfa, ns_xsd, ns_distill
VocabCachingInfo = ns_distill["VocabCachingInfo"]
View
28 pyRdfa/rdfs/cache.py
@@ -27,26 +27,26 @@
from rdflib.RDF import RDFNS as ns_rdf
from rdflib.Graph import Graph
-from pyRdfa import HTTPError, RDFaError
-from pyRdfa.host import MediaTypes, HostLanguage
-from pyRdfa.utils import create_file_name, URIOpener, quote_URI
-from pyRdfa.options import Options
-from pyRdfa import ns_rdfa
+from .. import HTTPError, RDFaError
+from ..host import MediaTypes, HostLanguage
+from ..utils import create_file_name, URIOpener, quote_URI
+from ..options import Options
+from .. import ns_rdfa
-from pyRdfa.rdfs import err_outdated_cache
-from pyRdfa.rdfs import err_unreachable_vocab
-from pyRdfa.rdfs import err_unparsable_Turtle_vocab
-from pyRdfa.rdfs import err_unparsable_xml_vocab
-from pyRdfa.rdfs import err_unparsable_ntriples_vocab
-from pyRdfa.rdfs import err_unparsable_rdfa_vocab
-from pyRdfa.rdfs import err_unrecognised_vocab_type
+from . import err_outdated_cache
+from . import err_unreachable_vocab
+from . import err_unparsable_Turtle_vocab
+from . import err_unparsable_xml_vocab
+from . import err_unparsable_ntriples_vocab
+from . import err_unparsable_rdfa_vocab
+from . import err_unrecognised_vocab_type
-from pyRdfa.rdfs import VocabCachingInfo
+from . import VocabCachingInfo
# Regular expression object for a general XML application media type
xml_application_media_type = re.compile("application/[a-zA-Z0-9]+\+xml")
-from pyRdfa.utils import URIOpener
+from ..utils import URIOpener
#===========================================================================================
if PY3 :
View
24 pyRdfa/rdfs/process.py
@@ -31,22 +31,22 @@
ns_owl = Namespace("http://www.w3.org/2002/07/owl#")
-from pyRdfa.host import MediaTypes
+from ..host import MediaTypes
-from pyRdfa.utils import URIOpener
+from ..utils import URIOpener
-from pyRdfa.rdfs import err_outdated_cache
-from pyRdfa.rdfs import err_unreachable_vocab
-from pyRdfa.rdfs import err_unparsable_Turtle_vocab
-from pyRdfa.rdfs import err_unparsable_xml_vocab
-from pyRdfa.rdfs import err_unparsable_ntriples_vocab
-from pyRdfa.rdfs import err_unparsable_rdfa_vocab
-from pyRdfa.rdfs import err_unrecognised_vocab_type
+from . import err_outdated_cache
+from . import err_unreachable_vocab
+from . import err_unparsable_Turtle_vocab
+from . import err_unparsable_xml_vocab
+from . import err_unparsable_ntriples_vocab
+from . import err_unparsable_rdfa_vocab
+from . import err_unrecognised_vocab_type
-from pyRdfa import VocabReferenceError
+from .. import VocabReferenceError
-from pyRdfa.rdfs.cache import CachedVocab
-from pyRdfa import HTTPError, RDFaError
+from .cache import CachedVocab
+from .. import HTTPError, RDFaError
#############################################################################################################
View
34 pyRdfa/state.py
@@ -35,20 +35,20 @@
from rdflib.RDFS import RDFSNS as ns_rdfs
from rdflib.RDF import RDFNS as ns_rdf
-from pyRdfa.options import Options
-from pyRdfa.utils import quote_URI
-from pyRdfa.host import HostLanguage, accept_xml_base, accept_xml_lang, beautifying_prefixes
+from .options import Options
+from .utils import quote_URI
+from .host import HostLanguage, accept_xml_base, accept_xml_lang, beautifying_prefixes
-from pyRdfa.termorcurie import TermOrCurie
-from pyRdfa import UnresolvablePrefix, UnresolvableTerm
+from .termorcurie import TermOrCurie
+from . import UnresolvablePrefix, UnresolvableTerm
-from pyRdfa import err_lang
-from pyRdfa import err_URI_scheme
-from pyRdfa import err_illegal_safe_CURIE
-from pyRdfa import err_no_CURIE_in_safe_CURIE
-from pyRdfa import err_undefined_terms
-from pyRdfa import err_non_legal_CURIE_ref
-from pyRdfa import err_undefined_CURIE
+from . import err_lang
+from . import err_URI_scheme
+from . import err_illegal_safe_CURIE
+from . import err_no_CURIE_in_safe_CURIE
+from . import err_undefined_terms
+from . import err_non_legal_CURIE_ref
+from . import err_undefined_CURIE
import re
import random
@@ -167,7 +167,7 @@ def remove_frag_id(uri) :
if rdfa_version is not None :
self.rdfa_version = rdfa_version
else :
- from pyRdfa import rdfa_current_version
+ from . import rdfa_current_version
self.rdfa_version = rdfa_current_version
# This value can be overwritten by a @version attribute
@@ -180,7 +180,7 @@ def remove_frag_id(uri) :
# this is just to play safe. I believe this should actually not happen...
if options == None :
- from pyRdfa import Options
+ from . import Options
self.options = Options()
else :
self.options = options
@@ -285,7 +285,7 @@ def create_URIRef(uri, check = True) :
@param uri: (absolute) URI string
@return: an RDFLib URIRef instance
"""
- from pyRdfa import uri_schemes
+ from . import uri_schemes
val = uri.strip()
if check and urlsplit(val)[0] not in uri_schemes :
self.options.add_warning(err_URI_scheme % val.strip(), node=self.node.nodeName)
@@ -397,12 +397,12 @@ def _TERMorCURIEorAbsURI(self, val) :
@type val: string
@return: an RDFLib URIRef instance or None
"""
- from pyRdfa import uri_schemes
+ from . import uri_schemes
# This case excludes the pure base, ie, the empty value
if val == "" :
return None
- from pyRdfa.termorcurie import ncname, termname
+ from .termorcurie import ncname, termname
if termname.match(val) :
# This is a term, must be handled as such...
retval = self.term_or_curie.term_to_URI(val)
View
44 pyRdfa/termorcurie.py
@@ -47,24 +47,24 @@
from rdflib.RDFS import RDFSNS as ns_rdfs
from rdflib.RDF import RDFNS as ns_rdf
-from pyRdfa.options import Options
-from pyRdfa.utils import quote_URI, URIOpener
-from pyRdfa.host import MediaTypes, HostLanguage, predefined_1_0_rel, warn_xmlns_usage
-from pyRdfa import IncorrectPrefixDefinition, RDFA_VOCAB, UnresolvableReference
-from pyRdfa import ns_rdfa
-
-from pyRdfa import err_redefining_URI_as_prefix
-from pyRdfa import err_xmlns_deprecated
-from pyRdfa import err_bnode_local_prefix
-from pyRdfa import err_col_local_prefix
-from pyRdfa import err_missing_URI_prefix
-from pyRdfa import err_invalid_prefix
-from pyRdfa import err_no_default_prefix
-from pyRdfa import err_prefix_and_xmlns
-from pyRdfa import err_non_ncname_prefix
-from pyRdfa import err_absolute_reference
-from pyRdfa import err_query_reference
-from pyRdfa import err_fragment_reference
+from .options import Options
+from .utils import quote_URI, URIOpener
+from .host import MediaTypes, HostLanguage, predefined_1_0_rel, warn_xmlns_usage
+from . import IncorrectPrefixDefinition, RDFA_VOCAB, UnresolvableReference
+from . import ns_rdfa
+
+from . import err_redefining_URI_as_prefix
+from . import err_xmlns_deprecated
+from . import err_bnode_local_prefix
+from . import err_col_local_prefix
+from . import err_missing_URI_prefix
+from . import err_invalid_prefix
+from . import err_no_default_prefix
+from . import err_prefix_and_xmlns
+from . import err_non_ncname_prefix
+from . import err_absolute_reference
+from . import err_query_reference
+from . import err_fragment_reference
# Regular expression object for NCNAME
ncname = re.compile("^[A-Za-z][A-Za-z0-9._-]*$")
@@ -117,9 +117,9 @@ def __init__(self, state, top_level) :
if state.rdfa_version < "1.1" or top_level == False :
return
- from pyRdfa.initialcontext import initial_context as context_data
- from pyRdfa.host import initial_contexts as context_ids
- from pyRdfa.host import default_vocabulary
+ from .initialcontext import initial_context as context_data
+ from .host import initial_contexts as context_ids
+ from .host import default_vocabulary
for id in context_ids[state.options.host_language] :
# This gives the id of a initial context, valid for this media type:
@@ -171,7 +171,7 @@ def __init__(self, state, graph, inherited_state) :
@type inherited_state: L{state.ExecutionContext}
"""
def check_prefix(pr) :
- from pyRdfa import uri_schemes
+ from . import uri_schemes
if pr in uri_schemes :
# The prefix being defined is a registered URI scheme, better avoid it...
state.options.add_warning(err_redefining_URI_as_prefix % pr, node=state.node.nodeName)
View
2  pyRdfa/transform/DublinCore.py
@@ -30,7 +30,7 @@ def DC_transform(html, options, state) :
@param state: top level execution state
@type state: L{State<pyRdfa.state>}
"""
- from pyRdfa.host import HostLanguage
+ from ..host import HostLanguage
if not( options.host_language in [ HostLanguage.xhtml, HostLanguage.html5, HostLanguage.xhtml5 ] ) :
return
View
2  pyRdfa/transform/OpenID.py
@@ -32,7 +32,7 @@ def OpenID_transform(html, options, state) :
@param state: top level execution state
@type state: L{State<pyRdfa.state>}
"""
- from pyRdfa.host import HostLanguage
+ from ..host import HostLanguage
if not( options.host_language in [ HostLanguage.xhtml, HostLanguage.html5, HostLanguage.xhtml5 ] ) :
return
View
6 pyRdfa/transform/__init__.py
@@ -35,8 +35,8 @@ def set_about(node) :
if not has_one_of_attributes(node, "href", "resource", "about", "src") :
node.setAttribute("about","")
- from pyRdfa.host import HostLanguage
- from pyRdfa.utils import has_one_of_attributes
+ from ..host import HostLanguage
+ from ..utils import has_one_of_attributes
if not has_one_of_attributes(root, "about") :
# The situation is a bit complicated: if a @resource is present without anything else, then it sets
@@ -98,7 +98,7 @@ def vocab_for_role(node, options, state) :
@param state: top level execution state
@type state: L{State<pyRdfa.state>}
"""
- from pyRdfa.termorcurie import termname, XHTML_URI
+ from ..termorcurie import termname, XHTML_URI
def handle_role(node) :
if node.hasAttribute("role") :
View
2  pyRdfa/transform/metaname.py
@@ -19,7 +19,7 @@ def meta_transform(html, options, state) :
@param state: top level execution state
@type state: L{State<pyRdfa.state>}
"""
- from pyRdfa.host import HostLanguage
+ from ..host import HostLanguage
if not( options.host_language in [ HostLanguage.xhtml, HostLanguage.html5, HostLanguage.xhtml5 ] ) :
return
View
10 pyRdfa/utils.py
@@ -31,7 +31,7 @@
from urllib import quote
from BaseHTTPServer import BaseHTTPRequestHandler
-from pyRdfa.extras.httpheader import content_type, parse_http_datetime
+from .extras.httpheader import content_type, parse_http_datetime
import rdflib
if rdflib.__version__ >= "3.0.0" :
@@ -39,7 +39,7 @@
else :
from rdflib.RDF import RDFNS as ns_rdf
-from pyRdfa.host import HostLanguage, preferred_suffixes
+from .host import HostLanguage, preferred_suffixes
from types import *
#########################################################################################################
@@ -129,12 +129,12 @@ def __init__(self, name, additional_headers = {}) :
except urllib_HTTPError :
e = sys.exc_info()[1]
- from pyRdfa import HTTPError
+ from . import HTTPError
msg = BaseHTTPRequestHandler.responses[e.code]
raise HTTPError('%s' % msg[1], e.code)
except Exception :
e = sys.exc_info()[1]
- from pyRdfa import RDFaError
+ from . import RDFaError
raise RDFaError('%s' % e)
#########################################################################################################
@@ -153,7 +153,7 @@ def quote_URI(uri, options = None) :
@param options:
@type options: L{Options<pyRdfa.Options>}
"""
- from pyRdfa import err_unusual_char_in_URI
+ from . import err_unusual_char_in_URI
suri = uri.strip()
for c in _warnChars :
if suri.find(c) != -1 :
Please sign in to comment.
Something went wrong with that request. Please try again.