def register_opener(suffix, opener=None):
  """
  Register a callback that opens an archive with the specified *suffix*.
  The object returned by the *opener* must implement the #tarfile.Tarfile
  interface, more specifically the following methods:

  - `add(filename, arcname) -> None`
  - `getnames() -> list of str`
  - `getmember(filename) -> TarInfo`
  - `extractfile(filename) -> file obj`

  This function can be used as a decorator when *opener* is not provided.

  The opener must accept the following arguments:

  %%arglist
  file (file-like): A file-like object to read the archive data from.
  mode (str): The mode to open the file in. Valid values are
    `'w'`, `'r'` and `'a'`.
  options (dict): A dictionary with possibly additional arguments.
  """

  if opener is None:
    def decorator(func):
      register_opener(suffix, func)
      return func
    return decorator
  if suffix in openers:
    raise ValueError('opener suffix {0!r} already registered'.format(suffix))
  openers[suffix] = opener
def register_opener ( suffix , opener = None ) : if opener is None : def decorator ( func ) : register_opener ( suffix , func ) return func return decorator if suffix in openers : raise ValueError ( 'opener suffix {0!r} already registered' . format ( suffix ) ) openers [ suffix ] = opener
Register a callback that opens an archive with the specified *suffix*.
  The object returned by the *opener* must implement the #tarfile.Tarfile
  interface, more specifically the following methods:

  - `add(filename, arcname) -> None`
  - `getnames() -> list of str`
  - `getmember(filename) -> TarInfo`
  - `extractfile(filename) -> file obj`

  This function can be used as a decorator when *opener* is not provided.

  The opener must accept the following arguments:

  %%arglist
  file (file-like): A file-like object to read the archive data from.
  mode (str): The mode to open the file in. Valid values are
    `'w'`, `'r'` and `'a'`.
  options (dict): A dictionary with possibly additional arguments.