From: Christian Heller Date: Tue, 17 Feb 2015 02:19:10 +0000 (+0100) Subject: Server/py: Minor refactoring. X-Git-Tag: tce~526 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bdb.prefix%7D%7D/condition?a=commitdiff_plain;h=cb8d36c147703b025906b1dc86510ab054095740;p=plomrogue Server/py: Minor refactoring. --- 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):