<s> try : <EOL> from urllib . request import urlopen <EOL> except ImportError : <EOL> from urllib2 import urlopen <EOL> import yaml <EOL> import warnings <EOL> from . core import DownloadFailure <EOL> from . rosdistrohelper import PreRep137Warning <EOL> REP3_TARGETS_URL = '<STR_LIT>' <EOL> DOWNLOAD_TIMEOUT = <NUM_LIT> <EOL> def download_targets_data ( targets_url = None ) : <EOL> """<STR_LIT>""" <EOL> warnings . warn ( "<STR_LIT>" , PreRep137Warning ) <EOL> if targets_url is None : <EOL> targets_url = REP3_TARGETS_URL <EOL> try : <EOL> f = urlopen ( targets_url , timeout = DOWNLOAD_TIMEOUT ) <EOL> text = f . read ( ) <EOL> f . close ( ) <EOL> targets_data = yaml . safe_load ( text ) <EOL> except Exception as e : <EOL> raise DownloadFailure ( "<STR_LIT>" % ( str ( e ) ) ) <EOL> if type ( targets_data ) == list : <EOL> new_targets_data = { } <EOL> for t in targets_data : <EOL> platform = list ( t . keys ( ) ) [ <NUM_LIT:0> ] <EOL> new_targets_data [ platform ] = t [ platform ] <EOL> targets_data = new_targets_data <EOL> return targets_data </s>
