<s> import os , os . path <EOL> import shutil <EOL> import urllib , urllib2 <EOL> import simplejson as json <EOL> from play . utils import * <EOL> COMMANDS = [ '<STR_LIT>' ] <EOL> HELP = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> TAGS_URL = "<STR_LIT>" <EOL> def execute ( ** kargs ) : <EOL> args = kargs . get ( "<STR_LIT:args>" ) <EOL> play_env = kargs . get ( "<STR_LIT>" ) <EOL> if len ( sys . argv ) == <NUM_LIT:3> : <EOL> version = sys . argv [ <NUM_LIT:2> ] <EOL> else : <EOL> version = playVersion ( play_env ) <EOL> current = Release ( version ) <EOL> releases = allreleases ( ) <EOL> if len ( releases ) == <NUM_LIT:0> : <EOL> print "<STR_LIT>" <EOL> elif current == max ( releases ) : <EOL> print "<STR_LIT>" <EOL> else : <EOL> print "<STR_LIT>" + str ( max ( releases ) ) <EOL> print "<STR_LIT>" + str ( current ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" + max ( releases ) . url ( ) <EOL> print "<STR_LIT>" <EOL> def allreleases ( ) : <EOL> try : <EOL> req = urllib2 . Request ( TAGS_URL ) <EOL> req . add_header ( '<STR_LIT>' , '<STR_LIT:application/json>' ) <EOL> opener = urllib2 . build_opener ( ) <EOL> result = opener . open ( req ) <EOL> return map ( lambda x : Release ( x ) , json . loads ( result . read ( ) ) [ "<STR_LIT>" ] ) <EOL> except urllib2 . HTTPError , e : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> except urllib2 . URLError , e : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> class Release : <EOL> def __init__ ( self , strversion ) : <EOL> self . strversion = strversion <EOL> try : <EOL> self . numpart = re . findall ( "<STR_LIT>" , strversion ) [ <NUM_LIT:0> ] <EOL> except : <EOL> self . numpart = '<STR_LIT>' <EOL> self . rest = strversion . replace ( self . numpart , "<STR_LIT>" ) <EOL> try : <EOL> self . versions = map ( lambda x : int ( x ) , self . numpart . split ( "<STR_LIT:.>" ) ) <EOL> except : <EOL> self . versions = [ <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> if not self . rest : self . rest = "<STR_LIT>" <EOL> def url ( self ) : <EOL> return "<STR_LIT>" + self . strversion + "<STR_LIT>" <EOL> def __eq__ ( self , other ) : <EOL> return self . strversion == other . strversion <EOL> def __lt__ ( self , other ) : <EOL> try : <EOL> if self == other : <EOL> return False <EOL> for i in range ( len ( self . versions ) ) : <EOL> if self . versions [ i ] < other . versions [ i ] : <EOL> return True <EOL> if self . versions [ i ] > other . versions [ i ] : <EOL> return False <EOL> if len ( self . versions ) < len ( other . versions ) : <EOL> return True <EOL> if len ( self . versions ) > len ( other . versions ) : <EOL> return False <EOL> if len ( other . numpart ) > <NUM_LIT:0> and len ( self . numpart ) == <NUM_LIT:0> : <EOL> return False <EOL> if len ( self . numpart ) > <NUM_LIT:0> and len ( other . numpart ) == <NUM_LIT:0> : <EOL> return True <EOL> return self . rest < other . rest <EOL> except : <EOL> return False <EOL> def __le__ ( self , other ) : <EOL> return self == other or self < other <EOL> def __gt__ ( self , other ) : <EOL> return not ( self <= other ) <EOL> def __ge__ ( self , other ) : <EOL> return not ( self < other ) <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> def __repr__ ( self ) : <EOL> return self . strversion <EOL> def __str__ ( self ) : <EOL> return self . strversion </s>
