<s> from __future__ import print_function <EOL> import pkg_resources <EOL> import sys <EOL> import traceback <EOL> from bloom . logging import debug <EOL> from bloom . logging import error <EOL> from bloom . logging import info <EOL> from bloom . util import code <EOL> from bloom . util import maybe_continue <EOL> from bloom . util import print_exc <EOL> try : <EOL> from rosdep2 import create_default_installer_context <EOL> from rosdep2 . catkin_support import get_catkin_view <EOL> from rosdep2 . lookup import ResolutionError <EOL> import rosdep2 . catkin_support <EOL> except ImportError as err : <EOL> debug ( traceback . format_exc ( ) ) <EOL> error ( "<STR_LIT>" , exit = True ) <EOL> BLOOM_GROUP = '<STR_LIT>' <EOL> DEFAULT_ROS_DISTRO = '<STR_LIT>' <EOL> def list_generators ( ) : <EOL> generators = [ ] <EOL> for entry_point in pkg_resources . iter_entry_points ( group = BLOOM_GROUP ) : <EOL> generators . append ( entry_point . name ) <EOL> return generators <EOL> def load_generator ( generator_name ) : <EOL> for entry_point in pkg_resources . iter_entry_points ( group = BLOOM_GROUP ) : <EOL> if entry_point . name == generator_name : <EOL> return entry_point . load ( ) <EOL> view_cache = { } <EOL> def get_view ( os_name , os_version , ros_distro ) : <EOL> global view_cache <EOL> key = os_name + os_version + ros_distro <EOL> if key not in view_cache : <EOL> value = get_catkin_view ( ros_distro , os_name , os_version , False ) <EOL> view_cache [ key ] = value <EOL> return view_cache [ key ] <EOL> def invalidate_view_cache ( ) : <EOL> global view_cache <EOL> view_cache = { } <EOL> def update_rosdep ( ) : <EOL> info ( "<STR_LIT>" ) <EOL> try : <EOL> rosdep2 . catkin_support . update_rosdep ( ) <EOL> except : <EOL> print_exc ( traceback . format_exc ( ) ) <EOL> error ( "<STR_LIT>" , <EOL> exit = True ) <EOL> def resolve_more_for_os ( rosdep_key , view , installer , os_name , os_version ) : <EOL> """<STR_LIT>""" <EOL> d = view . lookup ( rosdep_key ) <EOL> ctx = create_default_installer_context ( ) <EOL> os_installers = ctx . get_os_installer_keys ( os_name ) <EOL> default_os_installer = ctx . get_default_os_installer_key ( os_name ) <EOL> inst_key , rule = d . get_rule_for_platform ( os_name , os_version , <EOL> os_installers , <EOL> default_os_installer ) <EOL> assert inst_key in os_installers <EOL> return installer . resolve ( rule ) , inst_key , default_os_installer <EOL> def resolve_rosdep_key ( <EOL> key , <EOL> os_name , <EOL> os_version , <EOL> ros_distro = None , <EOL> ignored = None , <EOL> retry = True <EOL> ) : <EOL> ignored = ignored or [ ] <EOL> ctx = create_default_installer_context ( ) <EOL> try : <EOL> installer_key = ctx . get_default_os_installer_key ( os_name ) <EOL> except KeyError : <EOL> BloomGenerator . exit ( "<STR_LIT>" <EOL> . format ( os_name ) ) <EOL> installer = ctx . get_installer ( installer_key ) <EOL> ros_distro = ros_distro or DEFAULT_ROS_DISTRO <EOL> view = get_view ( os_name , os_version , ros_distro ) <EOL> try : <EOL> return resolve_more_for_os ( key , view , installer , os_name , os_version ) <EOL> except ( KeyError , ResolutionError ) as exc : <EOL> debug ( traceback . format_exc ( ) ) <EOL> if key in ignored : <EOL> return None , None , None <EOL> if isinstance ( exc , KeyError ) : <EOL> error ( "<STR_LIT>" . format ( key ) ) <EOL> returncode = code . GENERATOR_NO_SUCH_ROSDEP_KEY <EOL> else : <EOL> error ( "<STR_LIT>" <EOL> . format ( key , os_version ) ) <EOL> info ( str ( exc ) , use_prefix = False ) <EOL> returncode = code . GENERATOR_NO_ROSDEP_KEY_FOR_DISTRO <EOL> if retry : <EOL> error ( "<STR_LIT>" ) <EOL> if maybe_continue ( ) : <EOL> update_rosdep ( ) <EOL> invalidate_view_cache ( ) <EOL> return resolve_rosdep_key ( key , os_name , os_version , ros_distro , <EOL> ignored , retry = True ) <EOL> BloomGenerator . exit ( "<STR_LIT>" <EOL> . format ( key ) , returncode = returncode ) <EOL> def default_fallback_resolver ( key , peer_packages ) : <EOL> BloomGenerator . exit ( "<STR_LIT>" <EOL> . format ( key ) , returncode = code . GENERATOR_NO_SUCH_ROSDEP_KEY ) <EOL> def resolve_dependencies ( <EOL> keys , <EOL> os_name , <EOL> os_version , <EOL> ros_distro = None , <EOL> peer_packages = None , <EOL> fallback_resolver = None <EOL> ) : <EOL> ros_distro = ros_distro or DEFAULT_ROS_DISTRO <EOL> peer_packages = peer_packages or [ ] <EOL> fallback_resolver = fallback_resolver or default_fallback_resolver <EOL> resolved_keys = { } <EOL> keys = [ k . name for k in keys ] <EOL> for key in keys : <EOL> resolved_key , installer_key , default_installer_key = resolve_rosdep_key ( key , os_name , os_version , ros_distro , <EOL> peer_packages , retry = True ) <EOL> if resolved_key is None : <EOL> resolved_key = fallback_resolver ( key , peer_packages ) <EOL> resolved_keys [ key ] = resolved_key <EOL> return resolved_keys <EOL> class GeneratorError ( Exception ) : <EOL> def __init__ ( self , msg , returncode = code . UNKNOWN ) : <EOL> super ( GeneratorError , self ) . __init__ ( "<STR_LIT>" + msg ) <EOL> self . returncode = returncode <EOL> @ staticmethod <EOL> def excepthook ( etype , value , traceback ) : <EOL> GeneratorError . sysexcepthook ( etype , value , traceback ) <EOL> if isinstance ( value , GeneratorError ) : <EOL> sys . exit ( value . returncode ) <EOL> sys . excepthook , sysexcepthook = excepthook . __func__ , staticmethod ( sys . excepthook ) <EOL> class BloomGenerator ( object ) : <EOL> """<STR_LIT>""" <EOL> generator_type = None <EOL> title = '<STR_LIT>' <EOL> description = None <EOL> help = None <EOL> @ classmethod <EOL> def exit ( cls , msg , returncode = code . UNKNOWN ) : <EOL> raise GeneratorError ( msg , returncode ) <EOL> def prepare_arguments ( self , parser ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def handle_arguments ( self , args ) : <EOL> """<STR_LIT>""" <EOL> debug ( "<STR_LIT>" + str ( args ) ) <EOL> def summarize ( self ) : <EOL> """<STR_LIT>""" <EOL> info ( "<STR_LIT>" + self . title + "<STR_LIT>" ) <EOL> def get_branching_arguments ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ ] <EOL> def pre_modify ( self ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def pre_branch ( self , destination , source ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def post_branch ( self , destination , source ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def pre_export_patches ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def post_export_patches ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def pre_rebase ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def post_rebase ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def pre_patch ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def post_patch ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> </s>
