summaryrefslogtreecommitdiff
path: root/src/scripts/check-definitions.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripts/check-definitions.py')
-rw-r--r--src/scripts/check-definitions.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/scripts/check-definitions.py b/src/scripts/check-definitions.py
index 59b309a3e6..4f1026d4ef 100644
--- a/src/scripts/check-definitions.py
+++ b/src/scripts/check-definitions.py
@@ -33,18 +33,17 @@ debug = 0
# For the native part, return the sorted definition array.
def loadDefinitionFile(filename):
result = []
+
try:
- f = open(filename, 'r')
- except:
+ with open(filename, 'r') as f:
+ for line in f:
+ line = line.strip()
+ if line:
+ result.append(line)
+ except IOError:
+ # If cmake was not used, this script won't work, and that's ok
sys.exit(0)
- # if cmake was not used (because of skipnative or systems that do not use cmake), this script won't work.
-
- for line in f:
- theLine = line.rstrip("\r\n").strip()
- if (len(theLine) > 0):
- result.append(theLine)
- f.close()
result = sorted(result)
return result
@@ -108,9 +107,10 @@ def getDiff(arrNative, arrManaged):
def printPotentiallyCritical(arrDefinitions, referencedFilename, arrIgnore):
- f = open(referencedFilename, 'r')
- content = f.read()
- f.close()
+ content = None
+ with open(referencedFilename, 'r') as f:
+ content = f.read()
+
for keyword in arrDefinitions:
skip = 0