Replace remaining file() usage

This commit is contained in:
Daniel Martí 2016-01-04 17:59:47 +01:00
parent 5026d4e08b
commit fc21dbc667
2 changed files with 42 additions and 38 deletions

View file

@ -1013,7 +1013,8 @@ def get_library_references(root_dir):
proppath = os.path.join(root_dir, 'project.properties')
if not os.path.isfile(proppath):
return libraries
for line in file(proppath):
with open(proppath, 'r') as f:
for line in f:
if not line.startswith('android.library.reference.'):
continue
path = line.split('=')[1].strip()
@ -1087,7 +1088,8 @@ def parse_androidmanifests(paths, app):
package = None
if gradle:
for line in file(path):
with open(path, 'r') as f:
for line in f:
if gradle_comment.match(line):
continue
# Grab first occurence of each to avoid running into
@ -1531,7 +1533,8 @@ class KnownApks:
self.path = os.path.join('stats', 'known_apks.txt')
self.apks = {}
if os.path.isfile(self.path):
for line in file(self.path):
with open(self.path, 'r') as f:
for line in f:
t = line.rstrip().split(' ')
if len(t) == 2:
self.apks[t[0]] = (t[1], None)

View file

@ -199,7 +199,8 @@ def scan_source(build_dir, root_dir, build):
elif ext == 'java':
if not os.path.isfile(fp):
continue
for line in file(fp):
with open(fp, 'r') as f:
for line in f:
if 'DexClassLoader' in line:
count += handleproblem('DexClassLoader', fd, fp)
break