From c336f65b145d97c7dee5dcf53844dd061e2fb89f 2013-02-13 19:30:06 From: Matthias BUSSONNIER Date: 2013-02-13 19:30:06 Subject: [PATCH] rename runme2 to runme --- diff --git a/runme.py b/runme.py index 4712b5c..ab5269c 100755 --- a/runme.py +++ b/runme.py @@ -1,22 +1,65 @@ #!/usr/bin/env python -# coding: utf-8 - +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- from __future__ import print_function import sys import io + from converters.template import * +from converters.template import ConverterTemplate +from converters.html import ConverterHTML +# From IPython + +# All the stuff needed for the configurable things +from IPython.config.application import Application +from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, CaselessStrEnum + + +class NbconvertApp(Application): + + + def __init__(self, **kwargs): + super(NbconvertApp, self).__init__(**kwargs) + self.classes.insert(0,ConverterTemplate) + # ensure those are registerd + + + def initialize(self, argv=None): + self.parse_command_line(argv) + cl_config = self.config + self.update_config(cl_config) + + + + def run(self): + """Convert a notebook to html in one step""" + template_file = (self.extra_args or [None])[0] + ipynb_file = (self.extra_args or [None])[1] + + template_file = sys.argv[1] + if template_file.startswith('latex'): + tex_environement=True + else: + tex_environement=False -template_file = sys.argv[1] + C = ConverterTemplate(tplfile=sys.argv[1], tex_environement=tex_environement, config=self.config) + C.read(ipynb_file) -if template_file.startswith('latex'): - tex_environement=True -else: - tex_environement=False + output,rest = C.convert() -C = ConverterTemplate(tplfile=sys.argv[1], tex_environement=tex_environement) -C.read(sys.argv[2]) + print(output.encode('utf-8')) -output,rest = C.convert() +def main(): + """Convert a notebook to html in one step""" + app = NbconvertApp.instance() + app.initialize() + app.start() + app.run() +#----------------------------------------------------------------------------- +# Script main +#----------------------------------------------------------------------------- -print(output.encode('utf-8')) +if __name__ == '__main__': + main() diff --git a/runme2.py b/runme2.py deleted file mode 100755 index ab5269c..0000000 --- a/runme2.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- -from __future__ import print_function -import sys -import io - -from converters.template import * -from converters.template import ConverterTemplate -from converters.html import ConverterHTML -# From IPython - -# All the stuff needed for the configurable things -from IPython.config.application import Application -from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, CaselessStrEnum - - -class NbconvertApp(Application): - - - def __init__(self, **kwargs): - super(NbconvertApp, self).__init__(**kwargs) - self.classes.insert(0,ConverterTemplate) - # ensure those are registerd - - - def initialize(self, argv=None): - self.parse_command_line(argv) - cl_config = self.config - self.update_config(cl_config) - - - - def run(self): - """Convert a notebook to html in one step""" - template_file = (self.extra_args or [None])[0] - ipynb_file = (self.extra_args or [None])[1] - - template_file = sys.argv[1] - - if template_file.startswith('latex'): - tex_environement=True - else: - tex_environement=False - - C = ConverterTemplate(tplfile=sys.argv[1], tex_environement=tex_environement, config=self.config) - C.read(ipynb_file) - - output,rest = C.convert() - - print(output.encode('utf-8')) - -def main(): - """Convert a notebook to html in one step""" - app = NbconvertApp.instance() - app.initialize() - app.start() - app.run() -#----------------------------------------------------------------------------- -# Script main -#----------------------------------------------------------------------------- - -if __name__ == '__main__': - main()