#NEWLINE# def rst2tex( in_path , out_path ) : #NEWLINE# #INDENT# dir_util . copy_tree ( in_path , out_path ) #NEWLINE# base_dir = os . path . dirname ( __file__ ) #NEWLINE# scipy_status = os . path . join ( base_dir , '_static/status.sty' ) #NEWLINE# shutil . copy ( scipy_status , out_path ) #NEWLINE# scipy_style = os . path . join ( base_dir , '_static/scipy.sty' ) #NEWLINE# shutil . copy ( scipy_style , out_path ) #NEWLINE# preamble = '\\usepackage{scipy}' #NEWLINE# pygments = None #NEWLINE# try : #NEWLINE# #INDENT# import pygments #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# import warnings #NEWLINE# warnings . warn ( RuntimeWarning ( 'Could not import Pygments. Syntax highlighting will fail.' ) ) #NEWLINE# #UNINDENT# if pygments : #NEWLINE# #INDENT# from pygments.formatters import LatexFormatter #NEWLINE# from writer.sphinx_highlight import SphinxStyle #NEWLINE# preamble += LatexFormatter ( style = SphinxStyle ) . get_style_defs ( ) #NEWLINE# #UNINDENT# settings = { #NEWLINE# #INDENT# 'documentclass' : 'IEEEtran' , #NEWLINE# 'use_verbatim_when_possible' : True , #NEWLINE# 'use_latex_citations' : True , #NEWLINE# 'latex_preamble' : preamble , #NEWLINE# 'documentoptions' : 'letterpaper,compsoc,twoside' , #NEWLINE# 'halt_level' : 3 , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# ( rst , ) = glob . glob ( os . path . join ( in_path , '*.rst' ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise RuntimeError ( 'Found more than one input .rst--not sure which one to use.' ) #NEWLINE# #UNINDENT# content = ( header + open ( rst , 'r' ) . read ( ) ) #NEWLINE# tex = dc . publish_string ( source = content , writer = writer , settings_overrides = settings ) #NEWLINE# stats_file = os . path . join ( out_path , 'paper_stats.json' ) #NEWLINE# d = options . cfg2dict ( stats_file ) #NEWLINE# try : #NEWLINE# #INDENT# d . update ( writer . document . stats ) #NEWLINE# options . dict2cfg ( d , stats_file ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# print ( 'Error: no paper configuration found' ) #NEWLINE# #UNINDENT# tex_file = os . path . join ( out_path , 'paper.tex' ) #NEWLINE# with open ( tex_file , 'w' ) as f : #NEWLINE# #INDENT# f . write ( tex )