From cb8d36c147703b025906b1dc86510ab054095740 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 17 Feb 2015 03:19:10 +0100 Subject: [PATCH] Server/py: Minor refactoring. --- plomrogue-server.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plomrogue-server.py b/plomrogue-server.py index 0123597..324888f 100755 --- a/plomrogue-server.py +++ b/plomrogue-server.py @@ -36,15 +36,13 @@ def setup_server_io(io_db): def cleanup_server_io(io_db): """Close and remove all files open in IO files DB.""" - if "file_out" in io_db: - io_db["file_out"].close() - os.remove(io_db["path_out"]) - if "file_in" in io_db: - io_db["file_in"].close() - os.remove(io_db["path_in"]) - if "file_worldstate" in io_db: - io_db["file_worldstate"].close() - os.remove(io_db["path_worldstate"]) + def helper(file_key, path_key): + if file_key in io_db: + io_db[file_key].close() + os.remove(io_db[path_key]) + helper("file_out", "path_out") + helper("file_in", "path_in") + helper("file_worldstate", "path_worldstate") def detect_atomic_leftover(path): -- 2.30.2