OLD | NEW |
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. | 1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # | 3 # |
4 # This file is part of logilab-common. | 4 # This file is part of logilab-common. |
5 # | 5 # |
6 # logilab-common is free software: you can redistribute it and/or modify it unde
r | 6 # logilab-common is free software: you can redistribute it and/or modify it unde
r |
7 # the terms of the GNU Lesser General Public License as published by the Free | 7 # the terms of the GNU Lesser General Public License as published by the Free |
8 # Software Foundation, either version 2.1 of the License, or (at your option) an
y | 8 # Software Foundation, either version 2.1 of the License, or (at your option) an
y |
9 # later version. | 9 # later version. |
10 # | 10 # |
11 # logilab-common is distributed in the hope that it will be useful, but WITHOUT | 11 # logilab-common is distributed in the hope that it will be useful, but WITHOUT |
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | 13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. | 14 # details. |
15 # | 15 # |
16 # You should have received a copy of the GNU Lesser General Public License along | 16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with logilab-common. If not, see <http://www.gnu.org/licenses/>. | 17 # with logilab-common. If not, see <http://www.gnu.org/licenses/>. |
18 """Text formatting drivers for ureports""" | 18 """Text formatting drivers for ureports""" |
| 19 |
| 20 from __future__ import print_function |
| 21 |
19 __docformat__ = "restructuredtext en" | 22 __docformat__ = "restructuredtext en" |
20 | 23 |
| 24 from six.moves import range |
| 25 |
21 from logilab.common.textutils import linesep | 26 from logilab.common.textutils import linesep |
22 from logilab.common.ureports import BaseWriter | 27 from logilab.common.ureports import BaseWriter |
23 | 28 |
24 | 29 |
25 TITLE_UNDERLINES = ['', '=', '-', '`', '.', '~', '^'] | 30 TITLE_UNDERLINES = ['', '=', '-', '`', '.', '~', '^'] |
26 BULLETS = ['*', '-'] | 31 BULLETS = ['*', '-'] |
27 | 32 |
28 class TextWriter(BaseWriter): | 33 class TextWriter(BaseWriter): |
29 """format layouts as text | 34 """format layouts as text |
30 (ReStructured inspiration but not totally handled yet) | 35 (ReStructured inspiration but not totally handled yet) |
(...skipping 16 matching lines...) Expand all Loading... |
47 self.pending_urls = [] | 52 self.pending_urls = [] |
48 self.section -= 1 | 53 self.section -= 1 |
49 self.writeln() | 54 self.writeln() |
50 | 55 |
51 def visit_title(self, layout): | 56 def visit_title(self, layout): |
52 title = ''.join(list(self.compute_content(layout))) | 57 title = ''.join(list(self.compute_content(layout))) |
53 self.writeln(title) | 58 self.writeln(title) |
54 try: | 59 try: |
55 self.writeln(TITLE_UNDERLINES[self.section] * len(title)) | 60 self.writeln(TITLE_UNDERLINES[self.section] * len(title)) |
56 except IndexError: | 61 except IndexError: |
57 print "FIXME TITLE TOO DEEP. TURNING TITLE INTO TEXT" | 62 print("FIXME TITLE TOO DEEP. TURNING TITLE INTO TEXT") |
58 | 63 |
59 def visit_paragraph(self, layout): | 64 def visit_paragraph(self, layout): |
60 """enter a paragraph""" | 65 """enter a paragraph""" |
61 self.format_children(layout) | 66 self.format_children(layout) |
62 self.writeln() | 67 self.writeln() |
63 | 68 |
64 def visit_span(self, layout): | 69 def visit_span(self, layout): |
65 """enter a span""" | 70 """enter a span""" |
66 self.format_children(layout) | 71 self.format_children(layout) |
67 | 72 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 """display a verbatim layout as text (so difficult ;) | 136 """display a verbatim layout as text (so difficult ;) |
132 """ | 137 """ |
133 self.writeln('::\n') | 138 self.writeln('::\n') |
134 for line in layout.data.splitlines(): | 139 for line in layout.data.splitlines(): |
135 self.writeln(' ' + line) | 140 self.writeln(' ' + line) |
136 self.writeln() | 141 self.writeln() |
137 | 142 |
138 def visit_text(self, layout): | 143 def visit_text(self, layout): |
139 """add some text""" | 144 """add some text""" |
140 self.write(layout.data) | 145 self.write(layout.data) |
OLD | NEW |