2222from .dict_parser import DictReader
2323from .parser_utils import ParserException , RDF_CONVERSION_FORMATS
2424
25- try :
26- unicode = unicode
27- except NameError :
28- unicode = str
29-
3025ODML_NS = Format .namespace ()
3126
3227
@@ -129,7 +124,7 @@ def save_odml_values(self, parent_node, rdf_predicate, values):
129124 to the current parent node.
130125 :param values: list of odml values.
131126 """
132- seq = URIRef (ODML_NS + unicode (uuid .uuid4 ()))
127+ seq = URIRef (ODML_NS + str (uuid .uuid4 ()))
133128 self .graph .add ((seq , RDF .type , RDF .Seq ))
134129 self .graph .add ((parent_node , rdf_predicate , seq ))
135130
@@ -138,14 +133,14 @@ def save_odml_values(self, parent_node, rdf_predicate, values):
138133 # Once rdflib upgrades this should be reversed to RDF:li again!
139134 # see https://github.com/RDFLib/rdflib/issues/280
140135 # -- keep until supported
141- # bag = URIRef(ODML_NS + unicode (uuid.uuid4()))
136+ # bag = URIRef(ODML_NS + str (uuid.uuid4()))
142137 # self.graph.add((bag, RDF.type, RDF.Bag))
143138 # self.graph.add((curr_node, fmt.rdf_map(k), bag))
144139 # for curr_val in values:
145140 # self.graph.add((bag, RDF.li, Literal(curr_val)))
146141 counter = 1
147142 for curr_val in values :
148- custom_predicate = "%s_%s" % (unicode (RDF ), counter )
143+ custom_predicate = "%s_%s" % (str (RDF ), counter )
149144 self .graph .add ((seq , URIRef (custom_predicate ), Literal (curr_val )))
150145 counter = counter + 1
151146
@@ -160,7 +155,7 @@ def save_odml_list(self, parent_node, rdf_predicate, odml_list):
160155 :param odml_list: list of odml entities.
161156 """
162157 for curr_item in odml_list :
163- node = URIRef (ODML_NS + unicode (curr_item .id ))
158+ node = URIRef (ODML_NS + str (curr_item .id ))
164159 self .graph .add ((parent_node , rdf_predicate , node ))
165160
166161 fmt = curr_item .format ()
@@ -185,7 +180,7 @@ def save_repository_node(self, parent_node, rdf_predicate, leaf_value):
185180 if not terminology_node :
186181 # adding terminology url value to the graph and linking it
187182 # to the current RDF node.
188- terminology_node = URIRef (ODML_NS + unicode (uuid .uuid4 ()))
183+ terminology_node = URIRef (ODML_NS + str (uuid .uuid4 ()))
189184 self .graph .add ((terminology_node , RDF .type , URIRef (leaf_value )))
190185 self .graph .add ((self .hub_root , ODML_NS .hasTerminology , terminology_node ))
191186
@@ -203,7 +198,7 @@ def save_document(self, doc, curr_node=None):
203198 fmt = doc .format ()
204199
205200 if not curr_node :
206- curr_node = URIRef (ODML_NS + unicode (doc .id ))
201+ curr_node = URIRef (ODML_NS + str (doc .id ))
207202
208203 self .graph .add ((curr_node , RDF .type , URIRef (fmt .rdf_type )))
209204 self .graph .add ((self .hub_root , ODML_NS .hasDocument , curr_node ))
@@ -478,7 +473,7 @@ def parse_document(self, doc_uri):
478473 elif attr [0 ] == "id" :
479474 doc_attrs [attr [0 ]] = doc_uri .split ("#" , 1 )[1 ]
480475 elif elems :
481- doc_attrs [attr [0 ]] = unicode (elems [0 ].toPython ())
476+ doc_attrs [attr [0 ]] = str (elems [0 ].toPython ())
482477
483478 return {'Document' : doc_attrs , 'odml-version' : FORMAT_VERSION }
484479
@@ -503,7 +498,7 @@ def parse_section(self, sec_uri):
503498 elif attr [0 ] == "id" :
504499 sec_attrs [attr [0 ]] = sec_uri .split ("#" , 1 )[1 ]
505500 elif elems :
506- sec_attrs [attr [0 ]] = unicode (elems [0 ].toPython ())
501+ sec_attrs [attr [0 ]] = str (elems [0 ].toPython ())
507502
508503 self ._check_mandatory_attrs (sec_attrs )
509504 return sec_attrs
@@ -537,7 +532,7 @@ def parse_property(self, prop_uri):
537532 elif attr [0 ] == "id" :
538533 prop_attrs [attr [0 ]] = prop_uri .split ("#" , 1 )[1 ]
539534 elif elems :
540- prop_attrs [attr [0 ]] = unicode (elems [0 ].toPython ())
535+ prop_attrs [attr [0 ]] = str (elems [0 ].toPython ())
541536
542537 self ._check_mandatory_attrs (prop_attrs )
543538 return prop_attrs
0 commit comments