def read_tarball(path, shortkey=False, classes=Editor):
editors = {}<EOL>with tarfile.open(path) as tar:<EOL><INDENT>for member in tar.getmembers():<EOL><INDENT>f = tar.extractfile(member)<EOL>if f is None:<EOL><INDENT>continue<EOL><DEDENT>if shortkey:<EOL><INDENT>name = os.path.basename(member.name)<EOL><DEDENT>else:<EOL><INDENT>name = member.name<EOL><DEDENT>if isinstance(classes, type):<EOL><INDENT>cls = classes<EOL><DEDENT>elif isinstance(classes, dict):<EOL><INDENT>cls = classes.get(name, Editor)<EOL><DEDENT>elif callable(classes):<EOL><INDENT>cls = classes(name)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>".format(type(classes)))<EOL><DEDENT>editors[name] = cls(f, name=name)<EOL><DEDENT><DEDENT>return editors<EOL>
Read a (possibly compressed) tarball archive and return a dictionary of
editors.

.. code-block:: python

    eds = read_tarball(path, classes=MyEditor)    # All files read as type MyEditor
    # Only read the special file as type MyEditor (default to Editor)
    eds = read_tarball(path.bz2, classes={'specialfile': MyEditor})
    eds = read_tarball(path, classes=myfunc)      # Complex function that returns classes

Args:
    path (str): Path to tarball archive
    keypath (bool): Full member path as key (true, default); file name as key (false)
    classes: Class, dictionary of classes, or callable to return class