Skip to content

Commit

Permalink
signalflow_examples: Download notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Nov 10, 2023
1 parent 727d8e4 commit 7edc2a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion auxiliary/libs/signalflow_examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .signalflow_examples import download_examples
from .signalflow_examples import download_examples, download_notebooks
24 changes: 22 additions & 2 deletions auxiliary/libs/signalflow_examples/signalflow_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import urllib.request
import urllib.parse
import logging
import ssl
import os
Expand All @@ -14,7 +15,7 @@ def download_examples() -> None:
"""
Download all example scripts from GitHub to the current directory.
"""
url_prefix = "https://raw.githubusercontent.com/ideoforms/signalflow/master/examples/"
url_prefix = "https://raw.githubusercontent.com/ideoforms/signalflow/master/examples"
examples = [
"audio-through-example.py",
"buffer-play-example.py",
Expand All @@ -32,8 +33,27 @@ def download_examples() -> None:
]
local_dir = "examples"
os.makedirs(local_dir, exist_ok=True)
print("Downloading examples to: %s" % local_dir)
for filename in examples:
url = "%s%s" % (url_prefix, filename)
url = "%s/%s" % (url_prefix, urllib.parse.quote(filename))
output_path = os.path.join(local_dir, filename)
urllib.request.urlretrieve(url, output_path)
print(" - Downloaded: %s" % filename)

def download_notebooks() -> None:
"""
Download all example scripts from GitHub to the current directory.
"""
url_prefix = "https://raw.githubusercontent.com/ideoforms/signalflow/master/examples/notebooks"
notebooks = [
"01. Hello World.ipynb",
"02. Patch Example.ipynb",
]
local_dir = "notebooks"
os.makedirs(local_dir, exist_ok=True)
print("Downloading examples to: %s" % local_dir)
for filename in notebooks:
url = "%s/%s" % (url_prefix, urllib.parse.quote(filename))
output_path = os.path.join(local_dir, filename)
urllib.request.urlretrieve(url, output_path)
print(" - Downloaded: %s" % filename)
Expand Down

0 comments on commit 7edc2a0

Please sign in to comment.