File size: 4,070 Bytes
8a79f2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from future.utils import raise_from, string_types
from builtins import (bytes, str, open, super, range,
                      zip, round, input, int, pow, object)

# ~~~~~~~~~~~~~~~ #
# Define metadata #
# ~~~~~~~~~~~~~~~ #

makelog_started = False

color_success = None
color_failure = 'red'
color_in_process = 'cyan'

commands = {
    'posix': 
        {'makecopy' : 'cp -a \"%s\" \"%s\"', 
         'makelink' : 'ln -s \"%s\" \"%s\"',          
         'rmdir'    : 'rm %s \"%s\"', 
         'jupyter'  : '%s nbconvert --ExecutePreprocessor.timeout=-1 %s \"%s\"',
         'lyx'      : '%s %s \"%s\"',
         'latex'    : '%s -output-directory=latex_auxiliary_dir %s \"%s\"',
         'math'     : '%s < \"%s\" %s',
         'matlab'   : '%s %s -r \"try run(\'%s\'); catch e, fprintf(getReport(e)), exit(1); end; exit(0)\" -logfile \"%s\"',
         'perl'     : '%s %s \"%s\" %s',
         'python'   : '%s %s \"%s\" %s',
         'r'        : '%s %s \"%s\"',
         'sas'      : '%s %s -log -print %s',
         'st'       : '%s \"%s\"',
         'stata'    : '%s %s do \\\"%s\\\"'},
    'nt': 
        {'makecopy' : '%s xcopy /E /Y /Q /I /K \"%s\" \"%s\"',
         'makelink' : 'mklink %s \"%s\" \"%s\"',        
         'rmdir'    : 'rmdir %s \"%s\"', 
         'jupyter'  : '%s nbconvert --ExecutePreprocessor.timeout=-1 %s \"%s\"',
         'lyx'      : '%s %s \"%s\"',
         'latex'    : '%s -output-directory=latex_auxiliary_dir %s \"%s\"',
         'math'     : '%s < \"%s\" %s',
         'matlab'   : '%s %s -r \"try run(\'%s\'); catch e, fprintf(getReport(e)), exit(1); end; exit(0)\" -logfile \"%s\"',
         'perl'     : '%s %s \"%s\" %s',
         'python'   : '%s %s \"%s\" %s',
         'r'        : '%s %s \"%s\"',
         'sas'      : '%s %s -log -print %s',
         'st'       : '%s \"%s\"',
         'stata'    : '%s %s do \\\"%s\\\"'},
}

default_options = {
    'posix': 
        {'rmdir'    : '-rf', 
         'jupyter'  : '--to notebook --inplace --execute',
         'lyx'      : '-e pdf2',
         'latex'    : '',
         'math'     : '-noprompt',
         'matlab'   : '-nosplash -nodesktop',
         'perl'     : '',
         'python'   : '',
         'r'        : '--no-save',
         'sas'      : '',
         'st'       : '',
         'stata'    : '-e'},
    'nt': 
        {'rmdir'    : '/s /q', 
         'jupyter'  : '--to notebook --inplace --execute',
         'lyx'      : '-e pdf2',
         'latex'    : '',
         'math'     : '-noprompt',
         'matlab'   : '-nosplash -minimize -wait',
         'perl'     : '',
         'python'   : '',
         'r'        : '--no-save',
         'sas'      : '-nosplash',
         'st'       : '',
         'stata'    : '/e'}
}

default_executables = {
    'posix': 
        {'git-lfs'  : 'git-lfs', 
         'jupyter'  : 'python -m jupyter',
         'lyx'      : 'lyx',
         'latex'    : 'pdflatex',
         'math'     : 'math',
         'matlab'   : 'matlab',
         'perl'     : 'perl',
         'python'   : 'python',
         'r'        : 'Rscript',
         'sas'      : 'sas',
         'st'       : 'st',
         'stata'    : 'stata-mp'},
    'nt': 
        {'git-lfs'  : 'git-lfs',
         'jupyter'  : 'python -m jupyter',
         'lyx'      : 'LyX2.3',
         'latex'    : 'pdflatex',
         'math'     : 'math',
         'matlab'   : 'matlab',
         'perl'     : 'perl',
         'python'   : 'python',
         'r'        : 'Rscript',
         'sas'      : 'sas',
         'st'       : 'st',
         'stata'    : 'StataMP-64'},
}

extensions = {
    'jupyter' : ['.ipynb', '.IPYNB'],
    'lyx'     : ['.lyx', '.LYX'],
    'latex'   : ['.tex', '.TEX'],
    'math'    : ['.m', '.M'],
    'matlab'  : ['.m', '.M'],
    'perl'    : ['.pl', '.PL'],
    'python'  : ['.py', '.PY'],
    'r'       : ['.r', '.R'],
    'sas'     : ['.sas', '.SAS'],
    'st'      : ['.stc', '.STC', '.stcmd', '.STCMD'],
    'stata'   : ['.do', '.DO']
}