Show More
@@ -5,3 +5,4 b" c.ConverterTemplate.template_file='latex_base'" | |||
|
5 | 5 | c.ConverterTemplate.tex_environement=True |
|
6 | 6 | |
|
7 | 7 | c.ExtractFigureTransformer.extra_ext_map={'svg':'pdf'} |
|
8 | c.ExtractFigureTransformer.enabled=True |
@@ -1,4 +1,17 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | """ | |
|
3 | ================================================================================ | |
|
4 | ||
|
5 | |,---. | | , .| | | |
|
6 | ||---', .|--- |---.,---.,---. |\ ||---.,---.,---.,---.. ,,---.,---.|--- | |
|
7 | || | || | || || | | \ || || | || | \ / |---'| | | |
|
8 | `` `---|`---'` '`---'` ' ` `'`---'`---'`---'` ' `' `---'` `---' | |
|
9 | `---' | |
|
10 | ================================================================================ | |
|
11 | ||
|
12 | Highly experimental for now | |
|
13 | ||
|
14 | """ | |
|
2 | 15 | #----------------------------------------------------------------------------- |
|
3 | 16 | # Imports |
|
4 | 17 | #----------------------------------------------------------------------------- |
@@ -22,6 +35,21 b' from converters.transformers import (ConfigurableTransformers,Foobar,ExtractFigu' | |||
|
22 | 35 | |
|
23 | 36 | class NbconvertApp(Application): |
|
24 | 37 | |
|
38 | stdout = Bool(True, config=True) | |
|
39 | write = Bool(False, config=True) | |
|
40 | ||
|
41 | aliases = { | |
|
42 | 'stdout':'NbconvertApp.stdout', | |
|
43 | 'write':'NbconvertApp.write', | |
|
44 | } | |
|
45 | ||
|
46 | flags= {} | |
|
47 | flags['no-stdout'] = ( | |
|
48 | {'NbconvertApp' : {'stdout' : False}}, | |
|
49 | """the doc for this flag | |
|
50 | ||
|
51 | """ | |
|
52 | ) | |
|
25 | 53 | |
|
26 | 54 | def __init__(self, **kwargs): |
|
27 | 55 | super(NbconvertApp, self).__init__(**kwargs) |
@@ -64,16 +92,26 b' class NbconvertApp(Application):' | |||
|
64 | 92 | C.read(ipynb_file) |
|
65 | 93 | |
|
66 | 94 | output,resources = C.convert() |
|
95 | if self.stdout : | |
|
96 | print(output.encode('utf-8')) | |
|
67 | 97 | |
|
68 | print(output.encode('utf-8')) | |
|
98 | out_root = ipynb_file[:-6].replace('.','_') | |
|
69 | 99 | |
|
70 | 100 | keys = resources.keys() |
|
71 | 101 | if keys : |
|
72 |
|
|
|
102 | if self.write : | |
|
103 | os.mkdir(out_root) | |
|
104 | for key in keys: | |
|
105 | if self.write: | |
|
106 | with io.open(os.path.join(out_root+key),'w') as f: | |
|
107 | print(' writing to ',os.path.join(out_root+key)) | |
|
108 | f.write(resources[key]) | |
|
109 | if self.stdout: | |
|
110 | print(''' | |
|
73 | 111 | ====================== Keys in Resources ================================== |
|
74 | 112 | ''') |
|
75 | print(resources.keys()) | |
|
76 | print(""" | |
|
113 | print(resources.keys()) | |
|
114 | print(""" | |
|
77 | 115 | =========================================================================== |
|
78 | 116 | you are responsible from writing those data do a file in the right place if |
|
79 | 117 | they need to be. |
@@ -83,6 +121,7 b' they need to be.' | |||
|
83 | 121 | def main(): |
|
84 | 122 | """Convert a notebook to html in one step""" |
|
85 | 123 | app = NbconvertApp.instance() |
|
124 | app.description = __doc__ | |
|
86 | 125 | app.initialize() |
|
87 | 126 | app.start() |
|
88 | 127 | app.run() |
General Comments 0
You need to be logged in to leave comments.
Login now