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 | |
22 __docformat__ = "restructuredtext en" | 19 __docformat__ = "restructuredtext en" |
23 | 20 |
24 from six.moves import range | |
25 | |
26 from logilab.common.textutils import linesep | 21 from logilab.common.textutils import linesep |
27 from logilab.common.ureports import BaseWriter | 22 from logilab.common.ureports import BaseWriter |
28 | 23 |
29 | 24 |
30 TITLE_UNDERLINES = ['', '=', '-', '`', '.', '~', '^'] | 25 TITLE_UNDERLINES = ['', '=', '-', '`', '.', '~', '^'] |
31 BULLETS = ['*', '-'] | 26 BULLETS = ['*', '-'] |
32 | 27 |
33 class TextWriter(BaseWriter): | 28 class TextWriter(BaseWriter): |
34 """format layouts as text | 29 """format layouts as text |
35 (ReStructured inspiration but not totally handled yet) | 30 (ReStructured inspiration but not totally handled yet) |
(...skipping 16 matching lines...) Expand all Loading... |
52 self.pending_urls = [] | 47 self.pending_urls = [] |
53 self.section -= 1 | 48 self.section -= 1 |
54 self.writeln() | 49 self.writeln() |
55 | 50 |
56 def visit_title(self, layout): | 51 def visit_title(self, layout): |
57 title = ''.join(list(self.compute_content(layout))) | 52 title = ''.join(list(self.compute_content(layout))) |
58 self.writeln(title) | 53 self.writeln(title) |
59 try: | 54 try: |
60 self.writeln(TITLE_UNDERLINES[self.section] * len(title)) | 55 self.writeln(TITLE_UNDERLINES[self.section] * len(title)) |
61 except IndexError: | 56 except IndexError: |
62 print("FIXME TITLE TOO DEEP. TURNING TITLE INTO TEXT") | 57 print "FIXME TITLE TOO DEEP. TURNING TITLE INTO TEXT" |
63 | 58 |
64 def visit_paragraph(self, layout): | 59 def visit_paragraph(self, layout): |
65 """enter a paragraph""" | 60 """enter a paragraph""" |
66 self.format_children(layout) | 61 self.format_children(layout) |
67 self.writeln() | 62 self.writeln() |
68 | 63 |
69 def visit_span(self, layout): | 64 def visit_span(self, layout): |
70 """enter a span""" | 65 """enter a span""" |
71 self.format_children(layout) | 66 self.format_children(layout) |
72 | 67 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 """display a verbatim layout as text (so difficult ;) | 131 """display a verbatim layout as text (so difficult ;) |
137 """ | 132 """ |
138 self.writeln('::\n') | 133 self.writeln('::\n') |
139 for line in layout.data.splitlines(): | 134 for line in layout.data.splitlines(): |
140 self.writeln(' ' + line) | 135 self.writeln(' ' + line) |
141 self.writeln() | 136 self.writeln() |
142 | 137 |
143 def visit_text(self, layout): | 138 def visit_text(self, layout): |
144 """add some text""" | 139 """add some text""" |
145 self.write(layout.data) | 140 self.write(layout.data) |
OLD | NEW |