Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: third_party/logilab/common/ureports/__init__.py

Issue 707353002: pylint: upgrade to 1.3.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 """Universal report objects and some formatting drivers. 18 """Universal report objects and some formatting drivers.
19 19
20 A way to create simple reports using python objects, primarily designed to be 20 A way to create simple reports using python objects, primarily designed to be
21 formatted as text and html. 21 formatted as text and html.
22 """ 22 """
23 from __future__ import generators
24 __docformat__ = "restructuredtext en" 23 __docformat__ = "restructuredtext en"
25 24
26 import sys 25 import sys
27 from cStringIO import StringIO
28 from StringIO import StringIO as UStringIO
29 26
27 from logilab.common.compat import StringIO
30 from logilab.common.textutils import linesep 28 from logilab.common.textutils import linesep
31 29
32 30
33 def get_nodes(node, klass): 31 def get_nodes(node, klass):
34 """return an iterator on all children node of the given klass""" 32 """return an iterator on all children node of the given klass"""
35 for child in node.children: 33 for child in node.children:
36 if isinstance(child, klass): 34 if isinstance(child, klass):
37 yield child 35 yield child
38 # recurse (FIXME: recursion controled by an option) 36 # recurse (FIXME: recursion controled by an option)
39 for grandchild in get_nodes(child, klass): 37 for grandchild in get_nodes(child, klass):
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 stream.write(data.encode(self.encoding)) 149 stream.write(data.encode(self.encoding))
152 def writeln(data=''): 150 def writeln(data=''):
153 try: 151 try:
154 stream.write(data+linesep) 152 stream.write(data+linesep)
155 except UnicodeEncodeError: 153 except UnicodeEncodeError:
156 stream.write(data.encode(self.encoding)+linesep) 154 stream.write(data.encode(self.encoding)+linesep)
157 self.write = write 155 self.write = write
158 self.writeln = writeln 156 self.writeln = writeln
159 self.__compute_funcs.append((write, writeln)) 157 self.__compute_funcs.append((write, writeln))
160 for child in layout.children: 158 for child in layout.children:
161 stream = UStringIO() 159 stream = StringIO()
162 child.accept(self) 160 child.accept(self)
163 yield stream.getvalue() 161 yield stream.getvalue()
164 self.__compute_funcs.pop() 162 self.__compute_funcs.pop()
165 try: 163 try:
166 self.write, self.writeln = self.__compute_funcs[-1] 164 self.write, self.writeln = self.__compute_funcs[-1]
167 except IndexError: 165 except IndexError:
168 del self.write 166 del self.write
169 del self.writeln 167 del self.writeln
170 168
171 169
172 from logilab.common.ureports.nodes import * 170 from logilab.common.ureports.nodes import *
173 from logilab.common.ureports.text_writer import TextWriter 171 from logilab.common.ureports.text_writer import TextWriter
174 from logilab.common.ureports.html_writer import HTMLWriter 172 from logilab.common.ureports.html_writer import HTMLWriter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698