<s> from __future__ import absolute_import <EOL> import re <EOL> import sys <EOL> from pkg_resources import compatible_platforms , get_supported_platform <EOL> class Platform ( object ) : <EOL> class UnknownPlatformError ( Exception ) : <EOL> def __init__ ( self , platform ) : <EOL> super ( Platform . UnknownPlatformError , self ) . __init__ ( '<STR_LIT>' % platform ) <EOL> MACOSX_VERSION_STRING = re . compile ( r"<STR_LIT>" ) <EOL> MACOSX_PLATFORM_COMPATIBILITY = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> @ staticmethod <EOL> def current ( ) : <EOL> return get_supported_platform ( ) <EOL> @ staticmethod <EOL> def python ( ) : <EOL> return sys . version [ : <NUM_LIT:3> ] <EOL> @ classmethod <EOL> def compatible ( cls , package , platform ) : <EOL> if package is None or platform is None or package == platform : <EOL> return True <EOL> MAJOR , MINOR , PLATFORM = range ( <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> package_match = cls . MACOSX_VERSION_STRING . match ( package ) <EOL> platform_match = cls . MACOSX_VERSION_STRING . match ( platform ) <EOL> if not ( package_match and platform_match ) : <EOL> return compatible_platforms ( package , platform ) <EOL> if package_match . group ( MAJOR ) != platform_match . group ( MAJOR ) : <EOL> return False <EOL> if int ( package_match . group ( MINOR ) ) > int ( platform_match . group ( MINOR ) ) : <EOL> return False <EOL> package_platform = package_match . group ( PLATFORM ) <EOL> if package_platform not in cls . MACOSX_PLATFORM_COMPATIBILITY : <EOL> raise cls . UnknownPlatformError ( package_platform ) <EOL> sys_platform = platform_match . group ( PLATFORM ) <EOL> if sys_platform not in cls . MACOSX_PLATFORM_COMPATIBILITY : <EOL> raise cls . UnknownPlatformError ( sys_platform ) <EOL> package_compatibility = set ( cls . MACOSX_PLATFORM_COMPATIBILITY [ package_platform ] ) <EOL> system_compatibility = set ( cls . MACOSX_PLATFORM_COMPATIBILITY [ sys_platform ] ) <EOL> return bool ( package_compatibility . intersection ( system_compatibility ) ) <EOL> @ staticmethod <EOL> def version_compatible ( package_py_version , py_version ) : <EOL> return package_py_version is None or py_version is None or package_py_version == py_version </s>
