def _archive_single_dir(archive):
    """
    Check if all members of the archive are in a single top-level directory

    :param archive:
        An archive from _open_archive()

    :return:
        None if not a single top level directory in archive, otherwise a
        unicode string of the top level directory name
    """

    common_root = None
    for info in _list_archive_members(archive):
        fn = _info_name(info)
        if fn in set(['.', '/']):
            continue
        sep = None
        if '/' in fn:
            sep = '/'
        elif '\\' in fn:
            sep = '\\'
        if sep is None:
            root_dir = fn
        else:
            root_dir, _ = fn.split(sep, 1)
        if common_root is None:
            common_root = root_dir
        else:
            if common_root != root_dir:
                return None
    return common_root
def _archive_single_dir ( archive ) : common_root = None for info in _list_archive_members ( archive ) : fn = _info_name ( info ) if fn in set ( [ '.' , '/' ] ) : continue sep = None if '/' in fn : sep = '/' elif '\\' in fn : sep = '\\' if sep is None : root_dir = fn else : root_dir , _ = fn . split ( sep , 1 ) if common_root is None : common_root = root_dir else : if common_root != root_dir : return None return common_root
Check if all members of the archive are in a single top-level directory

    :param archive:
        An archive from _open_archive()

    :return:
        None if not a single top level directory in archive, otherwise a
        unicode string of the top level directory name