def _hadoop_prefix_from_bin(hadoop_bin):
 if ('/' not in hadoop_bin):
  hadoop_bin = which(hadoop_bin)
  if (not hadoop_bin):
   return None
 hadoop_home = posixpath.abspath(posixpath.join(posixpath.realpath(posixpath.dirname(hadoop_bin)), '..'))
 if (hadoop_home in _BAD_HADOOP_HOMES):
  return None
 return hadoop_home

def _hadoop_prefix_from_bin ( hadoop_bin ) : if ( '/' not in hadoop_bin ) : hadoop_bin = which ( hadoop_bin ) if ( not hadoop_bin ) : return None hadoop_home = posixpath . abspath ( posixpath . join ( posixpath . realpath ( posixpath . dirname ( hadoop_bin ) ) , '..' ) ) if ( hadoop_home in _BAD_HADOOP_HOMES ) : return None return hadoop_home
given a path to the hadoop binary .