From 2d3154582f073a9b0cdcda44d1e3dbf67d1ff703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Wed, 13 Jun 2018 14:48:48 +0200 Subject: [PATCH] Fix pylint issues in "genio"/"log_file" and warn about it's issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "genio"/"log_file" is quite dangerous and requires using private members of "genio" module. Unfortunatelly "Avocado-vt" heavily depends on this so let's just fix style issues and add docstrings explaining the issues. Signed-off-by: Lukáš Doktor --- aexpect/utils/genio.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/aexpect/utils/genio.py b/aexpect/utils/genio.py index 27f764f..0f423e8 100644 --- a/aexpect/utils/genio.py +++ b/aexpect/utils/genio.py @@ -9,18 +9,29 @@ # # See LICENSE for more details. +""" +Naive module that keeps tacks of some opened files and somehow manages them. +""" + import os -_open_log_files = {} +# This variable is used from Avocado-vt +_open_log_files = {} # pylint: disable=C0103 def close_log_file(filename): + + """ + This closes all files that use the same "filename" (not just path, but + really just "basename(filename)". + """ + remove = [] - for k in _open_log_files: - if os.path.basename(k) == filename: - f = _open_log_files[k] - f.close() - remove.append(k) + for log_file in _open_log_files: + if os.path.basename(log_file) == filename: + log_fd = _open_log_files[log_file] + log_fd.close() + remove.append(log_file) if remove: for key_to_remove in remove: _open_log_files.pop(key_to_remove)