• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2
3import argparse
4from IPython.nbformat import v3, v4
5
6if __name__ == '__main__':
7    parser = argparse.ArgumentParser()
8    parser.add_argument("input", help="input python file")
9    parser.add_argument("output", help="output notebook file")
10    args = parser.parse_args()
11
12with open(args.input) as fpin:
13    text = fpin.read()
14
15nbook = v3.reads_py(text)
16nbook = v4.upgrade(nbook)  # Upgrade v3 to v4
17
18jsonform = v4.writes(nbook) + "\n"
19with open(args.output, "w") as fpout:
20    fpout.write(jsonform)
21
22
23