-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add empty folder deletion to protolib/traverse_errors.py
- Loading branch information
Showing
2 changed files
with
91 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def check_py(files): | ||
for file in files: | ||
if 'ot2.apiv2.py' in file: | ||
return True | ||
return False | ||
|
||
|
||
def check_README(files): | ||
for file in files: | ||
if file == 'README.md': | ||
return True | ||
return False | ||
|
||
|
||
def check_fields(files): | ||
for file in files: | ||
if file == 'fields.json': | ||
return True | ||
return False | ||
|
||
|
||
def check_empty(folder): | ||
files = os.listdir(folder) | ||
return not (check_py(files) or check_README(files) or check_fields(files)) | ||
|
||
|
||
def delete_empty_folders(folder): | ||
if check_empty(folder): | ||
os.rmdir(folder) | ||
|
||
|
||
if __name__ == '__main__': | ||
source_file_path = sys.argv[1] | ||
source_folder_path = str(Path(source_file_path).parent) | ||
delete_empty_folders(source_folder_path) |