<s> import collections <EOL> import six <EOL> from anvil import shell as sh <EOL> from anvil import utils <EOL> class Helper ( object ) : <EOL> def __init__ ( self ) : <EOL> self . _multipip_executable = sh . which ( "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> def _call_multipip ( self , requirements , <EOL> requires_files = None , ignore_requirements = None , <EOL> forced_requirements = None ) : <EOL> cmdline = [ self . _multipip_executable ] <EOL> if requires_files : <EOL> cmdline . append ( "<STR_LIT>" ) <EOL> cmdline . extend ( requires_files ) <EOL> if ignore_requirements : <EOL> cmdline . append ( "<STR_LIT>" ) <EOL> cmdline . extend ( ignore_requirements ) <EOL> if forced_requirements : <EOL> cmdline . append ( "<STR_LIT>" ) <EOL> cmdline . extend ( forced_requirements ) <EOL> if requirements : <EOL> cmdline . append ( "<STR_LIT>" ) <EOL> cmdline . extend ( requirements ) <EOL> ( stdout , stderr ) = sh . execute ( cmdline , check_exit_code = False ) <EOL> compatibles = list ( utils . splitlines_not_empty ( stdout ) ) <EOL> incompatibles = collections . defaultdict ( list ) <EOL> current_name = '<STR_LIT>' <EOL> for line in stderr . strip ( ) . splitlines ( ) : <EOL> if line . endswith ( "<STR_LIT>" ) : <EOL> current_name = line . split ( "<STR_LIT::>" , <NUM_LIT:1> ) [ <NUM_LIT:0> ] . lower ( ) . strip ( ) <EOL> if current_name not in incompatibles : <EOL> incompatibles [ current_name ] = [ ] <EOL> else : <EOL> incompatibles [ current_name ] . append ( line ) <EOL> cleaned_incompatibles = dict ( ) <EOL> for ( requirement , lines ) in six . iteritems ( incompatibles ) : <EOL> requirement = requirement . strip ( ) <EOL> if not requirement : <EOL> continue <EOL> if not lines : <EOL> continue <EOL> cleaned_incompatibles [ requirement ] = lines <EOL> incompatibles = cleaned_incompatibles <EOL> return ( compatibles , incompatibles ) <EOL> def resolve ( self , requirements , <EOL> requires_files = None , ignore_requirements = None , <EOL> forced_requirements = None ) : <EOL> return self . _call_multipip ( requirements , <EOL> requires_files = requires_files , <EOL> ignore_requirements = ignore_requirements , <EOL> forced_requirements = forced_requirements ) </s>
