3434pyrepl."""
3535
3636
37+ import cmd
3738
3839from pyrepl import completer
3940from pyrepl .completing_reader import CompletingReader as CR
40- import cmd
4141
4242
4343class CmdReader (CR ):
4444 def collect_keymap (self ):
4545 return super (CmdReader , self ).collect_keymap () + (
4646 ("\\ M-\\ n" , "invalid-key" ),
47- ("\\ n" , "accept" ))
47+ ("\\ n" , "accept" ),
48+ )
4849
4950 def __init__ (self , completions ):
5051 super (CmdReader , self ).__init__ ()
@@ -53,13 +54,10 @@ def __init__(self, completions):
5354 def get_completions (self , stem ):
5455 if len (stem ) != self .pos :
5556 return []
56- return sorted (set (s
57- for s in self .completions
58- if s .startswith (stem )))
57+ return sorted (set (s for s in self .completions if s .startswith (stem )))
5958
6059
6160def replize (klass , history_across_invocations = 1 ):
62-
6361 """Return a subclass of the cmd.Cmd-derived klass that uses
6462 pyrepl instead of readline.
6563
@@ -69,13 +67,13 @@ def replize(klass, history_across_invocations=1):
6967 controls whether instances of the returned class share
7068 histories."""
7169
72- completions = [s [ 3 :]
73- for s in completer .get_class_members (klass )
74- if s . startswith ( "do_" ) ]
70+ completions = [
71+ s [ 3 :] for s in completer .get_class_members (klass ) if s . startswith ( "do_" )
72+ ]
7573
7674 assert issubclass (klass , cmd .Cmd )
77- # if klass.cmdloop.im_class is not cmd.Cmd:
78- # print "this may not work"
75+ # if klass.cmdloop.im_class is not cmd.Cmd:
76+ # print "this may not work"
7977
8078 class MultiHist (object ):
8179 __history = []
@@ -118,4 +116,5 @@ def cmdloop(self, intro=None):
118116
119117 class CmdRepl (hist , CmdLoopMixin , klass ):
120118 __name__ = "replize(%s.%s)" % (klass .__module__ , klass .__name__ )
119+
121120 return CmdRepl
0 commit comments