walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

Two tweaks from "layercake" #135

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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) :

Original issue reported on code.google.com by gjhigg...@gmail.com on 6 Aug 2010 at 3:31

Attachments:

GoogleCodeExporter commented 8 years ago
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.

Original comment by gromgull on 3 Mar 2011 at 10:49

GoogleCodeExporter commented 8 years ago
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.

Original comment by gjhigg...@gmail.com on 3 Mar 2011 at 1:53

GoogleCodeExporter commented 8 years ago
I went through layercake changes and applied good stuff a while back - closing 
this.

Original comment by gromgull on 19 Aug 2011 at 6:08