Skip to content

Commit

Permalink
remove last bits of python2 / six (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-detiste authored Sep 25, 2023
1 parent 7e0678d commit ea32038
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 27 deletions.
6 changes: 1 addition & 5 deletions fiona/_crs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
Calls methods from GDAL's OSR module.
"""

from __future__ import absolute_import

import logging

from six import string_types

from fiona cimport _cpl
from fiona._err cimport exc_wrap_pointer
from fiona._err import CPLE_BaseError
Expand Down Expand Up @@ -38,7 +34,7 @@ def crs_to_wkt(crs):
crs = crs.to_wkt()

# First, check for CRS strings like "EPSG:3857".
if isinstance(crs, string_types):
if isinstance(crs, str):
proj_b = crs.encode('utf-8')
proj_c = proj_b
OSRSetFromUserInput(cogr_srs, proj_c)
Expand Down
2 changes: 0 additions & 2 deletions fiona/_err.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ manager raises a more useful and informative error:
ValueError: The PNG driver does not support update access to existing datasets.
"""

from __future__ import absolute_import

# CPL function declarations.
cdef extern from "cpl_error.h":

Expand Down
4 changes: 1 addition & 3 deletions fiona/_geometry.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Coordinate and geometry transformations.

from __future__ import absolute_import

include "gdal.pxi"

import logging
Expand All @@ -20,7 +18,7 @@ log.addHandler(NullHandler())


# mapping of GeoJSON type names to OGR integer geometry types
GEOJSON2OGR_GEOMETRY_TYPES = dict((v, k) for k, v in GEOMETRY_TYPES.iteritems())
GEOJSON2OGR_GEOMETRY_TYPES = dict((v, k) for k, v in GEOMETRY_TYPES.items())

cdef int ogr_get_geometry_type(void *geometry):
# OGR_G_GetGeometryType with NULL geometry support
Expand Down
1 change: 0 additions & 1 deletion fiona/_transform.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# distutils: language = c++
#
# Coordinate and geometry transformations.
from __future__ import absolute_import

include "gdal.pxi"

Expand Down
10 changes: 5 additions & 5 deletions fiona/_vendor/munch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
converted via Munch.to/fromDict().
"""

from .python3_compat import iterkeys, iteritems, Mapping #, u
from collections.abc import Mapping

__version__ = "2.5.0"
VERSION = tuple(map(int, __version__.split('.')[:3]))
Expand Down Expand Up @@ -190,7 +190,7 @@ def __repr__(self):
return '{0}({1})'.format(self.__class__.__name__, dict.__repr__(self))

def __dir__(self):
return list(iterkeys(self))
return list(self.keys())

def __getstate__(self):
""" Implement a serializable interface used for pickling.
Expand Down Expand Up @@ -229,7 +229,7 @@ def update(self, *args, **kwargs):
Override built-in method to call custom __setitem__ method that may
be defined in subclasses.
"""
for k, v in iteritems(dict(*args, **kwargs)):
for k, v in dict(*args, **kwargs).items():
self[k] = v

def get(self, k, d=None):
Expand Down Expand Up @@ -428,7 +428,7 @@ def post_munchify(partial, obj):
# Here we finish munchifying the parts of obj that were deferred by pre_munchify because they
# might be involved in a cycle
if isinstance(obj, Mapping):
partial.update((k, munchify_cycles(obj[k])) for k in iterkeys(obj))
partial.update((k, munchify_cycles(obj[k])) for k in obj.keys())
elif isinstance(obj, list):
partial.extend(munchify_cycles(item) for item in obj)
elif isinstance(obj, tuple):
Expand Down Expand Up @@ -490,7 +490,7 @@ def post_unmunchify(partial, obj):
# Here we finish unmunchifying the parts of obj that were deferred by pre_unmunchify because they
# might be involved in a cycle
if isinstance(obj, Mapping):
partial.update((k, unmunchify_cycles(obj[k])) for k in iterkeys(obj))
partial.update((k, unmunchify_cycles(obj[k])) for k in obj.keys())
elif isinstance(obj, list):
partial.extend(unmunchify_cycles(v) for v in obj)
elif isinstance(obj, tuple):
Expand Down
6 changes: 0 additions & 6 deletions fiona/_vendor/munch/python3_compat.py

This file was deleted.

4 changes: 1 addition & 3 deletions fiona/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
{'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84', 'no_defs': True}
"""

from six import string_types


def to_string(crs):
"""Turn a parameter mapping into a more conventional PROJ.4 string.
Expand All @@ -25,7 +23,7 @@ def to_string(crs):
for k, v in sorted(filter(
lambda x: x[0] in all_proj_keys and x[1] is not False and (
isinstance(x[1], (bool, int, float)) or
isinstance(x[1], string_types)),
isinstance(x[1], str)),
crs.items())):
items.append(
"+" + "=".join(
Expand Down
1 change: 0 additions & 1 deletion fiona/ogrext.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# These are extension functions and classes using the OGR C API.
from __future__ import absolute_import

include "gdal.pxi"

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dependencies = [
"click-plugins>=1.0",
"cligj>=0.5",
'importlib-metadata;python_version<"3.10"',
"six",
]

[project.optional-dependencies]
Expand Down

0 comments on commit ea32038

Please sign in to comment.