@@ -73,7 +73,7 @@ def save_element(self, e, node=None):
7373 fmt = e .format ()
7474
7575 if not node :
76- curr_node = URIRef (odmlns + str (e .id ))
76+ curr_node = URIRef (odmlns + unicode (e .id ))
7777 else :
7878 curr_node = node
7979
@@ -101,7 +101,7 @@ def save_element(self, e, node=None):
101101 self .g .add ((curr_node , fmt .rdf_map (k ), terminology_node ))
102102 else :
103103 # adding terminology to the hub and to link with the doc
104- node = URIRef (odmlns + str (uuid .uuid4 ()))
104+ node = URIRef (odmlns + unicode (uuid .uuid4 ()))
105105 self .g .add ((node , RDF .type , URIRef (terminology_url )))
106106 self .g .add ((self .hub_root , odmlns .hasTerminology , node ))
107107 self .g .add ((curr_node , fmt .rdf_map (k ), node ))
@@ -111,20 +111,20 @@ def save_element(self, e, node=None):
111111 k == 'sections' and len (getattr (e , k )) > 0 :
112112 sections = getattr (e , k )
113113 for s in sections :
114- node = URIRef (odmlns + str (s .id ))
114+ node = URIRef (odmlns + unicode (s .id ))
115115 self .g .add ((curr_node , fmt .rdf_map (k ), node ))
116116 self .save_element (s , node )
117117 elif isinstance (fmt , Section .__class__ ) and \
118118 k == 'properties' and len (getattr (e , k )) > 0 :
119119 properties = getattr (e , k )
120120 for p in properties :
121- node = URIRef (odmlns + str (p .id ))
121+ node = URIRef (odmlns + unicode (p .id ))
122122 self .g .add ((curr_node , fmt .rdf_map (k ), node ))
123123 self .save_element (p , node )
124124 elif isinstance (fmt , Property .__class__ ) and \
125125 k == 'value' and len (getattr (e , k )) > 0 :
126126 values = getattr (e , k )
127- seq = URIRef (odmlns + str (uuid .uuid4 ()))
127+ seq = URIRef (odmlns + unicode (uuid .uuid4 ()))
128128 self .g .add ((seq , RDF .type , RDF .Seq ))
129129 self .g .add ((curr_node , fmt .rdf_map (k ), seq ))
130130 # rdflib so far does not respect RDF:li item order
@@ -133,15 +133,15 @@ def save_element(self, e, node=None):
133133 # this should be reversed to RDF:li again!
134134 # see https://github.com/RDFLib/rdflib/issues/280
135135 # -- keep until supported
136- # bag = URIRef(odmlns + str (uuid.uuid4()))
136+ # bag = URIRef(odmlns + unicode (uuid.uuid4()))
137137 # self.g.add((bag, RDF.type, RDF.Bag))
138138 # self.g.add((curr_node, fmt.rdf_map(k), bag))
139139 # for v in values:
140140 # self.g.add((bag, RDF.li, Literal(v)))
141141
142142 counter = 1
143143 for v in values :
144- pred = "%s_%s" % (str (RDF ), counter )
144+ pred = "%s_%s" % (unicode (RDF ), counter )
145145 self .g .add ((seq , URIRef (pred ), Literal (v )))
146146 counter = counter + 1
147147
@@ -242,7 +242,7 @@ def parse_document(self, doc_uri):
242242 doc_attrs [attr [0 ]] = doc_uri .split ("#" , 1 )[1 ]
243243 else :
244244 if len (elems ) > 0 :
245- doc_attrs [attr [0 ]] = str (elems [0 ].toPython ())
245+ doc_attrs [attr [0 ]] = unicode (elems [0 ].toPython ())
246246
247247 return {'Document' : doc_attrs , 'odml-version' : FORMAT_VERSION }
248248
@@ -264,7 +264,7 @@ def parse_section(self, sec_uri):
264264 sec_attrs [attr [0 ]] = sec_uri .split ("#" , 1 )[1 ]
265265 else :
266266 if len (elems ) > 0 :
267- sec_attrs [attr [0 ]] = str (elems [0 ].toPython ())
267+ sec_attrs [attr [0 ]] = unicode (elems [0 ].toPython ())
268268 self ._check_mandatory_attrs (sec_attrs )
269269 return sec_attrs
270270
@@ -293,7 +293,7 @@ def parse_property(self, prop_uri):
293293 prop_attrs [attr [0 ]] = prop_uri .split ("#" , 1 )[1 ]
294294 else :
295295 if len (elems ) > 0 :
296- prop_attrs [attr [0 ]] = str (elems [0 ].toPython ())
296+ prop_attrs [attr [0 ]] = unicode (elems [0 ].toPython ())
297297 self ._check_mandatory_attrs (prop_attrs )
298298 return prop_attrs
299299
0 commit comments