<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import os <EOL> import sys <EOL> import shutil <EOL> from os import path <EOL> from subprocess import call <EOL> import sphinx <EOL> from sphinx . util . console import bold , blue <EOL> from sphinx . util . osutil import cd <EOL> proj_name = os . getenv ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> BUILDERS = [ <EOL> ( "<STR_LIT>" , "<STR_LIT:html>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:text>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:info>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> class Make ( object ) : <EOL> def __init__ ( self , srcdir , builddir , opts ) : <EOL> self . srcdir = srcdir <EOL> self . builddir = builddir <EOL> self . opts = opts <EOL> def builddir_join ( self , * comps ) : <EOL> return path . join ( self . builddir , * comps ) <EOL> def build_clean ( self ) : <EOL> if not path . exists ( self . builddir ) : <EOL> return <EOL> elif not path . isdir ( self . builddir ) : <EOL> print ( "<STR_LIT>" % self . builddir ) <EOL> return <NUM_LIT:1> <EOL> print ( "<STR_LIT>" % self . builddir ) <EOL> for item in os . listdir ( self . builddir ) : <EOL> shutil . rmtree ( self . builddir_join ( item ) ) <EOL> def build_help ( self ) : <EOL> print ( bold ( "<STR_LIT>" % sphinx . __display_version__ ) ) <EOL> print ( "<STR_LIT>" % ( ( blue ( '<STR_LIT:target>' ) , ) * <NUM_LIT:2> ) ) <EOL> for osname , bname , description in BUILDERS : <EOL> if not osname or os . name == osname : <EOL> print ( '<STR_LIT>' % ( blue ( bname . ljust ( <NUM_LIT:10> ) ) , description ) ) <EOL> def build_html ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT:html>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % self . builddir_join ( '<STR_LIT:html>' ) ) <EOL> def build_dirhtml ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % <EOL> self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_singlehtml ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % <EOL> self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_pickle ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> def build_json ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' ) <EOL> def build_htmlhelp ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' % self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_qthelp ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' % self . builddir_join ( '<STR_LIT>' ) ) <EOL> print ( '<STR_LIT>' % self . builddir_join ( '<STR_LIT>' , proj_name ) ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' % <EOL> self . builddir_join ( '<STR_LIT>' , proj_name ) ) <EOL> def build_devhelp ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" + proj_name ) <EOL> print ( "<STR_LIT>" % <EOL> ( self . builddir_join ( '<STR_LIT>' ) , proj_name ) ) <EOL> print ( "<STR_LIT>" ) <EOL> def build_epub ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_latex ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( "<STR_LIT>" % self . builddir_join ( '<STR_LIT>' ) ) <EOL> if os . name == '<STR_LIT>' : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> def build_latexpdf ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> with cd ( self . builddir_join ( '<STR_LIT>' ) ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> def build_latexpdfja ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> with cd ( self . builddir_join ( '<STR_LIT>' ) ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> def build_lualatexpdf ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> with cd ( self . builddir_join ( '<STR_LIT>' ) ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> def build_xelatexpdf ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> with cd ( self . builddir_join ( '<STR_LIT>' ) ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> def build_text ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT:text>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % self . builddir_join ( '<STR_LIT:text>' ) ) <EOL> def build_texinfo ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( "<STR_LIT>" % <EOL> self . builddir_join ( '<STR_LIT>' ) ) <EOL> if os . name == '<STR_LIT>' : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> def build_info ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> with cd ( self . builddir_join ( '<STR_LIT>' ) ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> def build_gettext ( self ) : <EOL> dtdir = self . builddir_join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if self . run_generic_build ( '<STR_LIT>' , doctreedir = dtdir ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % <EOL> self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_changes ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % <EOL> self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_linkcheck ( self ) : <EOL> res = self . run_generic_build ( '<STR_LIT>' ) <EOL> print ( ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' % self . builddir_join ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return res <EOL> def build_doctest ( self ) : <EOL> res = self . run_generic_build ( '<STR_LIT>' ) <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" % self . builddir_join ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return res <EOL> def build_coverage ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" % self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_xml ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % self . builddir_join ( '<STR_LIT>' ) ) <EOL> def build_pseudoxml ( self ) : <EOL> if self . run_generic_build ( '<STR_LIT>' ) > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> print ( ) <EOL> print ( '<STR_LIT>' % <EOL> self . builddir_join ( '<STR_LIT>' ) ) <EOL> def run_generic_build ( self , builder , doctreedir = None ) : <EOL> papersize = os . getenv ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> opts = self . opts <EOL> if papersize in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> opts . extend ( [ '<STR_LIT>' , '<STR_LIT>' + papersize ] ) <EOL> if doctreedir is None : <EOL> doctreedir = self . builddir_join ( '<STR_LIT>' ) <EOL> orig_cmd = sys . argv [ <NUM_LIT:0> ] <EOL> if sys . platform == '<STR_LIT:win32>' and orig_cmd . endswith ( '<STR_LIT>' ) : <EOL> cmd = [ orig_cmd ] <EOL> elif sys . platform == '<STR_LIT:win32>' and os . path . splitext ( orig_cmd ) [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> cmd = [ orig_cmd + '<STR_LIT>' ] <EOL> else : <EOL> cmd = [ sys . executable , orig_cmd ] <EOL> return call ( cmd + [ '<STR_LIT>' , builder ] + opts + <EOL> [ '<STR_LIT>' , doctreedir , self . srcdir , self . builddir_join ( builder ) ] ) <EOL> def run_make_mode ( args ) : <EOL> if len ( args ) < <NUM_LIT:3> : <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' , file = sys . stderr ) <EOL> return <NUM_LIT:1> <EOL> make = Make ( args [ <NUM_LIT:1> ] , args [ <NUM_LIT:2> ] , args [ <NUM_LIT:3> : ] ) <EOL> run_method = '<STR_LIT>' + args [ <NUM_LIT:0> ] <EOL> if hasattr ( make , run_method ) : <EOL> return getattr ( make , run_method ) ( ) <EOL> return make . run_generic_build ( args [ <NUM_LIT:0> ] ) </s>
