Project Name: google-research+arxiv-latex-cleaner
Language: Python
Statement Type: API

Source Code:
def _read_file_content(filename):
  with open(filename, 'r', encoding='utf-8') as fp:
    lines = fp.readlines()
    lines = _strip_tex_contents(lines, '\\end{document}')
    return lines

_read_file_content(filename='tex/main.tex')

Selected Statement: with open(filename, 'r', encoding='utf-8') as fp:

Function Input:
filename: 'tex/main.tex'

Variable Values Before Statement:
filename: 'tex/main.tex'

Value After Statement Execution: <_io.TextIOWrapper name

Variable States During Runtime (line, value):
filename: 1
'tex/main.tex'
fp: 2
<_io.TextIOWrapper name='tex/main.tex' mode='r' encoding='utf-8'>
lines: 3
\begin{document}

Text

% Whole line comment



Text% Inline comment

\begin{comment}

This is an environment comment.

\end{comment}



This is a percent \%.

% Whole line comment without newline

\includegraphics{images/im1_included.png}

%\includegraphics{images/im_not_included}

\includegraphics{images/im3_included.png}

\includegraphics{%

  images/im4_included.png%

  }

\includegraphics[width=.5\linewidth]{%

  images/im5_included.jpg}

%\includegraphics{%

%  images/im4_not_included.png

%  }

%\includegraphics[width=.5\linewidth]{%

%  images/im5_not_included.jpg}



% test whatever the path satrting with dot works when include graphics

\includegraphics{./images/im3_included.png}



This line should\mytodo{Do this later} not be separated

\mytodo{This is a todo command with a nested \textit{command}.

Please remember that up to \texttt{2 levels} of \textit{nesting} are supported.}

from this one.



\begin{mynote}

  This is a custom environment that could be excluded.

\end{mynote}



\newif\ifvar



\ifvar

\if    false

\if false

\if 0

\iffalse

\ifvar

Text

\fi

\fi

\fi

\fi

\fi

\fi



\newcommand{\red}[1]{{\color{red} #1}}

hello test \red{hello

test \red{hello}}

test



% content after this line should not be cleaned if \end{document} is in a comment



\input{figures/figure_included.tex}

% \input{figures/figure_not_included.tex}



% Test for tikzpicture feature

% should be replaced

\tikzsetnextfilename{test1}

\begin{tikzpicture}

    \node (test) at (0,0) {Test1};

\end{tikzpicture}



% should be replaced in included file

\input{figures/figure_included.tikz}



% should not be be replaced - no preceding tikzsetnextfilename command

\begin{tikzpicture}

    \node (test) at (0,0) {Test3};

\end{tikzpicture}



\tikzsetnextfilename{test_no_match}

\begin{tikzpicture}

    \node (test) at (0,0) {Test4};

\end{tikzpicture}



\end{document}



This should be ignored.

4
\begin{document}

Text

% Whole line comment



Text% Inline comment

\begin{comment}

This is an environment comment.

\end{comment}



This is a percent \%.

% Whole line comment without newline

\includegraphics{images/im1_included.png}

%\includegraphics{images/im_not_included}

\includegraphics{images/im3_included.png}

\includegraphics{%

  images/im4_included.png%

  }

\includegraphics[width=.5\linewidth]{%

  images/im5_included.jpg}

%\includegraphics{%

%  images/im4_not_included.png

%  }

%\includegraphics[width=.5\linewidth]{%

%  images/im5_not_included.jpg}



% test whatever the path satrting with dot works when include graphics

\includegraphics{./images/im3_included.png}



This line should\mytodo{Do this later} not be separated

\mytodo{This is a todo command with a nested \textit{command}.

Please remember that up to \texttt{2 levels} of \textit{nesting} are supported.}

from this one.



\begin{mynote}

  This is a custom environment that could be excluded.

\end{mynote}



\newif\ifvar



\ifvar

\if    false

\if false

\if 0

\iffalse

\ifvar

Text

\fi

\fi

\fi

\fi

\fi

\fi



\newcommand{\red}[1]{{\color{red} #1}}

hello test \red{hello

test \red{hello}}

test



% content after this line should not be cleaned if \end{document} is in a comment



\input{figures/figure_included.tex}

% \input{figures/figure_not_included.tex}



% Test for tikzpicture feature

% should be replaced

\tikzsetnextfilename{test1}

\begin{tikzpicture}

    \node (test) at (0,0) {Test1};

\end{tikzpicture}



% should be replaced in included file

\input{figures/figure_included.tikz}



% should not be be replaced - no preceding tikzsetnextfilename command

\begin{tikzpicture}

    \node (test) at (0,0) {Test3};

\end{tikzpicture}



\tikzsetnextfilename{test_no_match}

\begin{tikzpicture}

    \node (test) at (0,0) {Test4};

\end{tikzpicture}



\end{document}