Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > batch pretty (color) print of python code?

Reply
Thread Tools

batch pretty (color) print of python code?

 
 
John Hunter
Guest
Posts: n/a
 
      09-27-2004
>>>>> "Humpdydum" == Humpdydum <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
 
Humpdydum
Guest
Posts: n/a
 
      09-27-2004
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


 
Reply With Quote
 
 
 
 
Josh Close
Guest
Posts: n/a
 
      09-27-2004
On Mon, 27 Sep 2004 16:07:03 -0400, Humpdydum
<(E-Mail Removed)> 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
 
Reply With Quote
 
Paul McNett
Guest
Posts: n/a
 
      09-27-2004
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
 
Reply With Quote
 
Fernando Perez
Guest
Posts: n/a
 
      09-27-2004
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
 
Reply With Quote
 
Paul McNett
Guest
Posts: n/a
 
      09-27-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pretty-print Python dict with unicode? kj Python 2 08-04-2010 11:28 PM
Pretty Print Python Data Structures to HTML Sam Python 2 10-17-2009 08:28 AM
Re: One more Pretty Face - Pretty face9.jpg [1/1] Harvey Digital Photography 7 11-04-2004 09:53 AM
Re: Pretty Please Peer2Peer need help Pretty Please John Haithwaite @ Blue Case Solutions Computer Support 0 07-06-2003 10:20 PM
Re: Pretty Please Peer2Peer need help Pretty Please Ralph Wade Phillips Computer Support 0 07-06-2003 09:07 PM



Advertisments