-
Notifications
You must be signed in to change notification settings - Fork 4
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
0ecab6e
commit e2559f6
Showing
7 changed files
with
44 additions
and
6 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
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
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
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 os import walk | ||
from pathlib import Path | ||
from shutil import rmtree | ||
|
||
REPO_DIR = Path(__file__).resolve().parent.parent | ||
IMAGES_DIR = REPO_DIR / 'images' | ||
|
||
files_del = [] | ||
dirs_del = [] | ||
|
||
# walk the images directory and find all the child directories | ||
for dirpath, dirnames, files in walk(IMAGES_DIR): | ||
# os.walk includes the root directory (i.e. repo/images) so we need to skip it | ||
if not IMAGES_DIR.samefile(dirpath) and Path(dirpath).parent.samefile(IMAGES_DIR): | ||
files_del.extend([Path(dirpath) / f for f in files if not f.lower() == 'image.yaml' and not f.lower() == 'image.yml']) | ||
dirs_del.extend([Path(dirpath) / d for d in dirnames]) | ||
|
||
for f in files_del: | ||
f.unlink() | ||
|
||
for d in dirs_del: | ||
rmtree(d) |