Create common.LoadDictionaryFromFile

There are some places defining same file open function and use
common.LoadDictionaryFromLines. This commit creates
LoadDictionaryFromFile to reduce some code redundancy.

Test: m -j & atest passed
Change-Id: I6a3fa48693095937f8c79ce6f3c110b6862a1967
This commit is contained in:
Kiyoung Kim
2019-06-25 17:09:55 +09:00
parent 4daa755fb2
commit ebe7c9c92f
2 changed files with 24 additions and 28 deletions

View File

@@ -455,6 +455,13 @@ def LoadBuildProp(read_helper, prop_file):
return LoadDictionaryFromLines(data.split("\n"))
def LoadDictionaryFromFile(file_path):
with open(file_path) as f:
lines = list(f.read().splitlines())
return LoadDictionaryFromLines(lines)
def LoadDictionaryFromLines(lines):
d = {}
for line in lines: