<%namespace name="tools" file="tools.tex"/>
<%! import os %>

\documentclass[10pt,a4paper,twoside,openright]{../deltares_manual}

%% include packages
\usepackage[english]{babel}
%%\usepackage{nicefrac}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{float}
\usepackage{pifont}

%% auto ref names
\def\chapterautorefname{Chapter}
\def\sectionautorefname{Section}
\def\appendixautorefname{Appendix}
\def\figureautorefname{Figure}
\def\tableautorefname{Table}

\epstopdfsetup{suffix=}

\begin{document}

%% make title
\title{XBeach skillbed cartoon}
\subtitle{status update}
\manualtype{}
\version{${revision}}
\manualtitle

%% chapters

<%
    path1 = base_path
    dirs1 = os.listdir(path1)
    
    for dir1 in dirs1:
    	path2 = os.path.join(path1, dir1)
    	
        if path2[0] != '.' and os.path.isdir(path2):
            context.write('\\chapter{Case "%s"}' % tools.latex_escape(dir1))
            
            dirs2 = os.listdir(path2)
            
            for dir2 in dirs2:
                path3 = os.path.join(path2, dir2)
                
                if path3[0] != '.' and os.path.isdir(path3):
                    context.write('\\section{Run "%s"}' % tools.latex_escape(dir2))
                    dirs3 = os.listdir(path3)               
                    for filename in dirs3:
                        file, ext = os.path.splitext(filename)
                                        
                        if ext == '.png':
                            tools.image(os.path.join(dir1,dir2), filename)
                                        
                        if ext == '.tex':
                            tools.table(os.path.join(dir1,dir2), filename)
				
                else:
                    file, ext = os.path.splitext(dir2)
				                                            
                    if ext == '.png':
                        tools.image(dir1, dir2)
				                                            
                    if ext == '.tex':
                        tools.table(dir1, dir2)
%>

\end{document}

