| 1 |
import glob |
| 2 |
import os |
| 3 |
from collections import defaultdict |
| 4 |
import re |
| 5 |
|
| 6 |
ignored_files = {'_shim.pyx', '_shim1.pyx', '_shim1.pxd', 'ogrext1.pxd'} |
| 7 |
|
| 8 |
# List of deprecated methods from https://gdal.org/doxygen/deprecated.html#_deprecated000028 |
| 9 |
deprecated = { |
| 10 |
'CPL_LSBINT16PTR', |
| 11 |
'CPL_LSBINT32PTR(x)', |
| 12 |
'OGR_Dr_CopyDataSource', |
| 13 |
'OGR_Dr_CreateDataSource', |
| 14 |
'OGR_Dr_DeleteDataSource', |
| 15 |
'OGR_Dr_Open', |
| 16 |
'OGR_Dr_TestCapability', |
| 17 |
'OGR_DS_CopyLayer', |
| 18 |
'OGR_DS_CreateLayer', |
| 19 |
'OGR_DS_DeleteLayer', |
| 20 |
'OGR_DS_Destroy', |
| 21 |
'OGR_DS_ExecuteSQL', |
| 22 |
'OGR_DS_GetDriver', |
| 23 |
'OGR_DS_GetLayer', |
| 24 |
'OGR_DS_GetLayerByName', |
| 25 |
'OGR_DS_GetLayerCount', |
| 26 |
'OGR_DS_GetName', |
| 27 |
'OGR_DS_ReleaseResultSet', |
| 28 |
'OGR_DS_TestCapability', |
| 29 |
'OGR_G_GetCoordinateDimension', |
| 30 |
'OGR_G_SetCoordinateDimension', |
| 31 |
'OGRGetDriver', |
| 32 |
'OGRGetDriverByName', |
| 33 |
'OGRGetDriverCount', |
| 34 |
'OGROpen', |
| 35 |
'OGROpenShared', |
| 36 |
'OGRRegisterAll', |
| 37 |
'OGRReleaseDataSource', |
| 38 |
} |
| 39 |
|
| 40 |
found_lines = defaultdict(list) |
| 41 |
files = glob.glob('fiona/*.pyx') + glob.glob('fiona/*.pxd') |
| 42 |
for path in files: |
| 43 |
if os.path.basename(path) in ignored_files: |
| 44 |
continue |
| 45 |
|
| 46 |
with open(path) as f: |
| 47 |
for i, line in enumerate(f): |
| 48 |
for deprecated_method in deprecated: |
| 49 |
match = re.search(fr'{deprecated_method}\s*\(', line) |
| 50 |
if match: |
| 51 |
found_lines[path].append((i+1, line.strip(), deprecated_method)) |
| 52 |
|
| 53 |
for path in sorted(found_lines): |
| 54 |
print(path) |
| 55 |
for line_nr, line, method in found_lines[path]: |
| 56 |
print(f"\t{line_nr}\t{line}") |
| 57 |
print("") |