summaryrefslogtreecommitdiffstats
path: root/base/server/src/engine/pkiparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'base/server/src/engine/pkiparser.py')
-rw-r--r--base/server/src/engine/pkiparser.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/base/server/src/engine/pkiparser.py b/base/server/src/engine/pkiparser.py
index 6a94e3827..8c9b6d620 100644
--- a/base/server/src/engine/pkiparser.py
+++ b/base/server/src/engine/pkiparser.py
@@ -208,22 +208,21 @@ class PKIConfigParser:
@staticmethod
def read_simple_configuration_file(filename):
values = {}
- f = open(filename)
- for line in f:
- # First, remove comments:
- if PKIConfigParser.COMMENT_CHAR in line:
- # split on comment char, keep only the part before
- line, comment = line.split(PKIConfigParser.COMMENT_CHAR, 1)
- # Second, find lines with an name=value:
- if PKIConfigParser.OPTION_CHAR in line:
- # split on name char:
- name, value = line.split(PKIConfigParser.OPTION_CHAR, 1)
- # strip spaces:
- name = name.strip()
- value = value.strip()
- # store in dictionary:
- values[name] = value
- f.close()
+ with open(filename) as f:
+ for line in f:
+ # First, remove comments:
+ if PKIConfigParser.COMMENT_CHAR in line:
+ # split on comment char, keep only the part before
+ line, comment = line.split(PKIConfigParser.COMMENT_CHAR, 1)
+ # Second, find lines with an name=value:
+ if PKIConfigParser.OPTION_CHAR in line:
+ # split on name char:
+ name, value = line.split(PKIConfigParser.OPTION_CHAR, 1)
+ # strip spaces:
+ name = name.strip()
+ value = value.strip()
+ # store in dictionary:
+ values[name] = value
return values