From f5390b931074fc4c95572fcdff86888280d295bc Mon Sep 17 00:00:00 2001 From: Geoffrey ROYER Date: Fri, 7 Jun 2019 23:13:21 +0200 Subject: [PATCH 1/2] Enhance script --- dummycharaviewer.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/dummycharaviewer.py b/dummycharaviewer.py index ad5e7b7..b40d526 100755 --- a/dummycharaviewer.py +++ b/dummycharaviewer.py @@ -4,19 +4,17 @@ import sys import struct - -source = sys.argv[-1] expected_magic_word = 0xdeadface -def check_magic_word(): +def check_magic_word(dat_file): magic_word = struct.unpack("") + raise SystemExit(-1) + + source = argv[1] + with open(source, "rb") as dat_file: + check_magic_word(dat_file) + read_character_name(dat_file) + read_filename(dat_file) + read_coordinates(dat_file) + raise SystemExit(0) + + +if __name__ == "__main__": + main(sys.argv) From 6e6dd04a9a4441220b3bb03d5a9a620e3e6248e5 Mon Sep 17 00:00:00 2001 From: Geoffrey ROYER Date: Fri, 7 Jun 2019 23:17:09 +0200 Subject: [PATCH 2/2] Assign variables through list comprehension --- dummycharaviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dummycharaviewer.py b/dummycharaviewer.py index b40d526..5779213 100755 --- a/dummycharaviewer.py +++ b/dummycharaviewer.py @@ -32,7 +32,7 @@ def read_filename(dat_file): def read_coordinates(dat_file): coordinates = struct.unpack("<2H", dat_file.read(4)) - x, y = coordinates[0], coordinates[1] + x, y = coordinates map_name_length = struct.unpack("