From 3ecc980fb1c950e90665c13385c401a7b07ca110 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Wed, 21 Jul 2021 23:27:40 +0300 Subject: [PATCH] add check logo exist --- .gitignore | 2 ++ assm/__init__.py | 2 +- assm/__main__.py | 17 ++++++++++++++--- pyproject.toml | 10 +++------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 6eb93ba..e56d641 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ venv/ dist/ assm/__pycache__ +images/ +logo.png diff --git a/assm/__init__.py b/assm/__init__.py index ad9d943..bf267a2 100644 --- a/assm/__init__.py +++ b/assm/__init__.py @@ -1,3 +1,3 @@ """iOS splash screen generator""" -__version__ = "0.1.1" +__version__ = "0.1.2" diff --git a/assm/__main__.py b/assm/__main__.py index 03a212c..6df6235 100644 --- a/assm/__main__.py +++ b/assm/__main__.py @@ -19,7 +19,14 @@ def make_splash_image(screen_orientation, screen_width, screen_height, logo_path splash_image = Image.new('RGB', (screen_width, screen_height), (255, 255, 255)) logo_image = Image.open(logo_path) app_logo = logo_image.resize((logo_size, logo_size)) - splash_image.paste(app_logo, (logo_w_pos, logo_h_pos), app_logo) + + try: + splash_image.paste(app_logo, (logo_w_pos, logo_h_pos), app_logo) + except ValueError as e: + if str(e) == 'bad transparency mask': + print('ERROR: Bad transparency mask.') + + quit(-1) return splash_image @@ -42,10 +49,14 @@ def main(output_folder='./images/'): f=output_folder, w=device_w, h=device_h ) - splash = make_splash_image('portrait', device_w, device_h, 'logo.png') + try: + splash = make_splash_image('portrait', device_w, device_h, 'logo.png') + except FileNotFoundError as e: + print('ERROR: File logo.png not found.') + quit(1) splash.save(file_name) - print('..splash for {w}x{h} saved...'.format(w=device_w, h=device_h)) + print('...splash for {w}x{h} saved...'.format(w=device_w, h=device_h)) # landscape print('Generate landscape splash...') diff --git a/pyproject.toml b/pyproject.toml index 627217b..d35c100 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,24 +7,20 @@ module = "assm" author = "Alexander Popov" author-email = "iiiypuk@iiiypuk.me" home-page = "https://github.com/emilecok/assm" -requires = ["Pillow==8.1.0" ] +requires = ["Pillow==8.3.1" ] description-file = "README.md" classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3" ] requires-python = ">=3" -keywords = [ - "iOS", - "splashscreen", - "splash-screen" -] +keywords = "iOS,splashscreen,splash-screen" [tool.flit.metadata.requires-extra] dev = ["pylint == 2.7.1", "black == 20.8b1"] [tool.flit.metadata.urls] -Documentation = "" +Documentation = "https://docs/" [tool.black] line-length = 99