numpy questions may get answered sooner and more dependably on the numpy
mailing list.

From mike$#at^&nospam!%trauschus Tue Oct 24 00:17:00 2006
From: mike$#at^&nospam!%trauschus (Michael B. Trausch)
Date: Mon, 23 Oct 2006 18:17:00 -0400
Subject: Attempting to parse free-form ANSI text.
In-Reply-To: <mailman.928.1161507871.11739.python-list@python.org>
References: <GsGdnTIYc-lXaafYnZ2dnUVZ_sCdnZ2d@comcast.com>
Message-ID: <IJSdnapq7drDoqDYnZ2dnUVZ_sadnZ2d@comcast.com>

Frederic Rentsch wrote:
Michael B. Trausch wrote:
Alright... I am attempting to find a way to parse ANSI text from a
telnet application. However, I am experiencing a bit of trouble.
*I have no experience with reading from TCP/IP. But looking at your
program with a candid mind I'd say that it is written to process a chunk
of data in memory.
That would be correct... that's the only way that I can think of to do
it, since the chunks come in from the network to a variable.
If, as you say, the chunks you get from TCP/IP may
start and end anywhere and, presumably you pass each chunk through
AppendText, then you have a synchronization problem, as each call resets
your escape flag, even if the new chunk starts in the middle of an
escape sequence. Perhaps you should cut off incomplete escapes at the
end and prepend them to the next chunk.
The question would be -- how does one determine if it is incomplete or
not? The answer might lie in the previous response to this, where there
is another ANSI python module that works with the text. Actually, it's
possible that my entire approach is faulty -- I am, after all, a rather
newbie programmer -- and this is my first go at an application that does
something other than "Hello, world!"

if(len(buffer) > 0):
wx.TextCtrl.AppendText(self, buffer) <<< Are you sure text goes
into the same place as the controls?
What do you mean? This function is in AnsiTextCtrl (so, it is
AnsiTextCtrl.AppendText). I have derived AnsiTextCtrl from wx.TextCtrl,
so I think that if I need to call the parent's function, I would do so
directly, with 'self' being the current object, and buffer being the
text to add from the network.

When I call AppendText from an instance of a text control, (e.g.,
AnsiTextCtrl.AppendText(buffer)), I don't need to provide the object
that needs to be worked on. It seems to work okay; but I know that just
because something works okay, that doesn't mean it is right. So, am I
doing it wrong?
if(len(AnsiBuffer) >
0): wx.TextCtrl.AppendText(self, AnsiBuffer) <<<
You say you want to strip the control sequences
Yes, in the end I do. Right now, I had to see what was going on. I
figure that once I do figure out how to get it working, I can see the
color changes when the ANSI code shows up in the buffer, and they should
match up with the little chart that I have of the codes here.
Hopefully. And then I can stop printing the extra crud on here.

-- Mike

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 4 | next ›
Discussion Overview
grouppython-list @
postedOct 23, '06 at 6:01p
activeOct 24, '06 at 10:48a



site design / logo © 2022 Grokbase