pipe2py icon indicating copy to clipboard operation
pipe2py copied to clipboard

etree_to_pipes fails when encountering a comment node

Open thwarted opened this issue 12 years ago • 1 comments

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 <built-in function Comment>, 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

thwarted avatar Jul 23 '13 08:07 thwarted

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

reubano avatar Nov 09 '14 11:11 reubano