comparison flatpak/build_manifest.py @ 145:9201caf7b2a8

flatpak (build_manifest): don't crash if icon is not specified
author Goffi <goffi@goffi.org>
date Mon, 24 Jun 2019 08:57:12 +0200
parents e23e414987d7
children 64c02902b86a
comparison
equal deleted inserted replaced
144:455f0d305b87 145:9201caf7b2a8
790 return data 790 return data
791 791
792 792
793 def get_icon(): 793 def get_icon():
794 icon = build_settings.get('icon') 794 icon = build_settings.get('icon')
795 if icon is not None: 795 if icon is None:
796 return []
797 else:
796 if isinstance(icon, str): 798 if isinstance(icon, str):
797 icon = {'url': icon} 799 icon = {'url': icon}
798 icon_path = Path(urlparse(icon['url']).path) 800 icon_path = Path(urlparse(icon['url']).path)
799 suffix = icon_path.suffix[1:] 801 suffix = icon_path.suffix[1:]
800 if suffix not in ('svg', 'png'): 802 if suffix not in ('svg', 'png'):
805 else: 807 else:
806 raise ValueError('icon size is not specified, please add a "size" key') 808 raise ValueError('icon size is not specified, please add a "size" key')
807 809
808 dest_path = f"/app/share/icons/hicolor/{icon['size']}/apps/{app_id}.{suffix}" 810 dest_path = f"/app/share/icons/hicolor/{icon['size']}/apps/{app_id}.{suffix}"
809 811
810 return file_from_url( 812 data = file_from_url(
811 url = icon['url'], 813 url = icon['url'],
812 dest = dest_path, 814 dest = dest_path,
813 # we have common cache if several manifest use the same icon URL 815 # we have common cache if several manifest use the same icon URL
814 step_name = f"icon__{icon}", 816 step_name = f"icon__{icon}",
815 step_message = "retrieving application icon", 817 step_message = "retrieving application icon",
816 ) 818 )
819 data[0]['name'] = 'icon'
820 return data
817 821
818 822
819 def generate_appdata_from_template(template_file): 823 def generate_appdata_from_template(template_file):
820 appdata_file = Path(f"{app_id}.appdata.xml") 824 appdata_file = Path(f"{app_id}.appdata.xml")
821 if appdata_file.exists() and not args.force: 825 if appdata_file.exists() and not args.force: