remove_trailing_spaces_from_filenames() not fixing the error - removed

This commit is contained in:
vangef committed 2023-03-01 00:46:04 +00:00
1 parent fb41caf7c5
commit 9c933348bd
2 files changed
+1 -12

No files matched your search

-10
View File
@@ -3,16 +3,6 @@ from utils.extractor import extract_file_to_dir
BAD_DIR_NAME = '__BAD__'
def remove_trailing_spaces_from_filenames(gradebook_dir):
for filename in os.listdir(gradebook_dir):
if BAD_DIR_NAME not in filename:
name, ext = os.path.splitext(filename) # separate file name from extension
if name != name.rstrip():
new_filename = name.rstrip() + ext # remove trailing spaces from file name and combines with extension
new_file_path = os.path.join(gradebook_dir, new_filename)
old_file_path = os.path.join(gradebook_dir, filename)
os.rename(old_file_path, new_file_path) # rename file
def validate_gradebook_dir_name(src_dir):
if not os.path.isdir(src_dir): # check if it exists and is a directory