コード例 #1
0
def listlayers(path, vfs=None):
    """Returns a list of layer names in their index order.

    The required ``path`` argument may be an absolute or relative file or
    directory path.

    A virtual filesystem can be specified. The ``vfs`` parameter may be
    an Apache Commons VFS style string beginning with "zip://" or
    "tar://"". In this case, the ``path`` must be an absolute path within
    that container.
    """
    if not isinstance(path, string_types):
        raise TypeError("invalid path: %r" % path)
    if vfs and not isinstance(vfs, string_types):
        raise TypeError("invalid vfs: %r" % vfs)

    path, vsi, archive = parse_paths(path, vfs)

    if archive:
        if not os.path.exists(archive):
            raise IOError("no such archive file: %r" % archive)
    elif not os.path.exists(path):
        raise IOError("no such file or directory: %r" % path)

    with drivers():
        return _listlayers(vsi_path(path, vsi, archive))
コード例 #2
0
ファイル: __init__.py プロジェクト: dimlev/Fiona
def listlayers(path, vfs=None):
    """Returns a list of layer names in their index order.
    
    The required ``path`` argument may be an absolute or relative file or
    directory path.
    
    A virtual filesystem can be specified. The ``vfs`` parameter may be
    an Apache Commons VFS style string beginning with "zip://" or
    "tar://"". In this case, the ``path`` must be an absolute path within
    that container.
    """
    if not isinstance(path, string_types):
        raise TypeError("invalid path: %r" % path)
    if vfs and not isinstance(vfs, string_types):
        raise TypeError("invalid vfs: %r" % vfs)
    
    path, vsi, archive = parse_paths(path, vfs)
    
    if archive:
        if not os.path.exists(archive):
            raise IOError("no such archive file: %r" % archive)
    elif not os.path.exists(path):
        raise IOError("no such file or directory: %r" % path)
    
    with drivers():
        return _listlayers(vsi_path(path, vsi, archive))
コード例 #3
0
ファイル: __init__.py プロジェクト: vishalbelsare/Fiona
def listlayers(fp, vfs=None):
    """List layer names in their index order

    Parameters
    ----------
    fp : URI (str or pathlib.Path), or file-like object
        A dataset resource identifier or file object.
    vfs : str
        This is a deprecated parameter. A URI scheme such as "zip://"
        should be used instead.

    Returns
    -------
    list
        A list of layer name strings.

    """
    if hasattr(fp, 'read'):

        with MemoryFile(fp.read()) as memfile:
            return _listlayers(memfile.name)

    else:

        if isinstance(fp, Path):
            fp = str(fp)

        if not isinstance(fp, string_types):
            raise TypeError("invalid path: %r" % fp)
        if vfs and not isinstance(vfs, string_types):
            raise TypeError("invalid vfs: %r" % vfs)

        if vfs:
            warnings.warn(
                "The vfs keyword argument is deprecated. Instead, pass a URL that uses a zip or tar (for example) scheme.",
                FionaDeprecationWarning,
                stacklevel=2)
            pobj_vfs = parse_path(vfs)
            pobj_path = parse_path(fp)
            pobj = ParsedPath(pobj_path.path, pobj_vfs.path, pobj_vfs.scheme)
        else:
            pobj = parse_path(fp)

        return _listlayers(vsi_path(pobj))
コード例 #4
0
def listlayers(path, vfs=None):
    """Returns a list of layer names in their index order.

    The required ``path`` argument may be an absolute or relative file or
    directory path.

    A virtual filesystem can be specified. The ``vfs`` parameter may be
    an Apache Commons VFS style string beginning with "zip://" or
    "tar://"". In this case, the ``path`` must be an absolute path within
    that container.
    """
    if not isinstance(path, string_types):
        raise TypeError("invalid path: %r" % path)
    if vfs and not isinstance(vfs, string_types):
        raise TypeError("invalid vfs: %r" % vfs)

    if vfs:
        pobj_vfs = parse_path(vfs)
        pobj_path = parse_path(path)
        pobj = ParsedPath(pobj_path.path, pobj_vfs.path, pobj_vfs.scheme)
    else:
        pobj = parse_path(path)

    return _listlayers(vsi_path(pobj))
コード例 #5
0
ファイル: __init__.py プロジェクト: Toblerity/Fiona
def listlayers(path, vfs=None):
    """Returns a list of layer names in their index order.

    The required ``path`` argument may be an absolute or relative file or
    directory path.

    A virtual filesystem can be specified. The ``vfs`` parameter may be
    an Apache Commons VFS style string beginning with "zip://" or
    "tar://"". In this case, the ``path`` must be an absolute path within
    that container.
    """
    if not isinstance(path, string_types):
        raise TypeError("invalid path: %r" % path)
    if vfs and not isinstance(vfs, string_types):
        raise TypeError("invalid vfs: %r" % vfs)

    if vfs:
        pobj_vfs = parse_path(vfs)
        pobj_path = parse_path(path)
        pobj = ParsedPath(pobj_path.path, pobj_vfs.path, pobj_vfs.scheme)
    else:
        pobj = parse_path(path)

    return _listlayers(vsi_path(pobj))