From 7a03b6b35bfd4af96e60e2137fe8f87f8d26bbfa Mon Sep 17 00:00:00 2001 From: Nick Young Date: Mon, 15 Feb 2021 14:32:35 +1300 Subject: [PATCH 1/3] fix typo, fix print --- nbgitconvert | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nbgitconvert b/nbgitconvert index 74dac38..1dd71d6 100755 --- a/nbgitconvert +++ b/nbgitconvert @@ -2,7 +2,7 @@ """ Convert juptyer notebooks to html, markdown, or pdf -durint git commits +during git commits INSTALL: 1. chmod +x nbgitconvert @@ -177,7 +177,7 @@ if __name__ == '__main__': except ConfigParser.NoSectionError: pass except Exception as e: - print e + print(e) raise parser.add_argument('--html', action='store_true') parser.add_argument('--markdown', action='store_true') From 5440660e24993343efa73a20595586528e9a7403 Mon Sep 17 00:00:00 2001 From: Nick Young Date: Mon, 15 Feb 2021 14:38:41 +1300 Subject: [PATCH 2/3] python3 fixes --- nbgitconvert | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nbgitconvert b/nbgitconvert index 1dd71d6..283d3ff 100755 --- a/nbgitconvert +++ b/nbgitconvert @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Convert juptyer notebooks to html, markdown, or pdf @@ -16,7 +16,7 @@ The setup step will create a git hook that, for any .ipynb files staged for comm import subprocess import argparse import os -import ConfigParser +import configparser convert_dict = { @@ -33,7 +33,7 @@ def create_config(): return # if the config already exists, don't overwrite it lines = ["[output_types]"] - for output_type, d in convert_dict.iteritems(): + for output_type, d in convert_dict.items(): lines.append('%s = %s' % (output_type, d['default'])) lines.append("") lines.append("[output_dir]") @@ -168,13 +168,13 @@ if __name__ == '__main__': parser.add_argument('--all', action='store_true') parser.add_argument('--setup', action='store_true') try: - config = ConfigParser.ConfigParser() + config = configparser.ConfigParser() config.read(CONFIG_LOCATION) args = vars(parser.parse_args()) for option in config.options('output_types'): args[option] = config.getboolean('output_types', option) args['output_dir'] = config.get('output_dir', 'path') - except ConfigParser.NoSectionError: + except configparser.NoSectionError: pass except Exception as e: print(e) From 5464b17a0cbf39e2bb11bd3b70076648567fda1a Mon Sep 17 00:00:00 2001 From: Nick Young Date: Mon, 15 Feb 2021 15:20:52 +1300 Subject: [PATCH 3/3] fix encoding --- nbgitconvert | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nbgitconvert b/nbgitconvert index 283d3ff..364004d 100755 --- a/nbgitconvert +++ b/nbgitconvert @@ -69,7 +69,7 @@ def setup(): def system(*args, **kwargs): """Run system command.""" kwargs.setdefault('stdout', subprocess.PIPE) - proc = subprocess.Popen(args, **kwargs) + proc = subprocess.Popen(args, **kwargs, encoding="utf8") out, err = proc.communicate() return out @@ -77,7 +77,7 @@ def system(*args, **kwargs): def system_with_exitcode(*args, **kwargs): """Run system command and return an exit code.""" kwargs.setdefault('stdout', subprocess.PIPE) - proc = subprocess.Popen(args, **kwargs) + proc = subprocess.Popen(args, **kwargs, encoding="utf8") out, err = proc.communicate() return proc.returncode