def v1_deprecated(warning=None):
  """Shows a warning if ENABLE_V1_WARNINGS is True.

  Function decorator used to mark methods used in v1 classes which
  may be removed in future versions of the library.
  """
  warning = warning or ''
  # This closure is what is returned from the deprecated function.
  def mark_deprecated(f):
    # The deprecated_function wraps the actual call to f.
    def optional_warn_function(*args, **kwargs):
      if ENABLE_V1_WARNINGS:
        warnings.warn(warning, DeprecationWarning, stacklevel=2)
      return f(*args, **kwargs)
    # Preserve the original name to avoid masking all decorated functions as
    # 'deprecated_function'
    try:
      optional_warn_function.func_name = f.func_name
    except __HOLE__:
      pass # In Python2.3 we can't set the func_name
    return optional_warn_function
  return mark_deprecated
dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/atom/__init__.py/v1_deprecated