File: vistrails.sty

package info (click to toggle)
vistrails 3.0~git%2B9dc22bd.dfsg.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 62,856 kB
  • sloc: python: 314,055; xml: 42,697; sql: 4,113; php: 731; sh: 469; makefile: 253
file content (188 lines) | stat: -rw-r--r-- 7,937 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Copyright (C) 2014-2016, New York University.
%% Copyright (C) 2011-2014, NYU-Poly.
%% Copyright (C) 2006-2011, University of Utah.
%% All rights reserved.
%% Contact: contact@vistrails.org
%%
%% This file is part of VisTrails.
%%
%% "Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions are met:
%%
%%  - Redistributions of source code must retain the above copyright notice,
%%    this list of conditions and the following disclaimer.
%%  - Redistributions in binary form must reproduce the above copyright
%%    notice, this list of conditions and the following disclaimer in the
%%    documentation and/or other materials provided with the distribution.
%%  - Neither the name of the New York University nor the names of its
%%    contributors may be used to endorse or promote products derived from
%%    this software without specific prior written permission.
%%
%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
%% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
%% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
%% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
%% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
%% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
%% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
%% OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
%% WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
%% OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
%% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Note: shell-escape needs to be activated for this to work.
%% This can either be done by passing -shell-escape as an option to
%% latex or by adding/changing "shell_escape = t" in your texmf.cnf .

\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{vistrails}[2011/02/10 v0.4 VisTrails in LaTeX]

%% keyval package allows us to define arguments in a command as key-value pairs,
%%  which is more convenient
%% ifplatform for detecting which version of OS we are running on
\RequirePackage{graphicx,keyval,ifthen,ifplatform}

%% This is to hide the border of the included image
\RequirePackage[pdfborder={0 0 0}]{hyperref}
\hypersetup{extension=notused}

%% we will generate a file for passing to python
\newwrite\pythonincludein

%% by default we will run vistrails on the web server
\newcommand{\vistrailspath}{}

%% environment configuration to be set before executing vistrails
%% for example
%% \newcommand{\vistrailsenv}{DYLD_LIBRARY_PATH= }
\newcommand{\vistrailsenv}{}

%% url for downloading the vistrails linked from the images
%% leave it empty if you don't want to embed a link in the pdf
\newcommand{\vistrailsdownload}{}

%% full path to python or just python if it is on PATH
\newcommand{\vistrailspythonpath}{python3}

%% this is for allowing line breaks, empty values in vistrails command's options
\def\vistrail{\kernel@ifnextchar [{\@vistrail}{\@vistrail[]}}
\def\@vistrail[#1]#2{%

%% macros that will be used
\def\vthost{vistrails.org}
\def\vtdb{vistrails}
\def\vtuser{}
\def\vtfilename{}
\def\vtvtid{}
\def\vtversion{}
\def\vttag{}
\def\vtport{3306}
\def\vtbuildalways{false}
\def\vtexecute{false}
\def\vtshowspreadsheetonly{false}
\def\vtpdf{false}
\def\vtworkflow{false}
\def\vttree{false}
\def\vtgetvtl{false}
\def\vtembedworkflow{false}
\def\vtincludefulltree{false}
\newread\myinput
%% We use '\jobname.python.temp' to store a unique file saying if python is present
\ifwindows
  \immediate\write18{find.cmd \vistrailspythonpath > \jobname.python.temp}
\else
  \immediate\write18{type -P "\vistrailspythonpath" > \jobname.python.temp}
\fi
\immediate\openin\myinput=\jobname.python.temp
% The group localizes the change to \endlinechar
\bgroup
  \endlinechar=-1
  \immediate\read\myinput to \localline
  % Since everything in the group is local, we have to explicitly make the
  % assignment global
  \global\let\pythonexists\localline
\egroup
\immediate\closein\myinput
% Clean up after ourselves
\ifwindows
  \immediate\write18{del \jobname.python.temp}
\else
  \immediate\write18{rm -f -- \jobname.python.temp}
\fi
\setkeys{vt}{#1}
\ifthenelse{\equal{\vtpdf}{true}}{\def\vttype{pdf}}{\def\vttype{png}}
\ifthenelse{\equal{\pythonexists}{}}{%
  % python does not exist. Include images directly
  \ifthenelse{\equal{\vttree}{true}}{%
  % include version tree image
    \immediate\input cached/\vthost\string_\vtdb\string_\vtport\string_\vtvtid\string_\vttype.tex
   }
   {% else test if don't include the workflow graph
    \ifthenelse{\equal{\vtworkflow}{false}}{% 
        \immediate\input cached/\vthost\string_\vtdb\string_\vtport\string_\vtvtid\string_\vtversion\string_\vttype.tex
     }
     {% else include workflow graph
        \immediate\input cached/\vthost\string_\vtdb\string_\vtport\string_\vtvtid\string_\vtversion\string_\vttype\string_graph.tex
    }
   }
  }
 { %else prepare input file for includevistrail.py
   \immediate\openout\pythonincludein=\jobname.cmdline
    \immediate\write\pythonincludein{path=\vistrailspath}
    \immediate\write\pythonincludein{python=\vistrailspythonpath}
    \immediate\write\pythonincludein{env=\vistrailsenv}
    \immediate\write\pythonincludein{download=\vistrailsdownload}
    \ifthenelse{\equal{\vtfilename}{}}{%
      \immediate\write\pythonincludein{host=\vthost}
      \immediate\write\pythonincludein{db=\vtdb}
      \immediate\write\pythonincludein{vtid=\vtvtid}
      \immediate\write\pythonincludein{user=\vtuser}
    }
    {% else it's a filename
      \immediate\write\pythonincludein{filename=\vtfilename}
    }
    \immediate\write\pythonincludein{version=\vtversion}
    \immediate\write\pythonincludein{tag=\vttag}
    \immediate\write\pythonincludein{port=\vtport}
    \immediate\write\pythonincludein{buildalways=\vtbuildalways}
    \immediate\write\pythonincludein{execute=\vtexecute}
    \immediate\write\pythonincludein{showspreadsheetonly=\vtshowspreadsheetonly}
    \immediate\write\pythonincludein{pdf=\vtpdf}
    \immediate\write\pythonincludein{workflow=\vtworkflow}
    \immediate\write\pythonincludein{tree=\vttree}
    \immediate\write\pythonincludein{getvtl=\vtgetvtl}
    \immediate\write\pythonincludein{embedworkflow=\vtembedworkflow}
    \immediate\write\pythonincludein{includefulltree=\vtincludefulltree}
    \ifx\@empty#2\@empty
        \immediate\write\pythonincludein{other=}
    \else
        \immediate\write\pythonincludein{other=\string#2}
    \fi
    \immediate\closeout\pythonincludein
    \immediate\write18{"\vistrailspythonpath" \space includevistrail.py \jobname.cmdline > \jobname.cmdline.tex 2> \jobname.cmdline.err}
    \immediate\input\jobname.cmdline.tex
}
}
%% key-value pairs for the command's options
\define@key{vt}{host}[vistrails.org]{\def\vthost{#1}}
\define@key{vt}{db}[vistrails]{\def\vtdb{#1}}
\define@key{vt}{user}[vistrails]{\def\vtuser{#1}}
\define@key{vt}{vtid}{\def\vtvtid{#1}}
\define@key{vt}{filename}{\def\vtfilename{#1}}
\define@key{vt}{version}{\def\vtversion{#1}}
\define@key{vt}{tag}[]{\def\vttag{#1}}
\define@key{vt}{port}[3306]{\def\vtport{#1}}
\define@key{vt}{buildalways}[true]{\def\vtbuildalways{#1}}
\define@key{vt}{execute}[true]{\def\vtexecute{#1}}
\define@key{vt}{showspreadsheetonly}[true]{\def\vtshowspreadsheetonly{#1}}
\define@key{vt}{pdf}[true]{\def\vtpdf{#1}}
\define@key{vt}{showworkflow}[true]{\def\vtworkflow{#1}}
\define@key{vt}{showtree}[true]{\def\vttree{#1}}
\define@key{vt}{getvtl}[true]{\def\vtgetvtl{#1}}
\define@key{vt}{embedworkflow}[true]{\def\vtembedworkflow{#1}}
\define@key{vt}{includefulltree}[true]{\def\vtincludefulltree{#1}}