File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 1
- import os
1
+ import pathlib
2
2
import zipfile
3
3
4
4
# Unzip zipped file
5
- def unzip (zip_file :str , output_dir :str ):
6
- with zipfile .ZipFile (zip_file , 'r' ) as zip_ref :
7
- zip_ref .extractall (output_dir )
5
+ def unzip (zip_file :pathlib . PosixPath , output_dir :pathlib . PosixPath ):
6
+ with zipfile .ZipFile (str ( zip_file ) , 'r' ) as zip_ref :
7
+ zip_ref .extractall (str ( output_dir ) )
8
8
9
9
# Make directory if it doesn't exist
10
- def dir_exists (directory :str ):
11
- if os . path . exists (directory ) is False :
12
- return os . makedirs (directory )
10
+ def dir_exists (directory :pathlib . PosixPath ):
11
+ if pathlib . Path . is_dir (directory ) is False :
12
+ return pathlib . Path . mkdir (directory )
13
13
return None
14
14
15
15
# Convert each value in combined_list to an integer if possible
@@ -18,3 +18,8 @@ def num_convert(num_string:str):
18
18
return int (num_string )
19
19
except ValueError :
20
20
return None
21
+
22
+ # Delete all temp files created by wget
23
+ def clean_up (cwd :pathlib .PosixPath ):
24
+ for file in cwd .glob ('**/*.tmp' ):
25
+ pathlib .Path .unlink (file )
You can’t perform that action at this time.
0 commit comments