This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
forked from PV-Tutorials/PVSC50
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5f668c
commit 524cd1c
Showing
4 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# from https://github.com/executablebooks/jupyter-book/issues/1087#issuecomment-1969119486 | ||
|
||
import base64 | ||
import json | ||
import glob | ||
|
||
filenames = glob.glob('*ipynb') | ||
|
||
for fn in filenames: | ||
with open(fn) as f: | ||
nb = json.load(f) | ||
|
||
attachments = [cell.get('attachments') for cell in nb['cells']] | ||
attachments = [a for a in attachments if a] | ||
|
||
for attachment in attachments: | ||
for name, data in attachment.items(): | ||
for filetype, encoded in data.items(): | ||
print(f'{name} ({filetype})') | ||
img_data = base64.b64decode(encoded) | ||
with open(f'attachment:{name}', 'wb') as img: | ||
img.write(img_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters