Beispiel #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)
Beispiel #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)
Beispiel #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)
 def load_references(self):
     NOTEBOOKS = self.GLOBALS['NOTEBOOKS']
     path_references = os.path.join(NOTEBOOKS, 'references.json')
     return ds.load_json(path_references)
 def load_config(self, arg):
     path_config = os.path.join(self.get_path(arg), 'config.json')
     return ds.load_json(path_config)
 def _get_globals(self):
     return ds.load_json('_makescripts/data/globals.json')
Beispiel #7
0
 def load_references(self):
     NOTEBOOKS = self.GLOBALS['NOTEBOOKS']
     path_references = os.path.join(NOTEBOOKS, 'references.json')
     return ds.load_json(path_references)
Beispiel #8
0
 def load_config(self, arg):
     path_config = os.path.join(self.get_path(arg), 'config.json')
     return ds.load_json(path_config)
Beispiel #9
0
 def _get_globals(self):
     return ds.load_json('_makescripts/data/globals.json')