batch pretty (color) print of python code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Humpdydum

    #1

    batch pretty (color) print of python code?

    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


  • Josh Close

    #2
    Re: batch pretty (color) print of python code?

    On Mon, 27 Sep 2004 16:07:03 -0400, Humpdydum
    <oliver.schoenb orn@utoronto.ca > wrote:[color=blue]
    > 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[/color]

    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

    Comment

    • Paul McNett

      #3
      Re: batch pretty (color) print of python code?

      Humpdydum writes:
      [color=blue]
      > 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.[/color]

      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.



      --
      Paul McNett
      Independent Software Consultant

      Comment

      • John Hunter

        #4
        Re: batch pretty (color) print of python code?

        >>>>> "Humpdydum" == Humpdydum <oliver.schoenb orn@utoronto.ca > 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.



        JDH

        Comment

        • Fernando Perez

          #5
          Re: batch pretty (color) print of python code?

          Humpdydum wrote:
          [color=blue]
          > 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[/color]

          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

          Comment

          • Paul McNett

            #6
            Re: batch pretty (color) print of python code?

            Fernando Perez writes:
            [color=blue]
            > 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,...)[/color]

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

            alias codeps='enscrip t -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

            Comment

            Working...