batch pretty (color) print of python code?

Discussion in 'Python' started by John Hunter, Sep 27, 2004.

  1. John Hunter

    John Hunter Guest

    >>>>> "Humpdydum" == Humpdydum <> writes:

    Humpdydum> Any freeware/open-source that does that? Windows- OR
    Humpdydum> Linux-based is fine. On Linux it would be s/t like
    Humpdydum> "pyprint -r *.py > out.ps" where -r indicates
    Humpdydum> recursive. Done a search on google and nothing solid
    Humpdydum> comes up. So far I've been using Boa's print feature,
    Humpdydum> which means one file at a time, tedious. Thanks,
    Humpdydum> Oliver


    I've been very happy with the latex listings package, which supports
    python.

    http://www.atscire.de/index.php?nav=products/listings

    JDH
     
    John Hunter, Sep 27, 2004
    #1
    1. Advertising

  2. John Hunter

    Humpdydum Guest

    Any freeware/open-source that does that? Windows- OR Linux-based is fine. On
    Linux it would be s/t like "pyprint -r *.py > out.ps" where -r indicates
    recursive. Done a search on google and nothing solid comes up. So far I've
    been using Boa's print feature, which means one file at a time, tedious.
    Thanks,
    Oliver
     
    Humpdydum, Sep 27, 2004
    #2
    1. Advertising

  3. John Hunter

    Josh Close Guest

    On Mon, 27 Sep 2004 16:07:03 -0400, Humpdydum
    <> wrote:
    > Any freeware/open-source that does that? Windows- OR Linux-based is fine. On
    > Linux it would be s/t like "pyprint -r *.py > out.ps" where -r indicates
    > recursive. Done a search on google and nothing solid comes up. So far I've
    > been using Boa's print feature, which means one file at a time, tedious.
    > Thanks,
    > Oliver


    Do you want the text to be colored on the command line? Not exactly
    sure what you mean. If so, gentoo has a very nice module for that,
    that comes with portage. It's located here

    /usr/lib/portage/pym/output.py

    All it does is uses \ values for color.

    -Josh
     
    Josh Close, Sep 27, 2004
    #3
  4. John Hunter

    Paul McNett Guest

    Humpdydum writes:

    > Any freeware/open-source that does that? Windows- OR
    > Linux-based is fine. On Linux it would be s/t like "pyprint
    > -r *.py > out.ps" where -r indicates recursive. Done a search
    > on google and nothing solid comes up. So far I've been using
    > Boa's print feature, which means one file at a time, tedious.


    I believe you are looking for py2pdf.py, the most recent version
    that I can find being included in ReportLab, in the tools
    directory.

    It is very configurable, and the defaults are nice. It doesn't
    offer recursion or output redirection like you want, but you
    could probably take the code and run with it. What it will do
    out of the box is to convert your specified files to individual
    pdf files. For example:

    python py2pdf.py *.py

    results in a .pdf file for every .py file in the directory.

    http://www.reportlab.org/downloads.html

    --
    Paul McNett
    Independent Software Consultant
    http://www.paulmcnett.com
     
    Paul McNett, Sep 27, 2004
    #4
  5. Humpdydum wrote:

    > Any freeware/open-source that does that? Windows- OR Linux-based is fine. On
    > Linux it would be s/t like "pyprint -r *.py > out.ps" where -r indicates
    > recursive. Done a search on google and nothing solid comes up. So far I've
    > been using Boa's print feature, which means one file at a time, tedious.
    > Thanks,
    > Oliver


    You said linux was OK. A simple enscript alias works wonders:

    planck[python]> which codeprint
    codeprint: ein Alias fur enscript -G2rjE --color !*
    planck[python]> which codeps
    codeps: ein Alias fur enscript -G2rjE --color -o !*.ps !*; gv !*.ps

    That's what I use for all kinds of source, it does a pretty decent job with
    python (and knows about C, C++, perl,...)

    Cheers,

    f
     
    Fernando Perez, Sep 27, 2004
    #5
  6. John Hunter

    Paul McNett Guest

    Fernando Perez writes:

    > You said linux was OK. A simple enscript alias works
    > wonders:
    >
    > planck[python]> which codeprint
    > codeprint: ein Alias fur enscript -G2rjE --color !*
    > planck[python]> which codeps
    > codeps: ein Alias fur enscript -G2rjE --color -o
    > !*.ps !*; gv !*.ps
    >
    > That's what I use for all kinds of source, it does a pretty
    > decent job with python (and knows about C, C++, perl,...)


    That's great! Thanks for turning me on to that. Here is the
    alias I'm now using:

    alias codeps='enscript -G2rjE --color -o -'

    This takes input on stdin and sends the output to stdout, so the
    OP can type:

    codeps *.py > output.ps

    and that is pretty close to what the OP wanted (minus
    recursion).

    --
    Paul McNett
    Independent Software Consultant
    http://www.paulmcnett.com
     
    Paul McNett, Sep 28, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Montgomery
    Replies:
    0
    Views:
    632
    Andrew Montgomery
    Sep 17, 2003
  2. Sam
    Replies:
    2
    Views:
    952
    Diez B. Roggisch
    Oct 17, 2009
  3. kj
    Replies:
    2
    Views:
    2,506
    Vlastimil Brom
    Aug 5, 2010
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    445
    Kamaljeet Saini
    Feb 13, 2009
  5. Replies:
    2
    Views:
    156
    John W. Krahn
    Nov 27, 2006
Loading...

Share This Page