code: def delete(path, regex=None, recurse=False, test=False):
      
      deleted = []
      if op.isfile(path):
          if not test: os.remove(path)
          else: return [path]
          return [] if op.exists(path) else [path]
      elif op.isdir(path):
          if regex:
              for r,ds,fs in os.walk(path):
                  for i in fs:
                      if _is_match(regex, i):
                          deleted += delete(op.join(r,i), test=test)
                  if not recurse:
                      break
          else:
              if not test: shutil.rmtree(path)
              else: return [path]
              return [] if op.exists(path) else [path]
      return deleted
docs: Deletes the file or directory at `path`. If `path` is a directory and
      `regex` is provided, matching files will be deleted; `recurse` controls
      whether subdirectories are recursed. A list of deleted items is returned.
      If `test` is true, nothing will be deleted and a list of items that would
      have been deleted is returned.