remove Python2 crumbs

This commit is contained in:
Alexandre Detiste 2024-11-11 23:22:22 +01:00
parent 6b9549ea7a
commit 7f97a3f033
34 changed files with 56 additions and 63 deletions

View File

@ -1,6 +1,4 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import, division, print_function
import os import os
import sys import sys

View File

@ -222,7 +222,7 @@ def test_basic_test_9():
# Test gdal.PushErrorHandler() with a Python error handler as a method (#5186) # 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): def __init__(self):
self.eErrClass = None self.eErrClass = None
self.err_no = None self.err_no = None

View File

@ -559,7 +559,7 @@ def test_cog_byte_to_web_mercator():
filename2 = directory + "/cog2.tif" filename2 = directory + "/cog2.tif"
src_ds = gdal.Open(filename) src_ds = gdal.Open(filename)
class my_error_handler(object): class my_error_handler:
def __init__(self): def __init__(self):
self.debug_msg_list = [] self.debug_msg_list = []
self.other_msg_list = [] self.other_msg_list = []

View File

@ -254,7 +254,7 @@ def test_misc_5():
############################################################################### ###############################################################################
class misc_6_interrupt_callback_class(object): class misc_6_interrupt_callback_class:
def __init__(self): def __init__(self):
pass pass

View File

@ -3266,7 +3266,7 @@ def test_tiff_read_gcp_internal_and_auxxml(
# Test reading .tif + .aux # Test reading .tif + .aux
class myHandlerClass(object): class myHandlerClass:
def __init__(self): def __init__(self):
self.msg = None self.msg = None

View File

@ -893,7 +893,7 @@ def test_vsis3_2(aws_test_config_as_config_options_or_credentials, webserver_por
# Test temporary redirect # Test temporary redirect
handler = webserver.SequentialHandler() handler = webserver.SequentialHandler()
class HandlerClass(object): class HandlerClass:
def __init__(self, response_value): def __init__(self, response_value):
self.old_authorization = None self.old_authorization = None
self.response_value = response_value self.response_value = response_value
@ -1484,7 +1484,7 @@ def test_vsis3_readdir(aws_test_config, webserver_port):
# Test temporary redirect # Test temporary redirect
handler = webserver.SequentialHandler() handler = webserver.SequentialHandler()
class HandlerClass(object): class HandlerClass:
def __init__(self, response_value): def __init__(self, response_value):
self.old_authorization = None self.old_authorization = None
self.response_value = response_value self.response_value = response_value

View File

@ -60,7 +60,7 @@ def _get_mds_num(filename):
# #
class EnvisatTestBase(object): class EnvisatTestBase:
# Just a base class # Just a base class
def download_file(self): def download_file(self):

View File

@ -25,13 +25,13 @@ try:
from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer
except ImportError: except ImportError:
# To be able to run in standalone mode # To be able to run in standalone mode
class BaseDriver(object): class BaseDriver:
pass pass
class BaseDataset(object): class BaseDataset:
pass pass
class BaseLayer(object): class BaseLayer:
pass pass

View File

@ -582,7 +582,7 @@ def test_ogr_gmlas_abstractgeometry():
# Test validation against schema # Test validation against schema
class MyHandler(object): class MyHandler:
def __init__(self): def __init__(self):
self.error_list = [] self.error_list = []

View File

@ -74,7 +74,7 @@ def testCreateCopyInterruptCallback(pct, message, user_data):
############################################################################### ###############################################################################
class GDALTest(object): class GDALTest:
def __init__( def __init__(
self, self,
drivername, drivername,

View File

@ -39,7 +39,7 @@ def install_http_handler(handler_instance):
custom_handler = None custom_handler = None
class RequestResponse(object): class RequestResponse:
def __init__( def __init__(
self, self,
method, method,
@ -76,7 +76,7 @@ class RequestResponse(object):
) )
class FileHandler(object): class FileHandler:
""" """
Handler that serves files from a dictionary and/or a fallback VSI location. Handler that serves files from a dictionary and/or a fallback VSI location.
""" """
@ -197,7 +197,7 @@ class FileHandler(object):
self.send_response(request, filedata) self.send_response(request, filedata)
class BaseMockedHttpHandler(object): class BaseMockedHttpHandler:
@staticmethod @staticmethod
def _process_req_resp(req_resp, request): def _process_req_resp(req_resp, request):
if req_resp.custom_method: if req_resp.custom_method:

View File

@ -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(): def test_gdalbuildvrt_lib_warnings_and_custom_error_handler():
class GdalErrorHandler(object): class GdalErrorHandler:
def __init__(self): def __init__(self):
self.got_failure = False self.got_failure = False
self.got_warning = False self.got_warning = False

View File

@ -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): def test_gdaltindex_lib_already_existing_rasters(four_tiles, four_tile_index, tmp_path):
class GdalErrorHandler(object): class GdalErrorHandler:
def __init__(self): def __init__(self):
self.warnings = [] self.warnings = []
@ -147,7 +147,7 @@ def test_gdaltindex_skipDifferentProjection(tmp_path, four_tile_index):
ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1]) ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1])
ds = None ds = None
class GdalErrorHandler(object): class GdalErrorHandler:
def __init__(self): def __init__(self):
self.warning = None self.warning = None

View File

@ -232,7 +232,7 @@ But you can do something like this instead:
from osgeo import gdal from osgeo import gdal
class GdalErrorHandler(object): class GdalErrorHandler:
def __init__(self): def __init__(self):
self.err_level = gdal.CE_None self.err_level = gdal.CE_None
self.err_no = 0 self.err_no = 0

View File

@ -1630,7 +1630,7 @@ Given the following :file:`mandelbrot.py` file :
#print('Using numba') #print('Using numba')
g_max_iterations = 100 g_max_iterations = 100
except Exception: except Exception:
class jit(object): class jit:
def __init__(self, nopython = True, nogil = True): def __init__(self, nopython = True, nogil = True):
pass pass

View File

@ -24,13 +24,13 @@ try:
from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer
except ImportError: except ImportError:
# To be able to run in standalone mode # To be able to run in standalone mode
class BaseDriver(object): class BaseDriver:
pass pass
class BaseDataset(object): class BaseDataset:
pass pass
class BaseLayer(object): class BaseLayer:
pass pass

View File

@ -23,19 +23,18 @@ try:
from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer
except ImportError: except ImportError:
# To be able to run in standalone mode # To be able to run in standalone mode
class BaseDriver(object): class BaseDriver:
pass pass
class BaseDataset(object): class BaseDataset:
pass pass
class BaseLayer(object): class BaseLayer:
RandomRead = "RandomRead" RandomRead = "RandomRead"
FastSpatialFilter = "FastSpatialFilter" FastSpatialFilter = "FastSpatialFilter"
FastFeatureCount = "FastFeatureCount" FastFeatureCount = "FastFeatureCount"
FastGetExtent = "FastGetExtent" FastGetExtent = "FastGetExtent"
StringsAsUTF8 = "StringsAsUTF8" StringsAsUTF8 = "StringsAsUTF8"
pass
class Layer(BaseLayer): class Layer(BaseLayer):

View File

@ -126,7 +126,7 @@ static bool InitializePythonAndLoadGDALPythonDriverModule()
"import json\n" "import json\n"
"import inspect\n" "import inspect\n"
"import sys\n" "import sys\n"
"class BaseLayer(object):\n" "class BaseLayer:\n"
" RandomRead='RandomRead'\n" " RandomRead='RandomRead'\n"
" FastSpatialFilter='FastSpatialFilter'\n" " FastSpatialFilter='FastSpatialFilter'\n"
" FastFeatureCount='FastFeatureCount'\n" " FastFeatureCount='FastFeatureCount'\n"
@ -141,11 +141,11 @@ static bool InitializePythonAndLoadGDALPythonDriverModule()
"BaseLayer'\n" "BaseLayer'\n"
" return _gdal_python_driver.layer_featureCount(self, force)\n" " return _gdal_python_driver.layer_featureCount(self, force)\n"
"\n" "\n"
"class BaseDataset(object):\n" "class BaseDataset:\n"
" def __init__(self):\n" " def __init__(self):\n"
" pass\n" " pass\n"
"\n" "\n"
"class BaseDriver(object):\n" "class BaseDriver:\n"
" def __init__(self):\n" " def __init__(self):\n"
" pass\n" " pass\n"
"\n" "\n"

View File

@ -20,7 +20,7 @@ os.system(
) )
class Commit(object): class Commit:
def __init__(self): def __init__(self):
self.metadata = "" self.metadata = ""
self.message = "" self.message = ""

View File

@ -293,7 +293,7 @@ static void popErrorHandler()
} }
%pythoncode %{ %pythoncode %{
class ExceptionMgr(object): class ExceptionMgr:
""" """
Context manager to manage Python Exception state Context manager to manage Python Exception state
for GDAL/OGR/OSR/GNM. for GDAL/OGR/OSR/GNM.

View File

@ -20,8 +20,6 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# ****************************************************************************** # ******************************************************************************
from __future__ import division
import contextlib import contextlib
import glob import glob
import json import json
@ -129,7 +127,7 @@ class UnsupportedTileMatrixSet(Exception):
pass pass
class TileMatrixSet(object): class TileMatrixSet:
def __init__(self) -> None: def __init__(self) -> None:
self.identifier = None self.identifier = None
self.srs = None self.srs = None
@ -328,7 +326,7 @@ Class is available under the open-source GDAL license (www.gdal.org).
MAXZOOMLEVEL = 32 MAXZOOMLEVEL = 32
class GlobalMercator(object): class GlobalMercator:
r""" r"""
TMS Global Mercator Profile TMS Global Mercator Profile
--------------------------- ---------------------------
@ -547,7 +545,7 @@ class GlobalMercator(object):
return quadKey return quadKey
class GlobalGeodetic(object): class GlobalGeodetic:
r""" r"""
TMS Global Geodetic Profile TMS Global Geodetic Profile
--------------------------- ---------------------------
@ -644,7 +642,7 @@ class GlobalGeodetic(object):
return (b[1], b[0], b[3], b[2]) return (b[1], b[0], b[3], b[2])
class Zoomify(object): class Zoomify:
""" """
Tiles compatible with the Zoomify viewer Tiles compatible with the Zoomify viewer
---------------------------------------- ----------------------------------------
@ -2126,7 +2124,7 @@ def options_post_processing(
return options return options
class TileDetail(object): class TileDetail:
tx = 0 tx = 0
ty = 0 ty = 0
tz = 0 tz = 0
@ -2155,7 +2153,7 @@ class TileDetail(object):
return "TileDetail %s\n%s\n%s\n" % (self.tx, self.ty, self.tz) 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 Plain object to hold tile job configuration for a dataset
""" """
@ -2196,7 +2194,7 @@ class Gdal2TilesError(Exception):
pass pass
class GDAL2Tiles(object): class GDAL2Tiles:
def __init__(self, input_file: str, output_folder: str, options: Options) -> None: def __init__(self, input_file: str, output_folder: str, options: Options) -> None:
"""Constructor function - initialization""" """Constructor function - initialization"""
self.out_drv = None self.out_drv = None
@ -4463,7 +4461,7 @@ def worker_tile_details(
return tile_job_info, 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: def __init__(self, total_items: int, progress_cbk=gdal.TermProgress_nocb) -> None:
self.total_items = total_items self.total_items = total_items
self.nb_items_done = 0 self.nb_items_done = 0
@ -4632,7 +4630,7 @@ def multi_threaded_tiling(
shutil.rmtree(os.path.dirname(conf.src_file)) shutil.rmtree(os.path.dirname(conf.src_file))
class DividedCache(object): class DividedCache:
def __init__(self, nb_processes): def __init__(self, nb_processes):
self.nb_processes = nb_processes self.nb_processes = nb_processes

View File

@ -219,7 +219,7 @@ def names_to_fileinfos(names):
# ***************************************************************************** # *****************************************************************************
class file_info(object): class file_info:
"""A class holding information about a GDAL file.""" """A class holding information about a GDAL file."""
def __init__(self): def __init__(self):

View File

@ -12,8 +12,6 @@
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
############################################################################### ###############################################################################
from __future__ import print_function
import os import os
import sys import sys
@ -23,7 +21,7 @@ from osgeo_utils.auxiliary.util import enable_gdal_exceptions
progress = gdal.TermProgress_nocb progress = gdal.TermProgress_nocb
class AffineTransformDecorator(object): class AffineTransformDecorator:
"""A class providing some useful methods for affine Transformations""" """A class providing some useful methods for affine Transformations"""
def __init__(self, transform): def __init__(self, transform):
@ -54,7 +52,7 @@ class AffineTransformDecorator(object):
return [xlist, ylist] return [xlist, ylist]
class DataSetCache(object): class DataSetCache:
"""A class for caching source tiles""" """A class for caching source tiles"""
def __init__(self): def __init__(self):
@ -84,7 +82,7 @@ class DataSetCache(object):
del self.dict del self.dict
class tile_info(object): class tile_info:
"""A class holding info how to tile""" """A class holding info how to tile"""
def __init__(self, xsize, ysize, tileWidth, tileHeight, overlap): def __init__(self, xsize, ysize, tileWidth, tileHeight, overlap):
@ -113,7 +111,7 @@ class tile_info(object):
print("overlap: %d" % self.overlap) print("overlap: %d" % self.overlap)
class mosaic_info(object): class mosaic_info:
"""A class holding information about a GDAL file or a GDAL fileset""" """A class holding information about a GDAL file or a GDAL fileset"""
def __init__(self, filename, inputDS): def __init__(self, filename, inputDS):

View File

@ -97,7 +97,7 @@ def _Esc(x):
return gdal.EscapeString(x, gdal.CPLES_XML).decode("UTF-8") return gdal.EscapeString(x, gdal.CPLES_XML).decode("UTF-8")
class XMLWriter(object): class XMLWriter:
def __init__(self, f): def __init__(self, f):
self.f = f self.f = f
self.inc = 0 self.inc = 0

View File

@ -420,7 +420,7 @@ def parse_jp2file(inpath, xml_tree, out_f):
# Wrapper class for GDAL VSI*L API with class Python file interface # Wrapper class for GDAL VSI*L API with class Python file interface
class VSILFile(object): class VSILFile:
def __init__(self, filename, access): def __init__(self, filename, access):
self.f = gdal.VSIFOpenL(filename, access) self.f = gdal.VSIFOpenL(filename, access)

View File

@ -29,7 +29,7 @@ def Usage():
return 2 return 2
class Translator(object): class Translator:
def construct_parser(self): def construct_parser(self):
from optparse import OptionGroup, OptionParser from optparse import OptionGroup, OptionParser

View File

@ -33,7 +33,7 @@ def Usage():
return 2 return 2
class ScaledProgress(object): class ScaledProgress:
def __init__(self, dfMin, dfMax, UnderlyingProgress): def __init__(self, dfMin, dfMax, UnderlyingProgress):
self.dfMin = dfMin self.dfMin = dfMin
self.dfMax = dfMax self.dfMax = dfMax

View File

@ -54,7 +54,7 @@ def names_to_fileinfos(names):
# ***************************************************************************** # *****************************************************************************
class file_info(object): class file_info:
"""A class holding information about a GDAL file.""" """A class holding information about a GDAL file."""
def __init__(self): def __init__(self):

View File

@ -21,7 +21,7 @@ from osgeo import gdal
# dummy object to hold options # dummy object to hold options
class Options(object): class Options:
def __init__(self): def __init__(self):
self.verbose_flag = 0 self.verbose_flag = 0
self.append = 0 self.append = 0

View File

@ -83,7 +83,7 @@ def wkbFlatten(x):
############################################################### ###############################################################
class Options(object): class Options:
def __init__(self): def __init__(self):
self.lco = [] self.lco = []
self.dispatch_fields = [] self.dispatch_fields = []

View File

@ -19,7 +19,7 @@ from osgeo import ogr, osr
############################################################################# #############################################################################
class Module(object): class Module:
def __init__(self): def __init__(self):
self.lines = {} self.lines = {}
self.poly_line_links = {} self.poly_line_links = {}

View File

@ -40,7 +40,7 @@ map_ogr_geom_type_to_geoparquet = {
map_remote_resources = {} map_remote_resources = {}
class GeoParquetValidator(object): class GeoParquetValidator:
def __init__(self, filename, check_data=False, local_schema=None): def __init__(self, filename, check_data=False, local_schema=None):
self.filename = filename self.filename = filename
self.check_data = check_data self.check_data = check_data

View File

@ -65,7 +65,7 @@ class GPKGCheckException(Exception):
pass pass
class GPKGChecker(object): class GPKGChecker:
BASE_GEOM_TYPES = ( BASE_GEOM_TYPES = (
"GEOMETRY", "GEOMETRY",

View File

@ -191,7 +191,7 @@ def get_gmljp2(filename):
return mdd[0] return mdd[0]
class ErrorReport(object): class ErrorReport:
def __init__(self, collect_internally=False): def __init__(self, collect_internally=False):
self.error_count = 0 self.error_count = 0
self.warning_count = 0 self.warning_count = 0