<s> """<STR_LIT>""" <EOL> from pkg_resources import get_supported_platform <EOL> from . platforms import Platform <EOL> class PEP425Extras ( object ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def is_macosx_platform ( cls , platform ) : <EOL> return platform . startswith ( '<STR_LIT>' ) <EOL> @ classmethod <EOL> def parse_macosx_tag ( cls , platform_tag ) : <EOL> invalid_tag = ValueError ( '<STR_LIT>' % platform_tag ) <EOL> if not cls . is_macosx_platform ( platform_tag ) : <EOL> raise invalid_tag <EOL> segments = platform_tag . split ( '<STR_LIT:_>' , <NUM_LIT:3> ) <EOL> if len ( segments ) != <NUM_LIT:4> : <EOL> raise invalid_tag <EOL> if segments [ <NUM_LIT:0> ] != '<STR_LIT>' : <EOL> raise invalid_tag <EOL> try : <EOL> major , minor = int ( segments [ <NUM_LIT:1> ] ) , int ( segments [ <NUM_LIT:2> ] ) <EOL> platform = segments [ <NUM_LIT:3> ] <EOL> except ValueError : <EOL> raise invalid_tag <EOL> return major , minor , platform <EOL> @ classmethod <EOL> def iter_compatible_osx_platforms ( cls , supported_platform ) : <EOL> platform_major , platform_minor , platform = cls . parse_macosx_tag ( supported_platform ) <EOL> platform_equivalents = set ( Platform . MACOSX_PLATFORM_COMPATIBILITY . get ( platform , ( ) ) ) <EOL> platform_equivalents . add ( platform ) <EOL> for minor in range ( platform_minor , - <NUM_LIT:1> , - <NUM_LIT:1> ) : <EOL> for binary_compat in platform_equivalents : <EOL> yield '<STR_LIT>' % ( platform_major , minor , binary_compat ) <EOL> @ classmethod <EOL> def platform_iterator ( cls , platform ) : <EOL> """<STR_LIT>""" <EOL> if cls . is_macosx_platform ( platform ) : <EOL> for plat in cls . iter_compatible_osx_platforms ( platform ) : <EOL> yield plat <EOL> else : <EOL> yield platform <EOL> class PEP425 ( object ) : <EOL> INTERPRETER_TAGS = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> @ classmethod <EOL> def get_implementation_tag ( cls , interpreter_subversion ) : <EOL> return cls . INTERPRETER_TAGS . get ( interpreter_subversion ) <EOL> @ classmethod <EOL> def get_version_tag ( cls , interpreter_version ) : <EOL> return '<STR_LIT>' . join ( map ( str , interpreter_version [ : <NUM_LIT:2> ] ) ) <EOL> @ classmethod <EOL> def translate_platform_to_tag ( cls , platform ) : <EOL> return platform . replace ( '<STR_LIT:.>' , '<STR_LIT:_>' ) . replace ( '<STR_LIT:->' , '<STR_LIT:_>' ) <EOL> @ classmethod <EOL> def get_platform_tag ( cls ) : <EOL> return cls . translate_platform_to_tag ( get_supported_platform ( ) ) <EOL> @ classmethod <EOL> def _iter_supported_tags ( cls , impl , version , platform ) : <EOL> """<STR_LIT>""" <EOL> abis = [ ] <EOL> if impl == '<STR_LIT>' and ( version . startswith ( '<STR_LIT:2>' ) or version . startswith ( '<STR_LIT:3>' ) ) : <EOL> abis . extend ( [ <EOL> '<STR_LIT>' % version , <EOL> '<STR_LIT>' % version , '<STR_LIT>' % version , '<STR_LIT>' % version , '<STR_LIT>' % version , <EOL> '<STR_LIT>' % version , '<STR_LIT>' % version , <EOL> '<STR_LIT>' % version <EOL> ] ) <EOL> if version . startswith ( '<STR_LIT:3>' ) : <EOL> abis . extend ( [ <EOL> '<STR_LIT>' <EOL> ] ) <EOL> major_version = int ( version [ <NUM_LIT:0> ] ) <EOL> minor_versions = [ ] <EOL> for minor in range ( int ( version [ <NUM_LIT:1> ] ) , - <NUM_LIT:1> , - <NUM_LIT:1> ) : <EOL> minor_versions . append ( '<STR_LIT>' % ( major_version , minor ) ) <EOL> platforms = list ( PEP425Extras . platform_iterator ( cls . translate_platform_to_tag ( platform ) ) ) <EOL> for p in platforms : <EOL> for abi in abis : <EOL> yield ( '<STR_LIT>' % ( impl , version ) , abi , p ) <EOL> for p in platforms + [ '<STR_LIT>' ] : <EOL> for i in ( '<STR_LIT>' , impl ) : <EOL> yield ( '<STR_LIT>' % ( i , major_version ) , '<STR_LIT:none>' , p ) <EOL> for minor_version in minor_versions : <EOL> yield ( '<STR_LIT>' % ( i , minor_version ) , '<STR_LIT:none>' , p ) <EOL> @ classmethod <EOL> def iter_supported_tags ( cls , identity , platform = get_supported_platform ( ) ) : <EOL> """<STR_LIT>""" <EOL> impl_tag = cls . get_implementation_tag ( identity . interpreter ) <EOL> vers_tag = cls . get_version_tag ( identity . version ) <EOL> tag_iterator = cls . _iter_supported_tags ( impl_tag , vers_tag , platform ) <EOL> for tag in tag_iterator : <EOL> yield tag </s>
