Updated font files locations functions to match

This commit is contained in:
Matt Troutman 2024-09-27 09:04:10 -05:00
parent e0b582e104
commit 9f5dca1277
No known key found for this signature in database

View file

@ -2,6 +2,8 @@ import os
import time import time
from fileinput import filename from fileinput import filename
font_location = '/Users/fishy/custom_fonts/font_files'
bad_phrases = [' Free', bad_phrases = [' Free',
'TBJ ', 'TBJ ',
' - Zarma Type', ' - Zarma Type',
@ -33,7 +35,7 @@ bad_phrases = [' Free',
'Non-Commercial Use', 'Non-Commercial Use',
] ]
def remove_ds_store_files(path): def remove_ds_store_files(path=font_location):
""" """
Recursively removes .DS_Store files within the given path. Recursively removes .DS_Store files within the given path.
@ -50,7 +52,7 @@ def remove_ds_store_files(path):
os.remove(file_path) os.remove(file_path)
print(f"Removed .DS_Store file: {file_path}") print(f"Removed .DS_Store file: {file_path}")
def remove_empty_folders(path): def remove_empty_folders(path=font_location):
""" """
Recursively removes empty directories within the given path, except for .git and .env directories and their subdirectories. Recursively removes empty directories within the given path, except for .git and .env directories and their subdirectories.
@ -70,7 +72,7 @@ def remove_empty_folders(path):
print(f"Removed empty folder: {dir_path}") print(f"Removed empty folder: {dir_path}")
# Usage # Usage
def remove_bad_phrases(path): def remove_bad_phrases(path=font_location):
""" """
Recursively removes bad phrases from the names of directories at the root of the given path. Recursively removes bad phrases from the names of directories at the root of the given path.
@ -97,7 +99,7 @@ def remove_bad_phrases(path):
break break
# time.sleep(1) # Delay to allow the file system to settle # time.sleep(1) # Delay to allow the file system to settle
def collect_orphaned_fonts(path): def collect_orphaned_fonts(path=font_location):
""" """
Collects orphaned font files at the root of the given path. Collects orphaned font files at the root of the given path.
@ -124,7 +126,7 @@ def collect_orphaned_fonts(path):
return orphaned_fonts return orphaned_fonts
def lowercase_all_the_folders(root_path): def lowercase_all_the_folders(root_path=font_location):
""" """
Lowercases all the folders in the root path, except those starting with a period. Lowercases all the folders in the root path, except those starting with a period.
@ -177,7 +179,7 @@ def add_font_folders_to_each(root_path):
new_file_path = os.path.join(new_dir_path, file) new_file_path = os.path.join(new_dir_path, file)
os.rename(os.path.join(dir_path, file), new_file_path) os.rename(os.path.join(dir_path, file), new_file_path)
def unzip_if_no_fonts(root_path): def unzip_if_no_fonts(root_path=font_location):
#if there are no font files, find the zip file and unzip it #if there are no font files, find the zip file and unzip it
for dir in os.listdir(root_path): for dir in os.listdir(root_path):
dir_path = os.path.join(root_path, dir) dir_path = os.path.join(root_path, dir)
@ -206,12 +208,11 @@ def unzip_if_no_fonts(root_path):
if __name__ == '__main__': if __name__ == '__main__':
remove_ds_store_files()
remove_ds_store_files('/Users/fishy/custom_fonts/') remove_empty_folders()
remove_empty_folders('/Users/fishy/custom_fonts/') remove_bad_phrases()
# remove_bad_phrases('/Users/fishy/custom_fonts/') collect_orphaned_fonts()
# collect_orphaned_fonts('/Users/fishy/custom_fonts/') lowercase_all_the_folders()
# lowercase_all_the_folders('/Users/fishy/custom_fonts/') add_font_folders_to_each()
# add_font_folders_to_each('/Users/fishy/custom_fonts/') remove_ds_store_files()
# remove_ds_store_files('/Users/fishy/custom_fonts/') remove_empty_folders()
# remove_empty_folders('/Users/fishy/custom_fonts/')