JarrettYe commited on
Commit
017a7a9
1 Parent(s): 0dddcae

remove folders correctly

Browse files
Files changed (1) hide show
  1. utilities.py +6 -3
utilities.py CHANGED
@@ -1,6 +1,6 @@
1
  from zipfile import ZipFile
2
- import os
3
  from pathlib import Path
 
4
 
5
 
6
  # Extract the collection file or deck file to get the .anki21 database.
@@ -16,11 +16,14 @@ def extract(file, prefix):
16
 
17
  def cleanup(proj_dir: Path, files):
18
  """
19
- Delete all files in prefix that dont have filenames in files
20
  :param proj_dir:
21
  :param files:
22
  :return:
23
  """
24
  for file in proj_dir.glob("*"):
25
  if file.name not in files:
26
- os.remove(file)
 
 
 
 
1
  from zipfile import ZipFile
 
2
  from pathlib import Path
3
+ import shutil
4
 
5
 
6
  # Extract the collection file or deck file to get the .anki21 database.
 
16
 
17
  def cleanup(proj_dir: Path, files):
18
  """
19
+ Delete all files/folders in prefix that dont have filenames in files
20
  :param proj_dir:
21
  :param files:
22
  :return:
23
  """
24
  for file in proj_dir.glob("*"):
25
  if file.name not in files:
26
+ if file.is_file():
27
+ file.unlink()
28
+ else:
29
+ shutil.rmtree(file)