def get_link_suffix(symlink):
  """Follow 'symlink' in ~/ and determine the suffix for the target (of the form <symlink>.[a-f0-9]+.
  Returns None if the symlink does not exist or is not a symlink.
  """
  with settings(warn_only=True):
    if not exists('~/%s' % symlink):
      return None
    target = run('readlink ~/%s' % symlink)
    if target.return_code != 0:
      return None
  suffix = get_file_suffix(symlink, target)
  assert suffix is not None, 'Could not determine suffix from filename %s' % target
  return suffix
dataset/ETHPy150Open viewfinderco/viewfinder/fabfile.py/get_link_suffix/original