Roberto Alsina | 3 Feb 2004 01:15
Picon
Favicon
Gravatar

How to get progress information?


Hello,

I am writing an application that uses docutils to format information, and
the process may take a while for very long pieces of data.

Since this is a graphical application, I would like to provide my users
with a progress bar showing how far it's gone and how much is left.

What would be the right way to hook this into docutils?

Thanks in advance,

PS: if you want to know about the app, it's called Notty, the code is at
http://sf.net/projects/notty in CVS, and there is a screenshot at
http://pycs.net/lateral/pictures

--

-- 
 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina <at> kde.org
 (_Y_.)' ._   ) `._`.  " -.-'   KDE Developer (MFCH)
  _..`-'_..-_/ /-'_.'
(l)-'' ((i).' ((!.'             Buenos Aires - Argentina
Imminentizing the eschaton since 1971.

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
(Continue reading)

Felix Wiemann | 8 Feb 2004 02:03
Picon

Re: How to get progress information?

Roberto Alsina wrote:

> I am writing an application that uses docutils to format information,
> and the process may take a while for very long pieces of data.
> 
> Since this is a graphical application, I would like to provide my
> users with a progress bar showing how far it's gone and how much is
> left.

readers/__init__.py says:

| self.input = self.source.read()

I do not know how docutils does the parsing, but if it is done
sequentially, one could replace self.input by an object which tracks the
accesses (and calls a hook).  David, might this work?

--

-- 
http://www.ososo.de/

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
David Goodger | 8 Feb 2004 15:35
Favicon

Re: How to get progress information?

Felix Wiemann wrote:
 > readers/__init__.py says:
 >
 > | self.input = self.source.read()
 >
 > I do not know how docutils does the parsing, but if it is done
 > sequentially, one could replace self.input by an object which tracks
 > the accesses (and calls a hook).  David, might this work?

The entire input is read into memory before processing.  As I wrote in
my on-list reply to Roberto (which see),

     For the parser, there's
     docutils.statemachine.StateMachine.attach_observer etc. (observer
     pattern); observers are notified whenever the input line number
     changes.

--

-- 
David Goodger                               http://python.net/~goodger
For hire: http://python.net/~goodger/cv

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
David Goodger | 3 Feb 2004 05:31
Favicon

Re: How to get progress information?

Roberto Alsina wrote:
 > I am writing an application that uses docutils to format
 > information, and the process may take a while for very long pieces
 > of data.
 >
 > Since this is a graphical application, I would like to provide my
 > users with a progress bar showing how far it's gone and how much is
 > left.
 >
 > What would be the right way to hook this into docutils?

Hmmm, that's a tough one.  Docutils is batch-processing code; hooks
for progress feedback was never considered.  Without measuring
processing runs, I wouldn't know how to predict progress.  For the
parser, there's docutils.statemachine.StateMachine.attach_observer
etc. (observer pattern); observers are notified whenever the input
line number changes.  There's no equivalent for transforms or writers
though.

docutils.core.Publisher.publish contains the 3 main calls:

             document = self.reader.read(self.source, self.parser,
                                         self.settings)
             self.apply_transforms(document)
             output = self.writer.write(document, self.destination)

A very coarse set of hooks could be added in there.  I suppose finer
hooks could be added within the Reader, Transformer, and Writer
classes.  I'm open to suggestions!  (And patches of course.)

(Continue reading)


Gmane