Skip to content

Commit

Permalink
Moved function
Browse files Browse the repository at this point in the history
  • Loading branch information
m-a-x-s-e-e-l-i-g committed Jul 28, 2023
1 parent c9c9ed1 commit ea710a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
18 changes: 0 additions & 18 deletions src/tools/clear_output_folder.py

This file was deleted.

12 changes: 11 additions & 1 deletion src/tools/frontend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import random
import sys
from pathlib import Path
Expand All @@ -7,8 +8,8 @@
base_path = Path(__file__).parent.parent.parent
sys.path.append(base_path.as_posix())

from src.config import TARGET_PATH
from src.tools.search_by_keyword import search_by_keyword
from src.tools.clear_output_folder import clear_output_folder


def main():
Expand Down Expand Up @@ -52,6 +53,15 @@ def main():
images_sample = random.sample(images, min(len(images), 20))
ex.image(images_sample, width=200)

def clear_output_folder():
if not os.path.isdir(TARGET_PATH):
return
for root, dirs, files in os.walk(TARGET_PATH, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
print(f"Output folder cleared.")

if __name__ == "__main__":
main()

0 comments on commit ea710a3

Please sign in to comment.