Unverified Commit e92f826a authored by Kai Chen's avatar Kai Chen Committed by GitHub
Browse files

close the config file after opening (#480)

parent cac22f8c
...@@ -88,7 +88,7 @@ class Config: ...@@ -88,7 +88,7 @@ class Config:
@staticmethod @staticmethod
def _validate_py_syntax(filename): def _validate_py_syntax(filename):
with open(filename) as f: with open(filename, 'r') as f:
content = f.read() content = f.read()
try: try:
ast.parse(content) ast.parse(content)
...@@ -107,7 +107,8 @@ class Config: ...@@ -107,7 +107,8 @@ class Config:
fileBasename=file_basename, fileBasename=file_basename,
fileBasenameNoExtension=file_basename_no_extension, fileBasenameNoExtension=file_basename_no_extension,
fileExtname=file_extname) fileExtname=file_extname)
config_file = open(filename).read() with open(filename, 'r') as f:
config_file = f.read()
for key, value in support_templates.items(): for key, value in support_templates.items():
regexp = r'\{\{\s*' + str(key) + r'\s*\}\}' regexp = r'\{\{\s*' + str(key) + r'\s*\}\}'
config_file = re.sub(regexp, value, config_file) config_file = re.sub(regexp, value, config_file)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment