-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mv demo nbs into src folder and add fn for cloning to current dir
Signed-off-by: Kevin <[email protected]>
- Loading branch information
1 parent
ecf04c3
commit 62ce155
Showing
27 changed files
with
30 additions
and
2 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,27 @@ | ||
import pathlib | ||
import shutil | ||
|
||
package_dir = pathlib.Path(__file__).parent.parent.resolve() | ||
demo_dir = f"{package_dir}/demo-notebooks" | ||
|
||
|
||
def copy_demo_nbs(dir: str = "./demo-notebooks", overwrite: bool = False): | ||
""" | ||
Copy the demo notebooks from the package to the current working directory | ||
overwrite=True will overwrite any files that exactly match files written by copy_demo_nbs in the target directory. | ||
Any files that exist in the directory that don't match these values will remain untouched. | ||
Args: | ||
dir (str): The directory to copy the demo notebooks to. Defaults to "./demo-notebooks". overwrite (bool): | ||
overwrite (bool): Whether to overwrite files in the directory if it already exists. Defaults to False. | ||
Raises: | ||
FileExistsError: If the directory already exists. | ||
""" | ||
# does dir exist already? | ||
if overwrite is False and pathlib.Path(dir).exists(): | ||
raise FileExistsError( | ||
f"Directory {dir} already exists. Please remove it or provide a different location." | ||
) | ||
|
||
shutil.copytree(demo_dir, dir, dirs_exist_ok=True) |