RDFLib/rdflib — Issue #126: Two tweaks from "layercake"
Author: gjhiggins
Created: 2012-02-20 08:33:20+00:00
State: open

gjhigg...@gmail.com, 2010-08-06T03:31:41.000Z

Two small changes to rdflib.term by Chimezie made to his 2.4.X "layercake-python" setup:

http://groups.google.com/group/fuxi-discussion/msg/d9f3be240efb81ab

They don't appear to have been propagated to the rdflib main branch, so I'll simply post the diff for immediacy of inspection (with an attached diff for convenience) :

Index: /opt/rdflib-svn/rdflib/term.py
============================================
--- /opt/rdflib-svn/rdflib/term.py	(revision 1890)
+++ /opt/rdflib-svn/rdflib/term.py	(working copy)
@@ -129,6 +129,8 @@
def __eq__(self, other):
if isinstance(other, URIRef):
return unicode(self)==unicode(other)
+ elif isinstance(other,basestring):
+ return unicode(self)==other
else:
return False

@@ -719,7 +721,10 @@
return strptime(v, "%H:%M:%S")

def _strToDate(v) :
- tstr = strptime(v, "%Y-%m-%d")
+ try:
+ tstr = strptime(v,"%Y-%m-%d")
+ except:
+ tstr = strptime(v,"%Y-%m-%dZ")
return date(tstr.tm_year, tstr.tm_mon, tstr.tm_mday)

def _strToDateTime(v) :

Comment 1 by gromgull
I do not think this patch is correct - applying it introduces several test failures.
In particular, once applied rdflib.URIRef("urn:a") == rdflib.Literal("urn:a") and this should not be the case.

Comment 2 by gjhigg...@gmail.com
I posted the patch as a possible convenience for repos maintainers- it was just a diff that dropped out of my explorations of the details of the layercake/rdflib3 split.

I've also not helped matters by conflating two small changes, one to term.__eq__() and another to term._strToDate().

You're clearly correct that the patch to __eq__() should be discarded.

I suspect that the patch to _strToDate can also be safely discarded, it makes no difference to the test results whether the patch is applied or not.

Comment 3 by gromgull
I went through layercake changes and applied good stuff a while back - closing this.