Filtering through an external process

From: Paul Rubin (//phr.cx_at_NOSPAM.invalid)
Date: 11/29/03

  • Next message: Logan: "Re: ActiveState Python won't call module function."
    Date: 29 Nov 2003 12:30:39 -0800
    
    

    Anyone know if there's code around to filter text through an external
    process? Sort of like the Emacs "filter-region" command. For
    example, say I have a program that reads input in English and outputs
    it in Pig Latin. I want my Python script to call the program, pipe
    some input into it and read the output:

         english = "hello world"
         pig_latin = ext_filter("pig_latin", english)

    should set pig_latin to "ellohay orldway".

    Note that you can't just call popen2, jam the english through it and
    then read the pig latin, because the subprocess can block if you give
    it too much input before reading the output, and in general there's no
    way to know how much buffering the subprocess is willing to do. So a
    proper solution has to use asynchronous i/o and keep polling the
    output side, or else separate threads for reading and writing.

    This is something that really belongs in the standard library. I've
    needed it several times and rather than going to the trouble of coding
    and debugging it, I've always ended up using a temp file instead,
    which is a kludge.


  • Next message: Logan: "Re: ActiveState Python won't call module function."

    Relevant Pages

    • Re: One value from previous record
      ... Additionally, if there can be only 1 reading per date, you can enforce this by setting the Indexed property of the field capturing the Date to YES. ... Filter One Influent Gallons, Filter One Influent MGD, same for Filter two, then Pump 1 Run Hours, Pump 1 hours by previous ... What I need to do is take the filter influent gallons number from today subtract that from yesterdays filter one gallons and then divide by 1,000,000. ... I want it to populate the next field (Filter One Influent MGD) with that calculation. ...
      (microsoft.public.access.modulesdaovba)
    • Re: Effective kill list for this group?
      ... My posting of a kill list wasn't ... After reading my response I realise it was a bit reactionary, ... worthless rehashing of past flame wars. ... Thunderbird needs to be able to filter by ...
      (rec.audio.tubes)
    • Re: Algae problem
      ... Yeah it got cloudy after the lights were off for awhile and it cleared up ... My filter by the way is an Eheim 2028. ... I did refill the cannister with aquarium water and I ... Elaine or yourself are most helpful and from reading the newsgroups ...
      (rec.aquaria.freshwater.plants)
    • Re: nudge me in right direction
      ... In your reading, look up the Emperor 400 filter. ... 100+ gallon tank with all his corals, ... water quality, coral and fish health, the Emperor 400 is awesome. ...
      (rec.aquaria.marine.reefs)
    • Re: Problem with Image Masking - ioerror on large images
      ... reading up on these, I'd like to use one for both the mask and image. ... The problem is that when I try to use it for the data source, ... The offending command is "filter", ...
      (comp.lang.postscript)