Updated font files locations functions to match
This commit is contained in:
parent
e0b582e104
commit
9f5dca1277
1 changed files with 16 additions and 15 deletions
|
|
@ -2,6 +2,8 @@ import os
|
|||
import time
|
||||
from fileinput import filename
|
||||
|
||||
font_location = '/Users/fishy/custom_fonts/font_files'
|
||||
|
||||
bad_phrases = [' Free',
|
||||
'TBJ ',
|
||||
' - Zarma Type',
|
||||
|
|
@ -33,7 +35,7 @@ bad_phrases = [' Free',
|
|||
'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.
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ def remove_ds_store_files(path):
|
|||
os.remove(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.
|
||||
|
||||
|
|
@ -70,7 +72,7 @@ def remove_empty_folders(path):
|
|||
print(f"Removed empty folder: {dir_path}")
|
||||
|
||||
# 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.
|
||||
|
||||
|
|
@ -97,7 +99,7 @@ def remove_bad_phrases(path):
|
|||
break
|
||||
# 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.
|
||||
|
||||
|
|
@ -124,7 +126,7 @@ def collect_orphaned_fonts(path):
|
|||
|
||||
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.
|
||||
|
||||
|
|
@ -177,7 +179,7 @@ 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):
|
||||
def unzip_if_no_fonts(root_path=font_location):
|
||||
#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)
|
||||
|
|
@ -206,12 +208,11 @@ def unzip_if_no_fonts(root_path):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
remove_ds_store_files('/Users/fishy/custom_fonts/')
|
||||
remove_empty_folders('/Users/fishy/custom_fonts/')
|
||||
# remove_bad_phrases('/Users/fishy/custom_fonts/')
|
||||
# collect_orphaned_fonts('/Users/fishy/custom_fonts/')
|
||||
# lowercase_all_the_folders('/Users/fishy/custom_fonts/')
|
||||
# add_font_folders_to_each('/Users/fishy/custom_fonts/')
|
||||
# remove_ds_store_files('/Users/fishy/custom_fonts/')
|
||||
# remove_empty_folders('/Users/fishy/custom_fonts/')
|
||||
remove_ds_store_files()
|
||||
remove_empty_folders()
|
||||
remove_bad_phrases()
|
||||
collect_orphaned_fonts()
|
||||
lowercase_all_the_folders()
|
||||
add_font_folders_to_each()
|
||||
remove_ds_store_files()
|
||||
remove_empty_folders()
|
||||
Loading…
Add table
Add a link
Reference in a new issue