Пример #1
0
def vsi_path(path, archive, scheme):
    """Convert a parsed path to a GDAL VSI path

    **DEPRECATED**

    Parameters
    ----------
    path : str
        The path part of a parsed path.
    archive : str
        The archive part of a parsed path.
    scheme : str
        The scheme part of a parsed path.

    Returns
    -------
    str
    """
    warnings.warn(
        "This function will be removed in version 1.0",
        RasterioDeprecationWarning
    )
    if archive or scheme:
        return future_vsi_path(ParsedPath(path, archive, scheme))
    else:
        return future_vsi_path(UnparsedPath(path))
Пример #2
0
def parse_path(path, vfs=None):
    """Parse a dataset's path into its parts

    **DEPRECATED**

    Parameters
    ----------
    path : str
        The path or filename to be parsed.
    vfs : str, optional **DEPRECATED**
        A virtual file system path.

    Returns
    -------
    path, archive, scheme : str
        Parts of the parsed path.
    """
    warnings.warn(
        "This function will be removed in version 1.0",
        RasterioDeprecationWarning
    )

    if vfs:
        parts = urlparse(vfs)
        scheme = parts.scheme
        archive = parts.path
        if parts.netloc and parts.netloc != 'localhost':  # pragma: no cover
            archive = parts.netloc + archive
        parsed = ParsedPath(path, archive, scheme)
        return parsed.path, parsed.archive, parsed.scheme

    else:
        parsed = future_parse_path(path)
        if isinstance(parsed, ParsedPath):
            return parsed.path, parsed.archive, parsed.scheme
        else:
            return parsed.path, None, None
Пример #3
0
def test_parsed_path_not_local(uri):
    """Check for paths that are not local"""
    assert False == ParsedPath.from_uri(uri).is_local
Пример #4
0
def test_parsed_path_not_remote(uri):
    """Check for paths that are not remote"""
    assert False == ParsedPath.from_uri(uri).is_remote
Пример #5
0
def test_parsed_path_file_local(scheme):
    """A parsed path is remote"""
    assert ParsedPath('foo.tif', None, scheme).is_local
Пример #6
0
def test_parsed_path_name_no_scheme():
    """A parsed path's name property is correct"""
    assert ParsedPath('bar.tif', None, None).name == 'bar.tif'
Пример #7
0
def test_parsed_path_remote(scheme):
    """A parsed path is remote"""
    assert ParsedPath('example.com/foo.tif', None, scheme).is_remote
Пример #8
0
def test_parsed_path_name_no_archive():
    """A parsed path's name property is correct"""
    assert ParsedPath('bar.tif', None, 'file').name == 'file://bar.tif'
Пример #9
0
def test_vsi_path_curl():
    """Correctly make and ordinary file path from a https path"""
    assert vsi_path(
        ParsedPath('example.com/foo.tif', None,
                   'https')) == '/vsicurl/https://example.com/foo.tif'
Пример #10
0
def test_parsed_path_name():
    """A parsed path's name property is correct"""
    assert ParsedPath('bar.tif', 'foo.zip',
                      'zip').name == 'zip://foo.zip!bar.tif'
Пример #11
0
def test_vsi_path_file():
    """Correctly make and ordinary file path from a file path"""
    assert vsi_path(ParsedPath('foo.tif', None, 'file')) == 'foo.tif'
Пример #12
0
def test_path_as_vsi_scheme():
    """Correctly make a vsi path"""
    assert ParsedPath('/foo.tif', 'tests/data/files.zip',
                      'zip').as_vsi() == '/vsizip/tests/data/files.zip/foo.tif'