<s> """<STR_LIT>""" <EOL> import os <EOL> import re <EOL> from gcimagebundlelib import linux <EOL> class SUSE ( linux . LinuxPlatform ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( SUSE , self ) . __init__ ( ) <EOL> self . distribution_codename = None <EOL> self . ParseOSRelease ( ) <EOL> if not self . distribution : <EOL> self . ParseSUSERelease ( ) <EOL> if not self . distribution : <EOL> self . distribution = '<STR_LIT>' <EOL> def ParseOSRelease ( self ) : <EOL> """<STR_LIT>""" <EOL> release_file = '<STR_LIT>' <EOL> if not os . path . isfile ( release_file ) : <EOL> self . distribution = None <EOL> return <EOL> lines = open ( release_file , '<STR_LIT:r>' ) . readlines ( ) <EOL> for ln in lines : <EOL> if not ln : <EOL> continue <EOL> if re . match ( r'<STR_LIT>' , ln ) : <EOL> self . distribution = self . __getData ( ln ) <EOL> if re . match ( r'<STR_LIT>' , ln ) : <EOL> self . distribution_version = self . __getData ( ln ) <EOL> if re . match ( r'<STR_LIT>' , ln ) : <EOL> data = self . __getData ( ln ) <EOL> self . distribution_codename = data . split ( '<STR_LIT:(>' ) [ - <NUM_LIT:1> ] [ : - <NUM_LIT:1> ] <EOL> return <EOL> def ParseSUSERelease ( self ) : <EOL> """<STR_LIT>""" <EOL> release_file = '<STR_LIT>' <EOL> if not os . path . isfile ( release_file ) : <EOL> self . distribution = None <EOL> return <EOL> lines = open ( release_file , '<STR_LIT:r>' ) . readlines ( ) <EOL> prts = lines [ <NUM_LIT:0> ] . split ( ) <EOL> cnt = <NUM_LIT:0> <EOL> self . distribution = '<STR_LIT>' <EOL> if len ( prts ) : <EOL> while <NUM_LIT:1> : <EOL> item = prts [ cnt ] <EOL> if re . match ( '<STR_LIT>' , item ) : <EOL> item = None <EOL> break <EOL> elif cnt > <NUM_LIT:0> : <EOL> self . distribution += '<STR_LIT:U+0020>' <EOL> self . distribution += item <EOL> cnt += <NUM_LIT:1> <EOL> for ln in lines : <EOL> if re . match ( r'<STR_LIT>' , ln ) : <EOL> self . distribution_version = self . __getData ( ln ) <EOL> if re . match ( r'<STR_LIT>' , ln ) : <EOL> self . distribution_codename = self . __getData ( ln ) <EOL> return <EOL> def __getData ( self , ln ) : <EOL> """<STR_LIT>""" <EOL> if ln . find ( '<STR_LIT:">' ) != - <NUM_LIT:1> : <EOL> return ln . split ( '<STR_LIT:">' ) [ <NUM_LIT:1> ] <EOL> else : <EOL> return ln . split ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] . strip ( ) </s>
