Changeset 159 for table_parser
- Timestamp:
- 21/11/10 03:21:26 (18 months ago)
- File:
-
- 1 edited
-
table_parser/table_parser.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
table_parser/table_parser.py
r158 r159 55 55 return '{"href": "%s", "text": "%s"}'%(self.href, self.text) 56 56 57 class Image(object): 58 def __init__(self, src): 59 self.src = src 60 def __repr__(self): 61 return '{"src": "%s"}'%(self.src) 62 57 63 # Get the item on the top of a stack 58 64 def top(x): … … 103 109 elif lower(tag) == 'a' and self.anchors and isinstance(top(self._stack), Cell): 104 110 # add the text we already have 105 top(self._stack).append(self._buf) 111 if len(self._buf) > 0: 112 top(self._stack).append(self._buf) 106 113 self._buf = '' 107 114 self._stack.append(Anchor(attrs['href'])) 115 elif lower(tag) == 'img' and self.anchors and isinstance(top(self._stack), Cell): 116 # add the text we already have 117 if len(self._buf) > 0: 118 top(self._stack).append(self._buf) 119 self._buf = '' 120 top(self._stack).append(Image(attrs['src'])) 108 121 109 122 #print "Encountered the beginning of a %s tag" % tag … … 130 143 t = top(self._stack) 131 144 if isinstance(t, Row): 132 c.append(self._buf) 145 if len(self._buf) > 0: 146 c.append(self._buf) 133 147 t.append(c) 134 148 else:
Note: See TracChangeset
for help on using the changeset viewer.
