Skip to content

Commit

Permalink
Merge pull request #11249 from a-detiste/master
Browse files Browse the repository at this point in the history
remove Python2 crumbs
  • Loading branch information
rouault authored Nov 11, 2024
2 parents 6b9549e + 7f97a3f commit 7c55296
Show file tree
Hide file tree
Showing 34 changed files with 56 additions and 63 deletions.
2 changes: 0 additions & 2 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# coding: utf-8
from __future__ import absolute_import, division, print_function

import os
import sys

Expand Down
2 changes: 1 addition & 1 deletion autotest/gcore/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_basic_test_9():
# Test gdal.PushErrorHandler() with a Python error handler as a method (#5186)


class my_python_error_handler_class(object):
class my_python_error_handler_class:
def __init__(self):
self.eErrClass = None
self.err_no = None
Expand Down
2 changes: 1 addition & 1 deletion autotest/gcore/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def my_cbk(pct, _, arg):
filename2 = directory + "/cog2.tif"
src_ds = gdal.Open(filename)

class my_error_handler(object):
class my_error_handler:
def __init__(self):
self.debug_msg_list = []
self.other_msg_list = []
Expand Down
2 changes: 1 addition & 1 deletion autotest/gcore/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def test_misc_5():


###############################################################################
class misc_6_interrupt_callback_class(object):
class misc_6_interrupt_callback_class:
def __init__(self):
pass

Expand Down
2 changes: 1 addition & 1 deletion autotest/gcore/tiff_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -3266,7 +3266,7 @@ def test_tiff_read_gcp_internal_and_auxxml(
# Test reading .tif + .aux


class myHandlerClass(object):
class myHandlerClass:
def __init__(self):
self.msg = None

Expand Down
4 changes: 2 additions & 2 deletions autotest/gcore/vsis3.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def method(request):
# Test temporary redirect
handler = webserver.SequentialHandler()

class HandlerClass(object):
class HandlerClass:
def __init__(self, response_value):
self.old_authorization = None
self.response_value = response_value
Expand Down Expand Up @@ -1484,7 +1484,7 @@ def method(request):
# Test temporary redirect
handler = webserver.SequentialHandler()

class HandlerClass(object):
class HandlerClass:
def __init__(self, response_value):
self.old_authorization = None
self.response_value = response_value
Expand Down
2 changes: 1 addition & 1 deletion autotest/gdrivers/envisat.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_mds_num(filename):
#


class EnvisatTestBase(object):
class EnvisatTestBase:
# Just a base class

def download_file(self):
Expand Down
6 changes: 3 additions & 3 deletions autotest/ogr/data/pydrivers/ogr_DUMMY.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer
except ImportError:
# To be able to run in standalone mode
class BaseDriver(object):
class BaseDriver:
pass

class BaseDataset(object):
class BaseDataset:
pass

class BaseLayer(object):
class BaseLayer:
pass


Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_gmlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def test_ogr_gmlas_abstractgeometry():
# Test validation against schema


class MyHandler(object):
class MyHandler:
def __init__(self):
self.error_list = []

Expand Down
2 changes: 1 addition & 1 deletion autotest/pymod/gdaltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def testCreateCopyInterruptCallback(pct, message, user_data):
###############################################################################


class GDALTest(object):
class GDALTest:
def __init__(
self,
drivername,
Expand Down
6 changes: 3 additions & 3 deletions autotest/pymod/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def install_http_handler(handler_instance):
custom_handler = None


class RequestResponse(object):
class RequestResponse:
def __init__(
self,
method,
Expand Down Expand Up @@ -76,7 +76,7 @@ def __repr__(self):
)


class FileHandler(object):
class FileHandler:
"""
Handler that serves files from a dictionary and/or a fallback VSI location.
"""
Expand Down Expand Up @@ -197,7 +197,7 @@ def do_DELETE(self, request):
self.send_response(request, filedata)


class BaseMockedHttpHandler(object):
class BaseMockedHttpHandler:
@staticmethod
def _process_req_resp(req_resp, request):
if req_resp.custom_method:
Expand Down
2 changes: 1 addition & 1 deletion autotest/utilities/test_gdalbuildvrt_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def test_gdalbuildvrt_lib_bandList_subset_of_bands_from_multiple_band_source():

###############################################################################
def test_gdalbuildvrt_lib_warnings_and_custom_error_handler():
class GdalErrorHandler(object):
class GdalErrorHandler:
def __init__(self):
self.got_failure = False
self.got_warning = False
Expand Down
4 changes: 2 additions & 2 deletions autotest/utilities/test_gdaltindex_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_gdaltindex_lib_basic(four_tile_index):


def test_gdaltindex_lib_already_existing_rasters(four_tiles, four_tile_index, tmp_path):
class GdalErrorHandler(object):
class GdalErrorHandler:
def __init__(self):
self.warnings = []

Expand Down Expand Up @@ -147,7 +147,7 @@ def test_gdaltindex_skipDifferentProjection(tmp_path, four_tile_index):
ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
ds = None

class GdalErrorHandler(object):
class GdalErrorHandler:
def __init__(self):
self.warning = None

Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/python_gotchas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ But you can do something like this instead:
from osgeo import gdal
class GdalErrorHandler(object):
class GdalErrorHandler:
def __init__(self):
self.err_level = gdal.CE_None
self.err_no = 0
Expand Down
2 changes: 1 addition & 1 deletion doc/source/drivers/raster/vrt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ Given the following :file:`mandelbrot.py` file :
#print('Using numba')
g_max_iterations = 100
except Exception:
class jit(object):
class jit:
def __init__(self, nopython = True, nogil = True):
pass
Expand Down
6 changes: 3 additions & 3 deletions examples/pydrivers/ogr_DUMMY.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer
except ImportError:
# To be able to run in standalone mode
class BaseDriver(object):
class BaseDriver:
pass

class BaseDataset(object):
class BaseDataset:
pass

class BaseLayer(object):
class BaseLayer:
pass


Expand Down
7 changes: 3 additions & 4 deletions examples/pydrivers/ogr_PASSTHROUGH.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@
from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer
except ImportError:
# To be able to run in standalone mode
class BaseDriver(object):
class BaseDriver:
pass

class BaseDataset(object):
class BaseDataset:
pass

class BaseLayer(object):
class BaseLayer:
RandomRead = "RandomRead"
FastSpatialFilter = "FastSpatialFilter"
FastFeatureCount = "FastFeatureCount"
FastGetExtent = "FastGetExtent"
StringsAsUTF8 = "StringsAsUTF8"
pass


class Layer(BaseLayer):
Expand Down
6 changes: 3 additions & 3 deletions gcore/gdalpythondriverloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static bool InitializePythonAndLoadGDALPythonDriverModule()
"import json\n"
"import inspect\n"
"import sys\n"
"class BaseLayer(object):\n"
"class BaseLayer:\n"
" RandomRead='RandomRead'\n"
" FastSpatialFilter='FastSpatialFilter'\n"
" FastFeatureCount='FastFeatureCount'\n"
Expand All @@ -141,11 +141,11 @@ static bool InitializePythonAndLoadGDALPythonDriverModule()
"BaseLayer'\n"
" return _gdal_python_driver.layer_featureCount(self, force)\n"
"\n"
"class BaseDataset(object):\n"
"class BaseDataset:\n"
" def __init__(self):\n"
" pass\n"
"\n"
"class BaseDriver(object):\n"
"class BaseDriver:\n"
" def __init__(self):\n"
" pass\n"
"\n"
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_log_feature_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)


class Commit(object):
class Commit:
def __init__(self):
self.metadata = ""
self.message = ""
Expand Down
2 changes: 1 addition & 1 deletion swig/include/python/python_exceptions.i
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static void popErrorHandler()
}

%pythoncode %{
class ExceptionMgr(object):
class ExceptionMgr:
"""
Context manager to manage Python Exception state
for GDAL/OGR/OSR/GNM.
Expand Down
20 changes: 9 additions & 11 deletions swig/python/gdal-utils/osgeo_utils/gdal2tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# SPDX-License-Identifier: MIT
# ******************************************************************************

from __future__ import division

import contextlib
import glob
import json
Expand Down Expand Up @@ -129,7 +127,7 @@ class UnsupportedTileMatrixSet(Exception):
pass


class TileMatrixSet(object):
class TileMatrixSet:
def __init__(self) -> None:
self.identifier = None
self.srs = None
Expand Down Expand Up @@ -328,7 +326,7 @@ def get_profile_list():
MAXZOOMLEVEL = 32


class GlobalMercator(object):
class GlobalMercator:
r"""
TMS Global Mercator Profile
---------------------------
Expand Down Expand Up @@ -547,7 +545,7 @@ def QuadTree(self, tx, ty, zoom):
return quadKey


class GlobalGeodetic(object):
class GlobalGeodetic:
r"""
TMS Global Geodetic Profile
---------------------------
Expand Down Expand Up @@ -644,7 +642,7 @@ def TileLatLonBounds(self, tx, ty, zoom):
return (b[1], b[0], b[3], b[2])


class Zoomify(object):
class Zoomify:
"""
Tiles compatible with the Zoomify viewer
----------------------------------------
Expand Down Expand Up @@ -2126,7 +2124,7 @@ def options_post_processing(
return options


class TileDetail(object):
class TileDetail:
tx = 0
ty = 0
tz = 0
Expand Down Expand Up @@ -2155,7 +2153,7 @@ def __repr__(self):
return "TileDetail %s\n%s\n%s\n" % (self.tx, self.ty, self.tz)


class TileJobInfo(object):
class TileJobInfo:
"""
Plain object to hold tile job configuration for a dataset
"""
Expand Down Expand Up @@ -2196,7 +2194,7 @@ class Gdal2TilesError(Exception):
pass


class GDAL2Tiles(object):
class GDAL2Tiles:
def __init__(self, input_file: str, output_folder: str, options: Options) -> None:
"""Constructor function - initialization"""
self.out_drv = None
Expand Down Expand Up @@ -4463,7 +4461,7 @@ def worker_tile_details(
return tile_job_info, tile_details


class ProgressBar(object):
class ProgressBar:
def __init__(self, total_items: int, progress_cbk=gdal.TermProgress_nocb) -> None:
self.total_items = total_items
self.nb_items_done = 0
Expand Down Expand Up @@ -4632,7 +4630,7 @@ def multi_threaded_tiling(
shutil.rmtree(os.path.dirname(conf.src_file))


class DividedCache(object):
class DividedCache:
def __init__(self, nb_processes):
self.nb_processes = nb_processes

Expand Down
2 changes: 1 addition & 1 deletion swig/python/gdal-utils/osgeo_utils/gdal_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def names_to_fileinfos(names):
# *****************************************************************************


class file_info(object):
class file_info:
"""A class holding information about a GDAL file."""

def __init__(self):
Expand Down
Loading

0 comments on commit 7c55296

Please sign in to comment.