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

Side by Side Diff: third_party/logilab/common/cli.py

Issue 739393004: Revert "Revert "pylint: upgrade to 1.3.1"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 6 years 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
« no previous file with comments | « third_party/logilab/common/clcommands.py ('k') | third_party/logilab/common/compat.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #
(...skipping 26 matching lines...) Expand all
37 37
38 help_do_ronfle = ("ronfle", "ronfle volume", _("met les autres en veille ")) 38 help_do_ronfle = ("ronfle", "ronfle volume", _("met les autres en veille "))
39 def do_ronfle(self): 39 def do_ronfle(self):
40 print 'fuuuuuuuuuuuu rhhhhhrhrhrrh' 40 print 'fuuuuuuuuuuuu rhhhhhrhrhrrh'
41 41
42 cl = BookShell() 42 cl = BookShell()
43 """ 43 """
44 44
45 __docformat__ = "restructuredtext en" 45 __docformat__ = "restructuredtext en"
46 46
47 from logilab.common.compat import raw_input, builtins 47 from six.moves import builtins, input
48
48 if not hasattr(builtins, '_'): 49 if not hasattr(builtins, '_'):
49 builtins._ = str 50 builtins._ = str
50 51
51 52
52 def init_readline(complete_method, histfile=None): 53 def init_readline(complete_method, histfile=None):
53 """Init the readline library if available.""" 54 """Init the readline library if available."""
54 try: 55 try:
55 import readline 56 import readline
56 readline.parse_and_bind("tab: complete") 57 readline.parse_and_bind("tab: complete")
57 readline.set_completer(complete_method) 58 readline.set_completer(complete_method)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 def __init__(self, histfile=None) : 101 def __init__(self, histfile=None) :
101 self._topics = {} 102 self._topics = {}
102 self.commands = None 103 self.commands = None
103 self._completer = Completer(self._register_commands()) 104 self._completer = Completer(self._register_commands())
104 init_readline(self._completer.complete, histfile) 105 init_readline(self._completer.complete, histfile)
105 106
106 def run(self): 107 def run(self):
107 """loop on user input, exit on EOF""" 108 """loop on user input, exit on EOF"""
108 while True: 109 while True:
109 try: 110 try:
110 line = raw_input('>>> ') 111 line = input('>>> ')
111 except EOFError: 112 except EOFError:
112 print 113 print
113 break 114 break
114 s_line = line.strip() 115 s_line = line.strip()
115 if not s_line: 116 if not s_line:
116 continue 117 continue
117 args = s_line.split() 118 args = s_line.split()
118 if args[0] in self.commands: 119 if args[0] in self.commands:
119 try: 120 try:
120 cmd = 'do_%s' % self.commands[args[0]] 121 cmd = 'do_%s' % self.commands[args[0]]
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 for command_help_method in self._topics[command]: 188 for command_help_method in self._topics[command]:
188 try: 189 try:
189 if callable(command_help_method): 190 if callable(command_help_method):
190 self._print_help(*command_help_method()) 191 self._print_help(*command_help_method())
191 else: 192 else:
192 self._print_help(*command_help_method) 193 self._print_help(*command_help_method)
193 except: 194 except:
194 import traceback 195 import traceback
195 traceback.print_exc() 196 traceback.print_exc()
196 print 'ERROR in help method %s'% ( 197 print 'ERROR in help method %s'% (
197 command_help_method.func_name) 198 command_help_method.__name__)
198 199
199 help_do_help = ("help", "help [topic|command]", 200 help_do_help = ("help", "help [topic|command]",
200 _("print help message for the given topic/command or \ 201 _("print help message for the given topic/command or \
201 available topics when no argument")) 202 available topics when no argument"))
202 203
203 def do_quit(self): 204 def do_quit(self):
204 """quit the CLI""" 205 """quit the CLI"""
205 raise EOFError() 206 raise EOFError()
206 207
207 def help_do_quit(self): 208 def help_do_quit(self):
208 return ("quit", "quit", _("quit the application")) 209 return ("quit", "quit", _("quit the application"))
OLDNEW
« no previous file with comments | « third_party/logilab/common/clcommands.py ('k') | third_party/logilab/common/compat.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698