<s> import os <EOL> import re <EOL> import sys <EOL> from command import Command <EOL> CHANGE_RE = re . compile ( r'<STR_LIT>' ) <EOL> class Download ( Command ) : <EOL> common = True <EOL> helpSummary = "<STR_LIT>" <EOL> helpUsage = """<STR_LIT>""" <EOL> helpDescription = """<STR_LIT>""" <EOL> def _Options ( self , p ) : <EOL> pass <EOL> def _ParseChangeIds ( self , args ) : <EOL> if not args : <EOL> self . Usage ( ) <EOL> to_get = [ ] <EOL> project = None <EOL> for a in args : <EOL> m = CHANGE_RE . match ( a ) <EOL> if m : <EOL> if not project : <EOL> self . Usage ( ) <EOL> chg_id = int ( m . group ( <NUM_LIT:1> ) ) <EOL> if m . group ( <NUM_LIT:2> ) : <EOL> ps_id = int ( m . group ( <NUM_LIT:2> ) ) <EOL> else : <EOL> ps_id = <NUM_LIT:1> <EOL> to_get . append ( ( project , chg_id , ps_id ) ) <EOL> else : <EOL> project = self . GetProjects ( [ a ] ) [ <NUM_LIT:0> ] <EOL> return to_get <EOL> def Execute ( self , opt , args ) : <EOL> for project , change_id , ps_id in self . _ParseChangeIds ( args ) : <EOL> dl = project . DownloadPatchSet ( change_id , ps_id ) <EOL> if not dl : <EOL> print >> sys . stderr , '<STR_LIT>' % ( project . name , change_id , ps_id ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if not dl . commits : <EOL> print >> sys . stderr , '<STR_LIT>' % ( project . name , change_id , ps_id ) <EOL> continue <EOL> if len ( dl . commits ) > <NUM_LIT:1> : <EOL> print >> sys . stderr , '<STR_LIT>' % ( project . name , change_id , ps_id , len ( dl . commits ) ) <EOL> for c in dl . commits : <EOL> print >> sys . stderr , '<STR_LIT>' % ( c ) <EOL> project . _Checkout ( dl . commit ) </s>
