From 5f7b15814d3b997e8c534ec445559f87563ab74d Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Thu, 7 Jul 2011 16:58:29 -0700 Subject: [PATCH] Don't use xsd:string for string data types in toTypedNode I saw a reference that "foo" and "foo"^xsd:string should be treated the same, and man isn't the first version shorter to write and easier to read? --- htsworkflow/util/rdfhelp.py | 8 +++++--- htsworkflow/util/test/test_rdfhelp.py | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htsworkflow/util/rdfhelp.py b/htsworkflow/util/rdfhelp.py index faf8acb..5c73d98 100644 --- a/htsworkflow/util/rdfhelp.py +++ b/htsworkflow/util/rdfhelp.py @@ -60,13 +60,15 @@ def toTypedNode(value): elif type(value) == types.FloatType: value_type = xsdNS['float'].uri value = unicode(value) - elif type(value) in types.StringTypes: - value_type = xsdNS['string'].uri else: value_type = None value = unicode(value) - return RDF.Node(literal=value, datatype=value_type) + if value_type is not None: + node = RDF.Node(literal=value, datatype=value_type) + else: + node = RDF.Node(literal=value) + return node def fromTypedNode(node): if node is None: diff --git a/htsworkflow/util/test/test_rdfhelp.py b/htsworkflow/util/test/test_rdfhelp.py index 0364d78..1012252 100644 --- a/htsworkflow/util/test/test_rdfhelp.py +++ b/htsworkflow/util/test/test_rdfhelp.py @@ -14,8 +14,7 @@ try: def test_typed_node_string(self): node = toTypedNode('hello') self.failUnlessEqual(node.literal_value['string'], u'hello') - self.failUnlessEqual(str(node.literal_value['datatype']), - 'http://www.w3.org/2001/XMLSchema#string') + self.failUnless(node.literal_value['datatype'] is None) def test_blank_or_uri_blank(self): node = blankOrUri() -- 2.30.2