From 9643318c9331a1d6c6acf4c2509cdb110971e416 Mon Sep 17 00:00:00 2001 From: Andrew Krasichkov Date: Fri, 19 May 2017 19:31:39 +0300 Subject: [PATCH] Checks file existing before opening by parser (#52) --- gixy/parser/nginx_parser.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gixy/parser/nginx_parser.py b/gixy/parser/nginx_parser.py index 14f960d..83ad06b 100644 --- a/gixy/parser/nginx_parser.py +++ b/gixy/parser/nginx_parser.py @@ -110,14 +110,17 @@ class NginxParser(object): def _resolve_file_include(self, pattern, parent): path = os.path.join(self.cwd, pattern) - file_path = None + exists = False for file_path in glob.iglob(path): + if not os.path.exists(file_path): + continue + exists = True include = block.IncludeBlock('include', [file_path]) parent.append(include) self.parse_file(file_path, include) - if not file_path: - LOG.warning("File not found: {0}".format(path)) + if not exists: + LOG.warning('File not found: {0}'.format(path)) def _resolve_dump_include(self, pattern, parent): path = os.path.join(self.cwd, pattern)