From d63467b7242d54478242fa72d90a505a3083f177 2013-01-28 18:59:55 From: Matthias BUSSONNIER Date: 2013-01-28 18:59:55 Subject: [PATCH] put figures in subkey --- diff --git a/converters/transformers.py b/converters/transformers.py index d821134..f1fd294 100755 --- a/converters/transformers.py +++ b/converters/transformers.py @@ -121,13 +121,15 @@ class ExtractFigureTransformer(ConfigurableTransformers): def cell_transform(self, cell, other, count): if not self.enabled: return cell, other + if other.get('figures',None) is None : + other['figures']={} for i, out in enumerate(cell.get('outputs', [])): for type in self.display_data_priority: if out.hasattr(type): figname, key, data = self._new_figure(out[type], type, count) cell.outputs[i][type] = figname out['key_'+type] = figname - other[key] = data + other['figures'][key] = data count = count+1 return cell, other diff --git a/runme.py b/runme.py index c5d892c..b489a83 100755 --- a/runme.py +++ b/runme.py @@ -98,7 +98,7 @@ class NbconvertApp(Application): out_root = ipynb_file[:-6].replace('.','_').replace(' ','_') - keys = resources.keys() + keys = resources.get('figures',{}).keys() if self.write : with io.open(os.path.join(out_root+'.'+self.fileext),'w') as f: f.write(output) @@ -109,12 +109,12 @@ class NbconvertApp(Application): if self.write: with io.open(os.path.join(out_root+'_files',key),'wb') as f: print(' writing to ',os.path.join(out_root,key)) - f.write(resources[key]) + f.write(resources['figures'][key]) if self.stdout: print(''' ====================== Keys in Resources ================================== ''') - print(resources.keys()) + print(resources['figures'].keys()) print(""" =========================================================================== you are responsible from writing those data do a file in the right place if