value = value.strftime(ISOFORMAT_MS)
else:
value_type = None
- value = unicode(value)
+ if six.PY3:
+ value = str(value)
+ else:
+ value = unicode(value).encode('utf-8')
if value_type is not None:
node = RDF.Node(literal=value, datatype=value_type)
else:
- node = RDF.Node(literal=unicode(value).encode('utf-8'), language=language)
+ node = RDF.Node(literal=value, language=language)
return node
schemas = resource_listdir(__name__, 'schemas')
for s in schemas:
schema = resource_string(__name__, 'schemas/' + s)
+ if six.PY3:
+ # files must be encoded utf-8
+ schema = schema.decode('utf-8')
namespace = 'file://localhost/htsworkflow/schemas/'+s
add_schema(model, schema, namespace)
element = lxml.html.fromstring(s)
cleaner = lxml.html.clean.Cleaner(page_structure=False)
element = cleaner.clean_html(element)
- text = lxml.html.tostring(element)
+ if six.PY3:
+ text = lxml.html.tostring(element, encoding=str)
+ else:
+ text = lxml.html.tostring(element)
p_len = 3
slash_p_len = 4
import RDF
from pyld import jsonld
+import six
def load_into_model(model, json_data):
'''Given a PyLD dictionary, load its statements into our Redland model
elif nodetype == 'IRI':
return RDF.Node(uri_string=str(value))
else:
- return RDF.Node(literal=unicode(value).encode('utf-8'),
+ if six.PY2:
+ literal = unicode(value).encode('utf-8')
+ else:
+ literal = value
+ return RDF.Node(literal=literal,
datatype=RDF.Uri(datatype))