Skip to content

Instantly share code, notes, and snippets.

@osfunapps
Created April 4, 2020 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osfunapps/f6d0253010aaf298b9b6ed981e31adee to your computer and use it in GitHub Desktop.
Save osfunapps/f6d0253010aaf298b9b6ed981e31adee to your computer and use it in GitHub Desktop.
Will copy a main dir of colors to respected dirs
from os_tools import FileHandler as fh
COLORS_MAIN_DIR = '/Users/home/Desktop/work/Apps/untitled folder/main_dir_fixed_colors'
COLORS_TO_INJECT_MAIN_DIR = '/Users/home/Desktop/work/Apps/untitled folder/no_good_color_apps'
# fetch all of the color xml files from the colors main dir
color_xmls = fh.search_files(COLORS_MAIN_DIR, 'dynamic_colors.xml')
# fetch all of the dirs to run on
app_dir_list = fh.get_dir_content(COLORS_TO_INJECT_MAIN_DIR, False, True, False)
# run on all of the color xmls
for color_xml in color_xmls:
is_color_found = False
color_parent_dir = fh.get_parent_path(color_xml)
color_parent_dir_name = fh.get_dir_name(color_parent_dir)
# run on all of the dirs in the app files
for app_dir in app_dir_list:
app_dir_name = fh.get_dir_name(app_dir)
# if parent dir is the same, copy xml file
if app_dir_name == color_parent_dir_name:
fh.copy_file(color_xml, app_dir)
is_color_found = True
print("copied " + color_xml + " to: " + app_dir)
break
if not is_color_found:
print("ERROR: Couldn't find an app dir for the color: " + color_xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment