You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Thomas Haas <th...@softwired-inc.com> on 2000/04/19 00:08:56 UTC

Proposal: File translation task

Hi all

In our prject we needed to add some file processing (striping off headers and footers of text files). The current copyfile does similar things. Functionality is spread across Project and Copyfile. I feel translating or generally processing and copying files should be separated. For me copying is copying withjout ANY modifications applied.

Translate extends MatchingTask and currently supports therefor (probably) all MatchingTask properties.

The attached proposal allows the following definitions in your build.xml:
<translate src="/from/dir" dest="/to/dir">
    <include .../>
    <exclude .../>
    <strip header="HEADER-SEPARATOR" footer="FOOTER-SEPARATOR"/>
    <convertCRLF format="DOS"/>
</translate>

Note:
- This is the third implementation of CRLF conversion. This has been done, as the others can not be combined with other file translation.
- Adding token filtering is no big deal (note the current token filtering may converts your eol)
- Add your own file translation as you need it.
- the strip shown aboev only prints text between HEADER-SEPARATOR and FOOTER-SEPARATOR or end of file.


How it works:
The translation is done by objects extending FilterOutputStream. For each file to be translated, the FilterOutputStreams are chainned together. The example above results in a chain of:
StripFilterOutputStream ---> ConvertCRLFFilterOutputStream ---> FileOutputStream


Next step:
- If considered a good thing, a real patch will be provided, including the token filtering.
- strip may not be part of standard distribution


- tom



Re: Proposal: File translation task

Posted by Thomas Haas <th...@softwired-inc.com>.
----- Original Message ----- 
From: Jonathan Locke <jo...@eidolon.muppetlabs.com>
To: <an...@jakarta.apache.org>
Sent: Wednesday, April 19, 2000 1:08 AM
Subject: Re: Proposal: File translation task


> 
> need a nice posix/perl5 compatible regexp library for file processing?
> i've got one...  then you could say <processFile replace="regexp"
> with="whatever">.  it also might help with version tagging and other
> things...  just a thought.
> 
> cheers!
> 
>     jon
> 

Sorry for replying late. I would love this.
Can you do it?

- tom





Re: Proposal: File translation task

Posted by James Duncan Davidson <ja...@eng.sun.com>.
> need a nice posix/perl5 compatible regexp library for file processing?
> i've got one...  then you could say <processFile replace="regexp"
> with="whatever">.  it also might help with version tagging and other
> things...  just a thought.

Are you amenable to placing it under the ASF license? I'd love a full
regexp package that was BSD style licensed! And I know others would as
well.

.duncan

Re: Proposal: File translation task

Posted by Jonathan Locke <jo...@eidolon.muppetlabs.com>.
need a nice posix/perl5 compatible regexp library for file processing?
i've got one...  then you could say <processFile replace="regexp"
with="whatever">.  it also might help with version tagging and other
things...  just a thought.

cheers!

    jon

On Wed, 19 Apr 2000, Thomas Haas wrote:

> Hi all
> 
> In our prject we needed to add some file processing (striping off headers and footers of text files). The current copyfile does similar things. Functionality is spread across Project and Copyfile. I feel translating or generally processing and copying files should be separated. For me copying is copying withjout ANY modifications applied.
> 
> Translate extends MatchingTask and currently supports therefor (probably) all MatchingTask properties.
> 
> The attached proposal allows the following definitions in your build.xml:
> <translate src="/from/dir" dest="/to/dir">
>     <include .../>
>     <exclude .../>
>     <strip header="HEADER-SEPARATOR" footer="FOOTER-SEPARATOR"/>
>     <convertCRLF format="DOS"/>
> </translate>
> 
> Note:
> - This is the third implementation of CRLF conversion. This has been done, as the others can not be combined with other file translation.
> - Adding token filtering is no big deal (note the current token filtering may converts your eol)
> - Add your own file translation as you need it.
> - the strip shown aboev only prints text between HEADER-SEPARATOR and FOOTER-SEPARATOR or end of file.
> 
> 
> How it works:
> The translation is done by objects extending FilterOutputStream. For each file to be translated, the FilterOutputStreams are chainned together. The example above results in a chain of:
> StripFilterOutputStream ---> ConvertCRLFFilterOutputStream ---> FileOutputStream
> 
> 
> Next step:
> - If considered a good thing, a real patch will be provided, including the token filtering.
> - strip may not be part of standard distribution
> 
> 
> - tom
> 
> 
>