From 76890bff809cb469711ffc4ce6c3149084675ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Gra=C4=8Danin?= <35041118+mgracanin@users.noreply.github.com> Date: Thu, 27 Jul 2023 22:26:44 +0200 Subject: [PATCH] Update __init__.py --- __init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/__init__.py b/__init__.py index bf46d71..245c98e 100644 --- a/__init__.py +++ b/__init__.py @@ -8,14 +8,18 @@ ASCII Art from https://www.asciimation.co.nz/ starwars_file_path = (f"{Path(__file__).parent}/starwars.txt") async def main(): - LPS = 14 ## Linija po frameu + LPS = 14 ## Lines per frame + + if os.path.exists(starwars_file_path): + with open(starwars_file_path, 'r') as f: + podaci = f.read().split('\n') + print('\n' * LPS) + else: + print(f"File {starwars_file_path} does not exist. Make sure file is in the same directory as this script.") + sys.exit(1) - with open(starwars_file_path, 'r') as f: - podaci = f.read().split('\n') - print('\n' * LPS) - for i in range(0, len(podaci), LPS): - print("\x1b[{}A\x1b[J{}".format(LPS, '\n'.join(podaci[i + 1:i + LPS]))) # \x1b[{}A\x1b[J pomičemo ESC char 14 linija + print("\x1b[{}A\x1b[J{}".format(LPS, '\n'.join(podaci[i + 1:i + LPS]))) # \x1b[{}A\x1b[J move ESC char 14 lines await sleep(int(podaci[i]) * 67 / 1000) ## Delay = 67 if __name__ == '__main__':