docs: def make_bag(bag_dir, bag_info=None, processes=1, checksum=None):
      """
      Convert a given directory into a bag. You can pass in arbitrary
      key/value pairs to put into the bag-info.txt metadata file as
      the bag_info dictionary.
      """
      bag_dir = os.path.abspath(bag_dir)
      logger.info("creating bag for directory %s", bag_dir)
      # assume md5 checksum if not specified
      if not checksum:
          checksum = ['md5']
  
      if not os.path.isdir(bag_dir):
          logger.error("no such bag directory %s", bag_dir)
          raise RuntimeError("no such bag directory %s" % bag_dir)
  
      old_dir = os.path.abspath(os.path.curdir)
      os.chdir(bag_dir)
  
      try:
          unbaggable = _can_bag(os.curdir)
          if unbaggable:
              logger.error("no write permissions for the following directories and files: \n%s", unbaggable)
              raise BagError("Not all files/folders can be moved.")
          unreadable_dirs, unreadable_files = _can_read(os.curdir)
          if unreadable_dirs or unreadable_files:
              if unreadable_dirs:
                  logger.error("The following directories do not have read permissions: \n%s", unreadable_dirs)
              if unreadable_files:
                  logger.error("The following files do not have read permissions: \n%s", unreadable_files)
              raise BagError("Read permissions are required to calculate file fixities.")
          else:
              logger.info("creating data dir")
  
              cwd = os.getcwd()
              temp_data = tempfile.mkdtemp(dir=cwd)
  
              for f in os.listdir('.'):
                  if os.path.abspath(f) == temp_data:
                      continue
                  new_f = os.path.join(temp_data, f)
                  logger.info("moving %s to %s", f, new_f)
                  os.rename(f, new_f)
  
              logger.info("moving %s to %s", temp_data, 'data')
              os.rename(temp_data, 'data')
  
              # permissions for the payload directory should match those of the
              # original directory
              os.chmod('data', os.stat(cwd).st_mode)
  
              for c in checksum:
                  logger.info("writing manifest-%s.txt", c)
                  Oxum = _make_manifest('manifest-%s.txt' % c, 'data', processes, c)
  
              logger.info("writing bagit.txt")
              txt = """BagIt-Version: 0.97\nTag-File-Character-Encoding: UTF-8\n"""
              with open("bagit.txt", "w") as bagit_file:
                  bagit_file.write(txt)
  
              logger.info("writing bag-info.txt")
              if bag_info is None:
                  bag_info = {}
  
              # allow 'Bagging-Date' and 'Bag-Software-Agent' to be overidden
              if 'Bagging-Date' not in bag_info:
                  bag_info['Bagging-Date'] = date.strftime(date.today(), "%Y-%m-%d")
              if 'Bag-Software-Agent' not in bag_info:
                  bag_info['Bag-Software-Agent'] = 'bagit.py <http://github.com/libraryofcongress/bagit-python>'
              bag_info['Payload-Oxum'] = Oxum
              _make_tag_file('bag-info.txt', bag_info)
  
              for c in checksum:
                  _make_tagmanifest_file(c, bag_dir)
      except Exception:
          logger.exception("An error occurred creating the bag")
          raise
      finally:
          os.chdir(old_dir)
  
      return Bag(bag_dir)