jckantor / nbpages

Command line tool to maintain a repository of Jupyter notebooks.
https://jckantor.github.io/nbpages/
MIT License
1 stars 4 forks source link

Add command line option to disable automatic insertion of code #58

Open adowling2 opened 3 years ago

adowling2 commented 3 years ago

Here is one of my pages: https://ndcbe.github.io/CBE60499/01.01-Pyomo-Nuts-and-Bolts.html

I would like a command-line option to prevent nbpages from inserting this code:

# IMPORT DATA FILES USED BY THIS NOTEBOOK
import os,  requests

file_links = [("data/Prices_DAM_ALTA2G_7_B1.csv", "https://ndcbe.github.io/CBE60499/data/Prices_DAM_ALTA2G_7_B1.csv")]

# This cell has been added by nbpages. Run this cell to download data files required for this notebook.

for filepath, fileurl in file_links:
    stem, filename = os.path.split(filepath)
    if stem:
        if not os.path.exists(stem):
            os.mkdir(stem)
    if not os.path.isfile(filepath):
        with open(filepath, 'wb') as f:
            response = requests.get(fileurl)
            f.write(response.content)

Why? I'm going to package it in helper.py for this course. I need several helper functions to install solvers anyways.

adowling2 commented 3 years ago

@jckantor Any thoughts? I'm hoping this is straightforward.