-def extract_apk_icons(icon_filename, apk, apk_zip, repo_dir):
+def extract_apk_icons(icon_filename, apk, apkzip, repo_dir):
"""
Extracts icons from the given APK zip in various densities,
saves them into given repo directory
"""
Extracts icons from the given APK zip in various densities,
saves them into given repo directory
:param icon_filename: A string representing the icon's file name
:param apk: A populated dictionary containing APK metadata.
Needs to have 'icons_src' key
:param icon_filename: A string representing the icon's file name
:param apk: A populated dictionary containing APK metadata.
Needs to have 'icons_src' key
:param repo_dir: The directory of the APK's repository
:return: A list of icon densities that are missing
"""
:param repo_dir: The directory of the APK's repository
:return: A list of icon densities that are missing
"""
# Extract the icon files per density
try:
with open(icon_dest, 'wb') as f:
# Extract the icon files per density
try:
with open(icon_dest, 'wb') as f:
apk['icons'][density] = icon_filename
except (zipfile.BadZipFile, ValueError, KeyError) as e:
logging.warning("Error retrieving icon file: %s %s", icon_dest, e)
apk['icons'][density] = icon_filename
except (zipfile.BadZipFile, ValueError, KeyError) as e:
logging.warning("Error retrieving icon file: %s %s", icon_dest, e)
icon_src = apk['icons_src']['-1']
icon_path = os.path.join(get_icon_dir(repo_dir, '0'), icon_filename)
with open(icon_path, 'wb') as f:
icon_src = apk['icons_src']['-1']
icon_path = os.path.join(get_icon_dir(repo_dir, '0'), icon_filename)
with open(icon_path, 'wb') as f: