def safe_filename(name, extension=None, digest=None, max_length=_MAX_FILENAME_LENGTH):
  if os.path.basename(name) != name:
    raise ValueError('Name must be a filename, handed a path: {}'.format(name))

  ext = extension or ''
  filename = name + ext
  if len(filename) <= max_length:
    return filename
  else:
    digest = digest or hashlib.sha1()
    digest.update(name)
    safe_name = digest.hexdigest() + ext
    if len(safe_name) > max_length:
      raise ValueError('Digest {} failed to produce a filename <= {} '
                       'characters for {} - got {}'.format(digest, max_length, filename, safe_name))
    return safe_name
Return the periodic tasks object
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/fs/fs.py/safe_filename--crossover with--dataset/ETHPy150Open openstack/sahara/sahara/service/periodic.py/_make_periodic_tasks