/usr/lib/python3/dist-packages/rasterio/vfs.py is in python3-rasterio 0.31.0-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """Implementation of Apache VFS schemes and URLs"""
import os
# NB: As not to propagate fallacies of distributed computing, Rasterio
# does not support HTTP or FTP URLs via GDAL's vsicurl handler. Only
# the following local filesystem schemes are supported.
SCHEMES = ['gzip', 'zip', 'tar']
def parse_path(path, vfs=None):
"""Parse a file path or Apache VFS URL into its parts."""
archive = scheme = None
if vfs:
parts = vfs.split("://")
scheme = parts.pop(0) if parts else None
archive = parts.pop(0) if parts else None
else:
parts = path.split("://")
path = parts.pop() if parts else None
scheme = parts.pop() if parts else None
if scheme in SCHEMES:
parts = path.split('!')
path = parts.pop() if parts else None
archive = parts.pop() if parts else None
elif scheme in (None, 'file'):
pass
else:
raise ValueError("VFS scheme {0} is unknown".format(scheme))
return path, archive, scheme
def vsi_path(path, archive=None, scheme=None):
"""Convert a parsed path to a GDAL VSI path."""
# If a VSF and archive file are specified, we convert the path to
# a GDAL VSI path (see cpl_vsi.h).
if scheme and scheme != 'file':
path = path.strip(os.path.sep)
result = os.path.sep.join(['/vsi{0}'.format(scheme), archive, path])
else:
result = path
return result
|