<s> """<STR_LIT>""" <EOL> class Version ( tuple ) : <EOL> def __new__ ( cls , * version ) : <EOL> padded_version = cls . _padded ( version , <NUM_LIT:4> ) <EOL> return super ( Version , cls ) . __new__ ( cls , tuple ( padded_version ) ) <EOL> @ classmethod <EOL> def _padded ( cls , iter , length , padding = <NUM_LIT:0> ) : <EOL> l = list ( iter ) <EOL> if len ( l ) < length : <EOL> for _ in range ( length - len ( l ) ) : <EOL> l . append ( padding ) <EOL> return l <EOL> @ classmethod <EOL> def from_string ( cls , version_string ) : <EOL> mod = <NUM_LIT:0> <EOL> bump_patch_level = False <EOL> if version_string . endswith ( "<STR_LIT:+>" ) : <EOL> version_string = version_string [ <NUM_LIT:0> : - <NUM_LIT:1> ] <EOL> mod = <NUM_LIT:1> <EOL> elif version_string . endswith ( "<STR_LIT>" ) : <EOL> version_string = version_string [ <NUM_LIT:0> : - <NUM_LIT:5> ] <EOL> mod = - <NUM_LIT:1> <EOL> elif version_string . endswith ( "<STR_LIT:->" ) : <EOL> version_string = version_string [ <NUM_LIT:0> : - <NUM_LIT:1> ] <EOL> mod = - <NUM_LIT:1> <EOL> if '<STR_LIT>' in version_string : <EOL> version_string = version_string [ <NUM_LIT:0> : version_string . find ( '<STR_LIT>' ) ] <EOL> mod = - <NUM_LIT:1> <EOL> elif '<STR_LIT:->' in version_string : <EOL> version_string = version_string [ <NUM_LIT:0> : version_string . find ( '<STR_LIT:->' ) ] <EOL> mod = - <NUM_LIT:1> <EOL> bump_patch_level = True <EOL> version = [ int ( part ) for part in version_string . split ( "<STR_LIT:.>" ) ] <EOL> version = cls . _padded ( version , <NUM_LIT:3> ) <EOL> if bump_patch_level : <EOL> version [ - <NUM_LIT:1> ] += <NUM_LIT:1> <EOL> version . append ( mod ) <EOL> return Version ( * version ) <EOL> @ classmethod <EOL> def from_version_array ( cls , version_array ) : <EOL> version = list ( version_array ) <EOL> if version [ - <NUM_LIT:1> ] < <NUM_LIT:0> : <EOL> version [ - <NUM_LIT:1> ] = - <NUM_LIT:1> <EOL> version = cls . _padded ( version , <NUM_LIT:3> ) <EOL> return Version ( * version ) <EOL> @ classmethod <EOL> def from_client ( cls , client ) : <EOL> info = client . server_info ( ) <EOL> if '<STR_LIT>' in info : <EOL> return cls . from_version_array ( info [ '<STR_LIT>' ] ) <EOL> return cls . from_string ( info [ '<STR_LIT:version>' ] ) <EOL> def at_least ( self , * other_version ) : <EOL> return self >= Version ( * other_version ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:.>" . join ( map ( str , self ) ) </s>
