How to use the fiona.errors.FionaDeprecationWarning function in fiona

To help you get started, we’ve selected a few fiona examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Toblerity / Fiona / tests / test_non_counting_layer.py View on Github external
def test_slice(self):
        with pytest.warns(FionaDeprecationWarning):
            features = self.c[2:5]
            assert len(features) == 3
github Toblerity / Fiona / tests / test_non_counting_layer.py View on Github external
def test_fail_slice_negative_index(self):
        with pytest.warns(FionaDeprecationWarning):
            with pytest.raises(IndexError):
                self.c[2:-4]
github Toblerity / Fiona / tests / test_drivers.py View on Github external
def test_options(tmpdir, path_coutwildrnp_shp):
    """Test that setting CPL_DEBUG=ON works and that a warning is raised."""
    logfile = str(tmpdir.mkdir('tests').join('test_options.log'))
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    fh = logging.FileHandler(logfile)
    fh.setLevel(logging.DEBUG)
    logger.addHandler(fh)

    # fiona.drivers() will be deprecated.
    with pytest.warns(FionaDeprecationWarning):
        with fiona.drivers(CPL_DEBUG=True):
            c = fiona.open(path_coutwildrnp_shp)
            c.close()
            with open(logfile, "r") as f:
                log = f.read()
            if fiona.gdal_version.major >= 2:
                assert "GDALOpen" in log
            else:
                assert "OGROpen" in log
github Toblerity / Fiona / tests / test_model.py View on Github external
"""Delegation in __setitem__ works"""

    class ThingDelegate(object):
        def __init__(self, value):
            self.value = value

    class Thing(Object):
        _delegated_properties = ["value"]

        def __init__(self, value=None, **data):
            self._delegate = ThingDelegate(value)
            super(Thing, self).__init__(**data)

    thing = Thing()
    assert thing["value"] is None
    with pytest.warns(FionaDeprecationWarning, match="immutable"):
        thing["value"] = 1
    assert thing["value"] == 1
github Toblerity / Fiona / tests / test_slice.py View on Github external
def test_collection_slice(path_coutwildrnp_shp):
    with pytest.warns(FionaDeprecationWarning), fiona.open(path_coutwildrnp_shp) as src:
        results = src[:5]
        assert isinstance(results, list)
        assert len(results) == 5
        assert results[4]['id'] == '4'
github Toblerity / Fiona / fiona / model.py View on Github external
def __delitem__(self, key):
        warn(
            "instances of this class -- CRS, geometry, and feature objects -- will become immutable in fiona version 2.0",
            FionaDeprecationWarning,
            stacklevel=2,
        )
        if key in self._delegated_properties:
            setattr(self._delegate, key, None)
        else:
            del self._data[key]
github OGGM / oggm-edu / docs / conf.py View on Github external
try:
    import netCDF4
    print("netCDF4: %s, %s" % (netCDF4.__version__, netCDF4.__file__))
except ImportError:
    print("no netCDF4")
try:
    import skimage
    print("skimage: %s, %s" % (skimage.__version__, skimage.__file__))
except ImportError:
    print("no skimage")

# Remove some warnings
try:
    import warnings
    from fiona.errors import FionaDeprecationWarning
    warnings.filterwarnings('ignore', category=FionaDeprecationWarning)
except ImportError:
    pass

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary',
    'sphinx.ext.intersphinx',
    'sphinx.ext.extlinks',
github Toblerity / Fiona / fiona / __init__.py View on Github external
def drivers(*args, **kwargs):
    """Returns a context manager with registered drivers.

    DEPRECATED
    """
    warnings.warn("Use fiona.Env() instead.", FionaDeprecationWarning, stacklevel=2)

    if driver_count == 0:
        log.debug("Creating a chief GDALEnv in drivers()")
        return Env(**kwargs)
    else:
        log.debug("Creating a not-responsible GDALEnv in drivers()")
        return Env(**kwargs)
github Toblerity / Fiona / fiona / model.py View on Github external
def __setitem__(self, key, value):
        warn(
            "instances of this class -- CRS, geometry, and feature objects -- will become immutable in fiona version 2.0",
            FionaDeprecationWarning,
            stacklevel=2,
        )
        if key in self._delegated_properties:
            setattr(self._delegate, key, value)
        else:
            self._data[key] = value
github Toblerity / Fiona / fiona / collection.py View on Github external
def __next__(self):
        """Returns next record from iterator."""
        warnings.warn("Collection.__next__() is buggy and will be removed in "
                      "Fiona 2.0. Switch to `next(iter(collection))`.",
                      FionaDeprecationWarning, stacklevel=2)
        if not self.iterator:
            iter(self)
        return next(self.iterator)