ggaughan / pipe2py

A project to compile Yahoo! Pipes into Python (see it hosted on Google App Engine: http://pipes-engine.appspot.com)
http://wiki.github.com/ggaughan/pipe2py
GNU General Public License v2.0
317 stars 51 forks source link

etree_to_pipes fails when encountering a comment node #21

Open thwarted opened 10 years ago

thwarted commented 10 years ago

pipe 11278a7cb21e7964282dfe9a46f38837

Not sure how this should be handled. The generated python code seems to at least parse and recognize HTML comments as comments, but it doesn't seem to be possible to get the yahoo pipe to do that.

repr(child) is "", and child.tag is , which doesn't have a split function. A simple change to see if child starts with the HTML comment tag opener works around this, but I'm not sure if this is a change that is compatible with the spirit of the rest of the code (should it look for the Comment function here, is there a better way to detect comments? Should they be skipped? Can the Comment function be monkeypatched to provide a split function? Is the .split call actually the best way to do whatever it's trying to do (split on "}" confuses me)?)

diff --git a/util.py b/util.py
index 6696dfd..79bdb3e 100644
--- a/util.py
+++ b/util.py
@@ -57,6 +57,8 @@ def etree_to_pipes(element):
             i['content'] = element.text

         for child in element:
+            if str(child)[0:4] == '<!--':
+                continue
             tag = child.tag.split('}', 1)[-1]

             # process child recursively and append it to parent dict
reubano commented 9 years ago

I just made a bunch of updates, can you check and see if the issue is still there?