no message

This commit is contained in:
Matt Troutman 2024-09-16 21:01:31 -05:00
parent 821dec8057
commit 02c5c42547
No known key found for this signature in database

View file

@ -151,7 +151,7 @@ def add_font_folders_to_each(root_path):
continue
#get recursive list of files in the directory
files = os.listdir(dir_path)
print(files)
# print(files)
for file in files:
# if file extension is otf, create a folder named oft if it doesn't exist, and move the file there
if file.endswith('.otf'):
@ -177,6 +177,30 @@ def add_font_folders_to_each(root_path):
new_file_path = os.path.join(new_dir_path, file)
os.rename(os.path.join(dir_path, file), new_file_path)
def unzip_if_no_fonts(root_path):
#if there are no font files, find the zip file and unzip it
for dir in os.listdir(root_path):
dir_path = os.path.join(root_path, dir)
if os.path.isdir(dir_path):
if dir.startswith('.'):
continue
#get recursive list of files in the directory
files = os.listdir(dir_path)
# print(files)
font_files = []
for file in files:
if file.endswith('.otf') or file.endswith('.ttf'):
font_files.append(file)
if len(font_files) == 0:
zip_files = []
for file in files:
if file.endswith('.zip'):
zip_files.append(file)
if len(zip_files) == 1:
zip_file = zip_files[0]
zip_file_path = os.path.join(dir_path, zip_file)
os.system(f'unzip {zip_file_path} -d {dir_path}')
print(f"Unzipped {zip_file_path}")