
import gzip
import hashlib


def file_md5sum(fname, unzip=False, mode="r", blocksize=65536):
    if unzip:
        opener = gzip.open
    else:
        opener = open

    hasher = hashlib.md5()
    with opener(fname, mode) as src:
        buf = src.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = src.read(blocksize)
    return hasher.hexdigest()


import gzip
import hashlib
import os


def file_md5sum(fname, unzip=False, mode="r", blocksize=65536):
    if unzip:
        opener = gzip.open
    else:
        opener = open

    hasher = hashlib.md5()
    with opener(fname, mode) as src:
        buf = src.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = src.read(blocksize)
    return hasher.hexdigest()


def isexecfile(fname):
    return os.path.isfile(fname) and os.access(fname, os.X_OK)


def which(program):
    # can not do anything meaningful without PATH
    if "PATH" not in os.environ:
        return
    for possible in os.environ["PATH"].split(":"):
        qualname = os.path.join(possible, program)
        if isexecfile(qualname):
            return qualname
    return

Add utility function for executable checking
Add utility function for executable checking

  
  import gzip
  import hashlib
+ import os
  
  
  def file_md5sum(fname, unzip=False, mode="r", blocksize=65536):
      if unzip:
          opener = gzip.open
      else:
          opener = open
  
      hasher = hashlib.md5()
      with opener(fname, mode) as src:
          buf = src.read(blocksize)
          while len(buf) > 0:
              hasher.update(buf)
              buf = src.read(blocksize)
      return hasher.hexdigest()
  
+ 
+ def isexecfile(fname):
+     return os.path.isfile(fname) and os.access(fname, os.X_OK)
+ 
+ 
+ def which(program):
+     # can not do anything meaningful without PATH
+     if "PATH" not in os.environ:
+         return
+     for possible in os.environ["PATH"].split(":"):
+         qualname = os.path.join(possible, program)
+         if isexecfile(qualname):
+             return qualname
+     return
+ 
Add utility function for executable checking
## Code Before:

import gzip
import hashlib


def file_md5sum(fname, unzip=False, mode="r", blocksize=65536):
    if unzip:
        opener = gzip.open
    else:
        opener = open

    hasher = hashlib.md5()
    with opener(fname, mode) as src:
        buf = src.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = src.read(blocksize)
    return hasher.hexdigest()

## Instruction:
Add utility function for executable checking
## Code After:

import gzip
import hashlib
import os


def file_md5sum(fname, unzip=False, mode="r", blocksize=65536):
    if unzip:
        opener = gzip.open
    else:
        opener = open

    hasher = hashlib.md5()
    with opener(fname, mode) as src:
        buf = src.read(blocksize)
        while len(buf) > 0:
            hasher.update(buf)
            buf = src.read(blocksize)
    return hasher.hexdigest()


def isexecfile(fname):
    return os.path.isfile(fname) and os.access(fname, os.X_OK)


def which(program):
    # can not do anything meaningful without PATH
    if "PATH" not in os.environ:
        return
    for possible in os.environ["PATH"].split(":"):
        qualname = os.path.join(possible, program)
        if isexecfile(qualname):
            return qualname
    return
