mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
samba_version.py: Avoid resource leak
View with 'git show -b'. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
d8d872e095
commit
fa4ddb887a
@ -235,22 +235,22 @@ also accepted as dictionary entries here
|
||||
def samba_version_file(version_file, path, env=None, is_install=True):
|
||||
'''Parse the version information from a VERSION file'''
|
||||
|
||||
f = open(version_file, 'r')
|
||||
version_dict = {}
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line == '':
|
||||
continue
|
||||
if line.startswith("#"):
|
||||
continue
|
||||
try:
|
||||
split_line = line.split("=")
|
||||
if split_line[1] != "":
|
||||
value = split_line[1].strip('"')
|
||||
version_dict[split_line[0]] = value
|
||||
except:
|
||||
print("Failed to parse line %s from %s" % (line, version_file))
|
||||
raise
|
||||
with open(version_file, 'r') as f:
|
||||
version_dict = {}
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line == '':
|
||||
continue
|
||||
if line.startswith("#"):
|
||||
continue
|
||||
try:
|
||||
split_line = line.split("=")
|
||||
if split_line[1] != "":
|
||||
value = split_line[1].strip('"')
|
||||
version_dict[split_line[0]] = value
|
||||
except:
|
||||
print("Failed to parse line %s from %s" % (line, version_file))
|
||||
raise
|
||||
|
||||
return SambaVersion(version_dict, path, env=env, is_install=is_install)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user