Exemplo n.º 1
0
def main():

    path_handler = common.PathHandler('trim')

    for arg in path_handler.args:

        file_ipynb = path_handler.get_file(arg, '.ipynb')
        nb_json = ds.load_json(file_ipynb)
        cells = path_handler.load_config(arg)['cells']

        nb_json_cells = nb_json['worksheets'][0]['cells']
        nb_json['worksheets'][0]['cells'] = nb_json_cells[cells[0]:cells[1]]

        file_tmp_ipynb = file_ipynb.replace('.ipynb', '.tmp.ipynb')
        ds.dump_json(nb_json, file_tmp_ipynb, indent=1)
Exemplo n.º 2
0
def main():

    path_handler = common.PathHandler('trim')

    for arg in path_handler.args:

        file_ipynb = path_handler.get_file(arg, '.ipynb')
        nb_json = ds.load_json(file_ipynb)
        cells = path_handler.load_config(arg)['cells']

        nb_json_cells = nb_json['worksheets'][0]['cells']
        nb_json['worksheets'][0]['cells'] = nb_json_cells[cells[0]:cells[1]]

        file_tmp_ipynb = file_ipynb.replace('.ipynb', '.tmp.ipynb')
        ds.dump_json(nb_json, file_tmp_ipynb, indent=1)
Exemplo n.º 3
0
def main():

    path_handler = common.PathHandler('trim')

    for arg in path_handler.args:

        file_ipynb = path_handler.get_file(arg, '.ipynb')
        nb_json = ds.load_json(file_ipynb)
        cells = path_handler.load_config(arg)['cells']

        if nb_json['nbformat'] == 4:
            nb_json_cells = nb_json['cells']
            nb_json['cells'] = get_slice(nb_json_cells, cells)
        else:
            nb_json_cells = nb_json['worksheets'][0]['cells']
            nb_json['worksheets'][0]['cells'] = get_slice(nb_json_cells, cells)

        file_tmp_ipynb = file_ipynb.replace('.ipynb', '.tmp.ipynb')
        ds.dump_json(nb_json, file_tmp_ipynb, indent=1)
Exemplo n.º 4
0
 def load_references(self):
     NOTEBOOKS = self.GLOBALS['NOTEBOOKS']
     path_references = os.path.join(NOTEBOOKS, 'references.json')
     return ds.load_json(path_references)
Exemplo n.º 5
0
 def load_config(self, arg):
     path_config = os.path.join(self.get_path(arg), 'config.json')
     return ds.load_json(path_config)
Exemplo n.º 6
0
 def _get_globals(self):
     return ds.load_json('_makescripts/data/globals.json')
Exemplo n.º 7
0
 def load_references(self):
     NOTEBOOKS = self.GLOBALS['NOTEBOOKS']
     path_references = os.path.join(NOTEBOOKS, 'references.json')
     return ds.load_json(path_references)
Exemplo n.º 8
0
 def load_config(self, arg):
     path_config = os.path.join(self.get_path(arg), 'config.json')
     return ds.load_json(path_config)
Exemplo n.º 9
0
 def _get_globals(self):
     return ds.load_json('_makescripts/data/globals.json')