<s> import os <EOL> import sys <EOL> import time <EOL> import imp <EOL> def shortPythonVersion ( ) : <EOL> hv = sys . hexversion <EOL> major = ( hv & <NUM_LIT> L ) >> <NUM_LIT> <EOL> minor = ( hv & <NUM_LIT> L ) >> <NUM_LIT:16> <EOL> teeny = ( hv & <NUM_LIT> L ) >> <NUM_LIT:8> <EOL> return "<STR_LIT>" % ( major , minor , teeny ) <EOL> knownPlatforms = { <EOL> '<STR_LIT>' : '<STR_LIT:win32>' , <EOL> '<STR_LIT>' : '<STR_LIT:win32>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> _timeFunctions = { <EOL> '<STR_LIT:win32>' : time . time , <EOL> } <EOL> class Platform : <EOL> """<STR_LIT>""" <EOL> type = knownPlatforms . get ( os . name ) <EOL> seconds = staticmethod ( _timeFunctions . get ( type , time . time ) ) <EOL> def __init__ ( self , name = None ) : <EOL> if name is not None : <EOL> self . type = knownPlatforms . get ( name ) <EOL> self . seconds = _timeFunctions . get ( self . type , time . time ) <EOL> def isKnown ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . type != None <EOL> def getType ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . type <EOL> def isMacOSX ( self ) : <EOL> """<STR_LIT>""" <EOL> return sys . platform == "<STR_LIT>" <EOL> def isWinNT ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . getType ( ) == '<STR_LIT:win32>' : <EOL> import _winreg <EOL> try : <EOL> k = _winreg . OpenKeyEx ( _winreg . HKEY_LOCAL_MACHINE , <EOL> r'<STR_LIT>' ) <EOL> _winreg . QueryValueEx ( k , '<STR_LIT>' ) <EOL> return <NUM_LIT:1> <EOL> except WindowsError : <EOL> return <NUM_LIT:0> <EOL> return <NUM_LIT:0> <EOL> def isWindows ( self ) : <EOL> return self . getType ( ) == '<STR_LIT:win32>' <EOL> def isVista ( self ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( sys , "<STR_LIT>" , None ) is not None : <EOL> return sys . getwindowsversion ( ) [ <NUM_LIT:0> ] == <NUM_LIT:6> <EOL> else : <EOL> return False <EOL> def supportsThreads ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return imp . find_module ( '<STR_LIT>' ) [ <NUM_LIT:0> ] is None <EOL> except ImportError : <EOL> return False <EOL> def supportsINotify ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> from twisted . python . _inotify import INotifyError , init <EOL> except ImportError : <EOL> return False <EOL> try : <EOL> os . close ( init ( ) ) <EOL> except INotifyError : <EOL> return False <EOL> return True <EOL> platform = Platform ( ) <EOL> platformType = platform . getType ( ) <EOL> seconds = platform . seconds </s>
