<s> import urllib <EOL> import tempfile <EOL> from lookups import Lookup <EOL> from core import GsxObject , GsxError <EOL> REASON_CODES = ( <EOL> ( '<STR_LIT:A>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:B>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:C>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:D>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:E>' , '<STR_LIT>' ) , <EOL> ) <EOL> IMAGE_URL = "<STR_LIT>" <EOL> class Part ( GsxObject ) : <EOL> """<STR_LIT>""" <EOL> def lookup ( self ) : <EOL> lookup = Lookup ( ** self . _data ) <EOL> return lookup . parts ( ) <EOL> def fetch_image ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . partNumber is None : <EOL> raise GsxError ( "<STR_LIT>" ) <EOL> image = "<STR_LIT>" % self . partNumber <EOL> url = IMAGE_URL % image <EOL> tmpfile = tempfile . mkstemp ( suffix = image ) <EOL> try : <EOL> return urllib . urlretrieve ( url , tmpfile [ <NUM_LIT:1> ] ) [ <NUM_LIT:0> ] <EOL> except Exception , e : <EOL> raise GsxError ( "<STR_LIT>" % e ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import sys <EOL> import doctest <EOL> import logging <EOL> from core import connect <EOL> logging . basicConfig ( level = logging . DEBUG ) <EOL> connect ( * sys . argv [ <NUM_LIT:1> : ] ) <EOL> doctest . testmod ( ) </s>
