%%
%% This is file `py2tex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% py2tex.doc 
%% 
%% The py2tex documentstyle option can be used to typeset files
%% generated by the py2tex script.  Directions on the usage of the
%% script and the documentstyle option can be found in py2tex.py.
%% Documentation on the implementation and customization of this
%% documentstyle can be found in py2tex.doc.
%% 
%% If you would like to change the definition of one or more macros in
%% this section, you are advised to make a new style file along the
%% following lines, rather than change this file.
%% 
%%   % mypy.sty
%%   \input{py2tex.sty}
%%   <new definitions>
%%   % EOF
%% 
%% Such a derived style file can be used as a document style option
%% instead of py2tex.

\def\fileversion{v3.4}
\def\filedate{2006/03/29}
\def\docdate{2006/03/29}

\@ifundefined{ProvidesPackage}{}%
  {\ProvidesPackage{py2tex}}


\let\PythonSection=\section
\def\PythonFile#1#2{\PythonSection[\upcasechar#1]%
  {\upcasechar#1\thinspace--\thinspace#2}\bigskip}
\def\upcasechar#1{\uppercase{#1}}

\def\PythonEmptyLines#1{\PythonPageBreak
  \vskip\baselineskip }
\def\PythonNumber#1{\llap{\rm\small #1\ }}

\def\PythonCalcIndent{%
  \setbox0=\hbox{$\K{def}\ $}\PythonDent=\wd0
  \advance\PythonDent by .8 pt }

\ifx\selectfont\undefined
  \let\PythonFont=\relax
  \let\PythonSlFont=\sl
  \let\PythonBfFont=\bf
\else
  \message{NFSS font settings}
  \let\PythonFont=\sffamily
  \def\PythonSlFont{\PythonFont\slshape}
  \def\PythonBfFont{\PythonFont\bfseries}
\fi
\def\PythonSlantedFunctions{%
  \def\PythonFunction##1{\mbox{\PythonSlFont ##1\/}}%
  \def\PythonVariable##1{\mbox{\PythonFont ##1}}}
\def\PythonSlantedVariables{%
  \def\PythonFunction##1{\mbox{\PythonFont ##1}}%
  \def\PythonVariable##1{\mbox{\PythonSlFont ##1\/}}}
\PythonSlantedFunctions
\def\PythonKeyword#1{\mbox{\PythonBfFont #1}}%
\def\PythonOperator#1{\mathrel{\PythonKeyword{#1}}}
\def\PythonSymbol#1{#1}
\def\PythonHexadecimal#1{\mbox{\tt 0x#1}}
\def\PythonOctal#1{\mbox{\it 0#1\/}}
\def\PythonExponentFloat#1#2#3{#1{\cdot}10^{#2}{\mathrm\relax #3}}
\def\PythonPlainNumber#1#2{#1{\mathrm\relax#2}}
\def\PythonBreakPoint{\penalty 100\relax }


\newdimen\PythonDent \PythonDent=2em
\newif\ifOuterPython

\def\PythonSource{%
  \@ifstar
    {\OuterPythonfalse\@PythonSource}%
    {\OuterPythontrue\@PythonSource}}

\def\@PythonSource#1{\begingroup
  \PythonMode
  \let\B=  \PythonBlockComment
  \let\BP= \PythonBreakPoint
  \let\DS= \PythonDocString
  \let\E=  \PythonEmptyLines
  \let\ESC=\par
  \let\EXP=\PythonExponentFloat
  \let\F=  \Python@function
  \let\HEX=\PythonHexadecimal
  \let\I=  \PythonIndent
  \let\K=  \Python@keyword
  \let\M=  \PythonMetaVariable
  \let\NUM=\PythonPlainNumber
  \let\O=  \Python@operator
  \let\OCT=\PythonOctal
  \let\PB= \PythonPageBreak
  \let\S=  \PythonString
  \let\V=  \Python@variable
  \let\Y=  \Python@symbol
  \ifOuterPython
    \let\File=\PythonFile
    \let\PythonNr=\PythonNumber
  \else
    \let\File\@gobbletwo
    \let\PythonNr\@gobble
  \fi
  \PythonCalcIndent
  \input #1
  \par\endgroup}

\def\PythonMode{
  \par
  \parskip=0mm plus 1 pt
  \parindent=0mm
  \rightskip=0mm plus .5\hsize
  \interlinepenalty=300 }

\def\PythonIndent#1#2{\endgraf\penalty 500
  \hangindent=#2\PythonDent
  \advance\hangindent by 1.5\PythonDent
  \hangafter=1
  \leavevmode\strut\PythonNr{#1}%
  \hskip #2\PythonDent\relax }

\def\PythonOuterBlock{\TextMode
  \@ifstar{}{\@start@outer@block}}
\def\@start@outer@block{%
  \par\OuterMarker\nobreak\vskip -\parskip}
\def\PythonOuterBlockEnd{%
  \par\nobreak\OuterMarker\PythonMode}

\def\PythonBlockComment#1#2{\PythonPageBreak
  \PythonIndent{#1}{#2}%
  \def\subtract{-#2\PythonDent}\PythonInnerBlock}

\def\PythonInnerBlock#{\hbox\bgroup\strut \Marker
  \vtop\bgroup
    \TextMode
    \let\ESC=\PythonEscapeBlockComment
    \advance\hsize by \subtract
    \setbox0=\hbox{\Marker}\advance\hsize by -\wd0
    \textwidth=\hsize
    \linewidth=\hsize
    \aftergroup\egroup
    \let\next=}

\def\PythonDocBlock{\TextMode
  \@ifstar{}{\@start@doc@block}}
\def\@start@doc@block{%
  \par\DocOuterMarker\nobreak\vskip -\parskip}

\def\PythonDocBlockEnd{%
  \par\nobreak\DocOuterMarker\PythonMode}


\def\PythonDocString#1#2{\PythonPageBreak
  \PythonIndent{#1}{#2}%
  \def\subtract{-#2\PythonDent}\PythonDocStringHelper}

\def\PythonDocStringHelper#{\hbox\bgroup\strut \DocStringMarker
  \vtop\bgroup
    \TextMode
    \advance
    \hsize by \subtract
    \setbox0=\hbox{\DocStringMarker}\advance\hsize by -\wd0
    \textwidth=\hsize
    \linewidth=\hsize
    \aftergroup\egroup
    \let\next=}

\def\TextMode{\par
  \rightskip=0mm%
  \parskip=\baselineskip
  \advance\parskip by 0mm plus 1pt
  \interlinepenalty=0}

\def\PythonEscapeBlockComment{\par
    \vskip.5\baselineskip\vskip.5\MarkerSep
  \egroup\par\nobreak
  \bgroup
    \vskip-.5\baselineskip\vskip-.5\MarkerSep
    \EscapeMarker\nobreak
    \TextMode
    \bgroup
      \vskip -\parskip
      \aftergroup\EndEscape}
\def\EndEscape{\par\nobreak\EscapeMarker\egroup}

\newdimen\MarkerSep \MarkerSep=2pt

\def\Marker{\vrule\hskip\MarkerSep\vrule\ }

\def\DocStringMarker{\vrule width\MarkerSep\ }

\def\OuterMarker{\par\nointerlineskip
  \vbox to \baselineskip{\vss
    \hrule width\textwidth \vskip\MarkerSep
    \hrule width\textwidth \vss}%
  \nointerlineskip}
\let\EscapeMarker=\OuterMarker

\def\DocOuterMarker{\par\nointerlineskip
  \vbox to \baselineskip{\vss
    \hrule height\MarkerSep width\textwidth \vss}%
  \nointerlineskip}

\def\PythonPageBreak{\par
  \vskip 0mm plus  4\baselineskip \penalty -200
  \vskip 0mm plus -4\baselineskip \relax }

\input{ts1enc.def}
\input{t1enc.def}
\DeclareTextSymbolDefault{\textquoteright}{T1}
\DeclareTextSymbolDefault{\textquotedbl}{T1}
{\catcode`\'=\active
  \catcode`\"=\active
  \gdef\PythonString#{\bgroup\tt
    \catcode`\'=\active\def'{\textquoteright}%
    \catcode`\"=\active\def"{\textquotedbl}%
    \let\next= }}

\def\prefix@user{ExcUser@}
\def\prefix@intern{ExcIntern@}
\def\Python@def#1{\endgroup\expandafter\def
    \csname \@prefix #1\endcsname ##1##2##3}
\def\PythonDef{\let\@prefix=\prefix@user
  \@prepare\Python@def}
\def\PythonDefIntern{\let\@prefix=\prefix@intern
  \@prepare\Python@def}
\def\Python@let#1{\endgroup
  \expandafter\let\csname \@prefix #1\endcsname }
\def\PythonLet{\let\@prefix=\prefix@user
  \@prepare\Python@let}
\def\PythonLetIntern{\let\@prefix=\prefix@intern
  \@prepare\Python@let}
\def\PythonDefault#1{\PythonLet{#1}\relax}
\def\PythonDefaultIntern#1{\PythonLetIntern{#1}\relax}

\def\Python@function{\Python@identifier
  UF\PythonFunction}
\def\Python@variable{\Python@identifier
  UV\PythonVariable}
\def\Python@symbol{\@prepare\Python@identifier
  IY\PythonSymbol}
\def\Python@keyword{\Python@identifier
  IK\PythonKeyword}
\def\Python@operator{\Python@identifier
  IO\PythonOperator}
\chardef\other=12
\def\@prepare{\begingroup
  \def\do##1{\catcode`##1=\other}\dospecials
  \catcode`\{=1 \catcode`\}=2 }
{\catcode`\_=\other \gdef\@underscore{_}}
\def\global@let@tempa#1{\global\let\@tempa#1}
\def\Python@identifier#1#2#3#4{%
  \if #2Y\relax \endgroup \fi
  \begingroup\let\_=\@underscore \relax
    \if #1U\relax \let\@prefix=\prefix@user
    \else \let\@prefix=\prefix@intern \fi
    \@ifundefined{\@prefix #4}{%
        \global\let\@tempa=\@gobble
      }{\expandafter\global@let@tempa
          \csname \@prefix #4\endcsname
      }\endgroup\let\@tempb=\@tempa
      \@tempb{#2}#3{#4}}

\PythonDefIntern{[]}{[\,]}
\PythonDefIntern{&}{\mathbin\&}
\PythonDefIntern{|}{\mathbin\vert}
\PythonDefIntern{^}{\mathbin{{}^\wedge}}
\PythonDefIntern{~}{\mathop{{}^\sim}}
\PythonDefIntern{%}{\mathbin{\%}}
\PythonDefIntern{:}{\colon}

\def\PythonToAssign{%
  \PythonDefIntern{=}{\leftarrow}%
  \PythonDefIntern{==}{=}}
\def\PythonIsAssign{%
  \PythonDefaultIntern{=}%
  \PythonDefIntern{==}{\mathrel{==}}}

\def\PythonMath{%
  \PythonToAssign
  \PythonDefIntern{and}{\land}%
  \PythonDefIntern{in}{\in}%
  \PythonDefIntern{is}{\equiv}%
  \PythonDefIntern{is not}{\not\equiv}%
  \PythonDefIntern{not}{\neg}%
  \PythonDefIntern{not in}{\not\in}%
  \PythonDefIntern{or}{\lor}%
  \PythonDefIntern{<=}{\le}%
  \PythonDefIntern{>=}{\ge}%
  \PythonDefIntern{!=}{\ne}%
  \PythonDefIntern{<>}{\ne}%
  \PythonDefIntern{<<}{\ll}%
  \PythonDefIntern{>>}{\gg}}
\def\PythonNoMath{%
  \PythonIsAssign
  \PythonDefaultIntern{and}%
  \PythonDefaultIntern{in}%
  \PythonDefaultIntern{is}%
  \PythonDefaultIntern{is not}%
  \PythonDefIntern{not}{{##2{##3}}\mathbin{}}%
  \PythonDefaultIntern{not in}%
  \PythonDefaultIntern{or}%
  \PythonDefIntern{<=}{\mathrel{<=}}%
  \PythonDefIntern{>=}{\mathrel{>=}}%
  \PythonDefIntern{!=}{\mathrel{!\!=}}%
  \PythonDefIntern{<>}{\mathrel{<>}}%
  \PythonDefIntern{<<}{\mathrel{<\!<}}%
  \PythonDefIntern{>>}{\mathrel{>\!>}}}
\PythonMath

\def\Ident@Base#1\_#2.{#1}
\def\Ident@Sub#1\_#2.{#2}
\def\PythonSubscript#1#2#3{%
  #2{\Ident@Base#3.}_{\Ident@Sub#3.}}
\def\PythonSubscriptV#1#2#3{%
  \Ident@Base#3._{\Ident@Sub#3.}}
\endinput
%%
%% End of file `py2tex.sty'.
