parameters: (program, dirpath=None, min_version=None, recommend_version=None)
return_statement: return None
docstring: returns the path to an executable or None if it can't be found
docstring_summary: returns the path to an executable or None if it can't be found
docstring_tokens: returns the path to an executable or None if it can t be found
function: def get_path_to_program(program, dirpath=None, min_version=None, recommend_version=None):
      """
      returns the path to an executable or None if it can't be found
      """
      OLD_VERSION = 0
      CORRECT_VERSION = 1
      NOT_RECOMMENDED_VERSION = 2
  
      def is_exe(fpath):
          if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
              version_check = check_version(fpath, min_version, recommend_version)
              if version_check != OLD_VERSION:
                  if version_check == NOT_RECOMMENDED_VERSION:
                      logger.warning('Version of installed %s differs from its version in QUAST package (%s). '
                                     'Please make sure that you use an actual version of software.' % (program, recommend_version))
                  return True
  
      def check_version(fpath, min_version, recommend_version=None):
          if not min_version: return CORRECT_VERSION
          p = subprocess.Popen([fpath, '--version'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
          stdout, stderr = p.communicate()
          version_pattern = re.compile('(?P<major_version>\d+)\.(?P<minor_version>\d+)')
          v = version_pattern.search(str(stdout))
          if not v.group('major_version') or not v.group('minor_version'):
              return OLD_VERSION
          version, minor_version = map(int, min_version.split('.'))
          rec_version, rec_minor_version = map(int, recommend_version.split('.'))
          if int(v.group('major_version')) == version and int(v.group('minor_version')) >= minor_version:
              if not recommend_version or (int(v.group('major_version')) == rec_version and int(v.group('minor_version')) == rec_minor_version):
                  return CORRECT_VERSION
              else:
                  return NOT_RECOMMENDED_VERSION
          else: return OLD_VERSION
  
      if dirpath:
          exe_file = os.path.join(dirpath, program)
          if is_exe(exe_file):
              return exe_file
  
      for path in os.environ["PATH"].split(os.pathsep):
          exe_file = os.path.join(path, program)
          if is_exe(exe_file):
              return exe_file
      return None
function_tokens: def get_path_to_program ( program , dirpath = None , min_version = None , recommend_version = None ) : OLD_VERSION = 0 CORRECT_VERSION = 1 NOT_RECOMMENDED_VERSION = 2 def is_exe ( fpath ) : if os . path . isfile ( fpath ) and os . access ( fpath , os . X_OK ) : version_check = check_version ( fpath , min_version , recommend_version ) if version_check != OLD_VERSION : if version_check == NOT_RECOMMENDED_VERSION : logger . warning ( 'Version of installed %s differs from its version in QUAST package (%s). ' 'Please make sure that you use an actual version of software.' % ( program , recommend_version ) ) return True def check_version ( fpath , min_version , recommend_version = None ) : if not min_version : return CORRECT_VERSION p = subprocess . Popen ( [ fpath , '--version' ] , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) stdout , stderr = p . communicate ( ) version_pattern = re . compile ( '(?P<major_version>\d+)\.(?P<minor_version>\d+)' ) v = version_pattern . search ( str ( stdout ) ) if not v . group ( 'major_version' ) or not v . group ( 'minor_version' ) : return OLD_VERSION version , minor_version = map ( int , min_version . split ( '.' ) ) rec_version , rec_minor_version = map ( int , recommend_version . split ( '.' ) ) if int ( v . group ( 'major_version' ) ) == version and int ( v . group ( 'minor_version' ) ) >= minor_version : if not recommend_version or ( int ( v . group ( 'major_version' ) ) == rec_version and int ( v . group ( 'minor_version' ) ) == rec_minor_version ) : return CORRECT_VERSION else : return NOT_RECOMMENDED_VERSION else : return OLD_VERSION if dirpath : exe_file = os . path . join ( dirpath , program ) if is_exe ( exe_file ) : return exe_file for path in os . environ [ "PATH" ] . split ( os . pathsep ) : exe_file = os . path . join ( path , program ) if is_exe ( exe_file ) : return exe_file return None