~ubuntu-branches/ubuntu/trusty/pyx/trusty

« back to all changes in this revision

Viewing changes to examples/examples.py

  • Committer: Bazaar Package Importer
  • Author(s): Graham Wilson
  • Date: 2004-12-25 06:42:57 UTC
  • Revision ID: james.westby@ubuntu.com-20041225064257-31469ij5uysqq302
Tags: upstream-0.7.1
ImportĀ upstreamĀ versionĀ 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import sys; sys.path[:0]=[".."]
 
4
import os.path
 
5
import pyx
 
6
 
 
7
tex = open("examples.tex", "w")
 
8
tex.write(r"""
 
9
\documentclass[abstracton,a4paper]{scrreprt}
 
10
\areaset{17cm}{24cm}
 
11
\usepackage{pyx,graphicx,scrpage,listings,color}
 
12
\usepackage[latin1]{inputenc}
 
13
\lstloadlanguages{Python}
 
14
\lstset{language=Python,commentstyle={\itshape\lstset{columns=fullflexible}},extendedchars=true}
 
15
\begin{document}
 
16
\subject{\texttt{http://pyx.sourceforge.net/}}
 
17
\title{\PyX{} %s\\Examples}
 
18
\author{J\"org Lehmann \texttt{<joergl@users.sourceforge.net>}\and
 
19
Andr\'e Wobst \texttt{<wobsta@users.sourceforge.net>}}
 
20
\maketitle
 
21
""" % pyx.__version__)
 
22
lastdir = None
 
23
for file in sys.argv[1:]:
 
24
    dir = os.path.dirname(file)
 
25
    if dir != lastdir:
 
26
        try:
 
27
            tex.write("\\begin{abstract}\n%s\\end{abstract}\n" % open(os.path.join(dir, "README")).read().replace("__version__", pyx.__version__))
 
28
        except IOError:
 
29
            print "ignore missing README in %s" % dir
 
30
        lastdir = dir
 
31
    tex.write("\\deftripstyle{mypagestyle}{}{%s}{}{}{\\pagemark}{}\n" % file)
 
32
    tex.write("\\pagestyle{mypagestyle}{}\n")
 
33
    tex.write("\\section*{%s}\n" % file)
 
34
    tex.write("\\lstinputlisting{%s.py}\n" % file)
 
35
    tex.write("\\vspace{1cm}\n")
 
36
    tex.write("\\centerline{\\includegraphics{%s}}\n\\clearpage\n" % file)
 
37
tex.write("\\end{document}\n")
 
38