@@ -200,9 +200,8 @@ def _dist_try_harder(distname,version,id):
200200 """
201201 if os .path .exists ('/var/adm/inst-log/info' ):
202202 # SuSE Linux stores distribution information in that file
203- info = open ('/var/adm/inst-log/info' ).readlines ()
204203 distname = 'SuSE'
205- for line in info :
204+ for line in open ( '/var/adm/inst-log/ info' ) :
206205 tv = line .split ()
207206 if len (tv ) == 2 :
208207 tag ,value = tv
@@ -217,8 +216,7 @@ def _dist_try_harder(distname,version,id):
217216
218217 if os .path .exists ('/etc/.installed' ):
219218 # Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
220- info = open ('/etc/.installed' ).readlines ()
221- for line in info :
219+ for line in open ('/etc/.installed' ):
222220 pkg = line .split ('-' )
223221 if len (pkg ) >= 2 and pkg [0 ] == 'OpenLinux' :
224222 # XXX does Caldera support non Intel platforms ? If yes,
@@ -327,9 +325,8 @@ def linux_distribution(distname='', version='', id='',
327325 return _dist_try_harder (distname ,version ,id )
328326
329327 # Read the first line
330- f = open ('/etc/' + file , 'r' )
331- firstline = f .readline ()
332- f .close ()
328+ with open ('/etc/' + file , 'r' ) as f :
329+ firstline = f .readline ()
333330 _distname , _version , _id = _parse_release_file (firstline )
334331
335332 if _distname and full_distribution_name :
0 commit comments