[Patches] [ python-Patches-558544 ] cmd.py: add instance-specific stdin/out

noreply@sourceforge.net noreply@sourceforge.net
Thu, 06 Jun 2002 00:08:55 -0700


Patches item #558544, was opened at 2002-05-21 15:45
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=558544&group_id=5470

Category: None
Group: None
Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Anthony Baxter (anthonybaxter)
Assigned to: Anthony Baxter (anthonybaxter)
Summary: cmd.py: add instance-specific stdin/out

Initial Comment:
The following patch adds stdin, stdout as optional
arguments to the cmd.Cmd constructor (defaulting to
sys.stdin, sys.stdout), and changes the Cmd methods
throughout to use self.stdout.write() and 
self.stdin.foo for output and input. This allows much
greater flexibility for using cmd - for instance, 
hooking it into a telnet server. And if the response
is YAGNI, well, actually, IAGNI, because it's in use
today (and for the last year). :)

If this is acceptable, I'll provide a documentation
patch as well.


----------------------------------------------------------------------

>Comment By: Anthony Baxter (anthonybaxter)
Date: 2002-06-06 17:08

Message:
Logged In: YES 
user_id=29957

reverse diff - oops. The str(line) repr(line) bit is because
when hooking
it into telnet, sometimes you get wierd control characters
at the start. The
str/repr is so that you can actually read the line. I'll
kill the str() bit.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-06 11:37

Message:
Logged In: YES 
user_id=6380

+1.  But before you check it in, watch out -- looks like the
patch is older than current CVS, and it is missing a number
of improvements that Raymond Hettinger checked in.

Hm, what's this?

self.stdout.write('*** Unknown syntax: %s
(%s)\n'%(str(line),repr(line)))

Why write the contents of the line twice?

It also looks like the patch is a reverse diff.

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2002-06-06 11:20

Message:
Logged In: YES 
user_id=29957

damn. here's patch

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-06-02 22:45

Message:
Logged In: YES 
user_id=21627

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=558544&group_id=5470