From dd1226aeada6caa5801a59e600373dce672ca131 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 20:42:08 +0000 Subject: [PATCH 1/8] removed flake8 from first 2 files --- doc/python/raster_example_ctypes.py | 11 +++++++++-- doc/python/vector_example_ctypes.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/python/raster_example_ctypes.py b/doc/python/raster_example_ctypes.py index f62ce4a9492..4ef23451761 100644 --- a/doc/python/raster_example_ctypes.py +++ b/doc/python/raster_example_ctypes.py @@ -17,9 +17,16 @@ import os import sys +import math -from grass.lib.gis import * -from grass.lib.raster import * +from ctypes import POINTER, c_int, c_float, c_double, c_void_p, cast + +from grass.lib.gis import G_gisinit, G_find_raster2, G_free +from grass.lib.raster import ( + Rast_map_type, CELL_TYPE, FCELL_TYPE, DCELL_TYPE, + Rast_open_old, Rast_allocate_buf, Rast_window_rows, + Rast_window_cols, Rast_get_row, Rast_close +) # check if GRASS is running or not if "GISBASE" not in os.environ: diff --git a/doc/python/vector_example_ctypes.py b/doc/python/vector_example_ctypes.py index 9f8a90d6459..bdf85178dcb 100644 --- a/doc/python/vector_example_ctypes.py +++ b/doc/python/vector_example_ctypes.py @@ -7,9 +7,16 @@ import os import sys +from ctypes import pointer, byref -from grass.lib.gis import * -from grass.lib.vector import * +# Import specific functions and classes instead of using wildcard imports +from grass.lib.gis import G_gisinit, G_find_vector2 +from grass.lib.vector import ( + Map_info, Vect_set_open_level, Vect_open_old, Vect_get_full_name, + Vect_is_3d, Vect_get_num_dblinks, Vect_get_scale, Vect_get_map_box, + Vect_point_in_box, Vect_get_num_lines, Vect_get_num_primitives, + Vect_get_num_areas, Vect_close, bound_box, GV_POINT, GV_LINE +) if "GISBASE" not in os.environ: sys.exit("You must be in GRASS GIS to run this program.") From 2292046248b04025ce3adc9107dbfe97747cadc9 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 20:42:40 +0000 Subject: [PATCH 2/8] updated .flake8 --- .flake8 | 2 -- 1 file changed, 2 deletions(-) diff --git a/.flake8 b/.flake8 index e72eaa73333..df73ebe4971 100644 --- a/.flake8 +++ b/.flake8 @@ -22,8 +22,6 @@ per-file-ignores = __init__.py: F401, F403 man/build_html.py: E501 imagery/i.atcorr/create_iwave.py: F632, F821, W293 - doc/python/raster_example_ctypes.py: F403, F405 - doc/python/vector_example_ctypes.py: F403, F405 doc/python/m.distance.py: F403, F405, E501 doc/gui/wxpython/example/dialogs.py: F401 locale/grass_po_stats.py: E122, E128, E231, E401, E722 From 90ae7510b78e355768853e2f8185997f49aa9ac2 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 22:12:31 +0000 Subject: [PATCH 3/8] remove flake8 from distance.py --- .flake8 | 1 - doc/python/m.distance.py | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index df73ebe4971..4f383ee9467 100644 --- a/.flake8 +++ b/.flake8 @@ -22,7 +22,6 @@ per-file-ignores = __init__.py: F401, F403 man/build_html.py: E501 imagery/i.atcorr/create_iwave.py: F632, F821, W293 - doc/python/m.distance.py: F403, F405, E501 doc/gui/wxpython/example/dialogs.py: F401 locale/grass_po_stats.py: E122, E128, E231, E401, E722 gui/scripts/d.wms.py: E501 diff --git a/doc/python/m.distance.py b/doc/python/m.distance.py index 5eddb1dcc56..35a3776aa59 100755 --- a/doc/python/m.distance.py +++ b/doc/python/m.distance.py @@ -25,7 +25,7 @@ # %module # % label: Finds the distance between two or more points. -# % description: If the projection is latitude-longitude, this distance is measured along the geodesic. +# % description: If the projection is lat-long, distance measured along the geodesic. # % keyword: miscellaneous # % keyword: distance # % keyword: measure @@ -45,10 +45,15 @@ # %end import sys +from ctypes import byref, c_double import grass.script as gs - -from grass.lib.gis import * +from grass.lib.gis import ( + G_gisinit, G_begin_distance_calculations, G_scan_easting, G_scan_northing, + G_distance, G_begin_polygon_area_calculations, G_area_of_polygon, + G_database_units_to_meters_factor, G_database_unit_name, + PROJECTION_LL +) def main(): From 331d5fa4972517b97ccf6ef89323431ddd4a578f Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 15:20:39 -0700 Subject: [PATCH 4/8] Update doc/python/m.distance.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- doc/python/m.distance.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/python/m.distance.py b/doc/python/m.distance.py index 35a3776aa59..da0e61cdebf 100755 --- a/doc/python/m.distance.py +++ b/doc/python/m.distance.py @@ -49,10 +49,16 @@ import grass.script as gs from grass.lib.gis import ( - G_gisinit, G_begin_distance_calculations, G_scan_easting, G_scan_northing, - G_distance, G_begin_polygon_area_calculations, G_area_of_polygon, - G_database_units_to_meters_factor, G_database_unit_name, - PROJECTION_LL + G_gisinit, + G_begin_distance_calculations, + G_scan_easting, + G_scan_northing, + G_distance, + G_begin_polygon_area_calculations, + G_area_of_polygon, + G_database_units_to_meters_factor, + G_database_unit_name, + PROJECTION_LL, ) From 5cd609973c02c34280b29025b918bcee162dbf77 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 15:20:45 -0700 Subject: [PATCH 5/8] Update doc/python/vector_example_ctypes.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- doc/python/vector_example_ctypes.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/python/vector_example_ctypes.py b/doc/python/vector_example_ctypes.py index bdf85178dcb..ae3877224d0 100644 --- a/doc/python/vector_example_ctypes.py +++ b/doc/python/vector_example_ctypes.py @@ -12,10 +12,22 @@ # Import specific functions and classes instead of using wildcard imports from grass.lib.gis import G_gisinit, G_find_vector2 from grass.lib.vector import ( - Map_info, Vect_set_open_level, Vect_open_old, Vect_get_full_name, - Vect_is_3d, Vect_get_num_dblinks, Vect_get_scale, Vect_get_map_box, - Vect_point_in_box, Vect_get_num_lines, Vect_get_num_primitives, - Vect_get_num_areas, Vect_close, bound_box, GV_POINT, GV_LINE + Map_info, + Vect_set_open_level, + Vect_open_old, + Vect_get_full_name, + Vect_is_3d, + Vect_get_num_dblinks, + Vect_get_scale, + Vect_get_map_box, + Vect_point_in_box, + Vect_get_num_lines, + Vect_get_num_primitives, + Vect_get_num_areas, + Vect_close, + bound_box, + GV_POINT, + GV_LINE, ) if "GISBASE" not in os.environ: From c1072e106fecd7cceba15a4844d6e27ad0815b6d Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 15:20:51 -0700 Subject: [PATCH 6/8] Update doc/python/raster_example_ctypes.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- doc/python/raster_example_ctypes.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/python/raster_example_ctypes.py b/doc/python/raster_example_ctypes.py index 4ef23451761..67f7a2cf4cb 100644 --- a/doc/python/raster_example_ctypes.py +++ b/doc/python/raster_example_ctypes.py @@ -23,9 +23,16 @@ from grass.lib.gis import G_gisinit, G_find_raster2, G_free from grass.lib.raster import ( - Rast_map_type, CELL_TYPE, FCELL_TYPE, DCELL_TYPE, - Rast_open_old, Rast_allocate_buf, Rast_window_rows, - Rast_window_cols, Rast_get_row, Rast_close + Rast_map_type, + CELL_TYPE, + FCELL_TYPE, + DCELL_TYPE, + Rast_open_old, + Rast_allocate_buf, + Rast_window_rows, + Rast_window_cols, + Rast_get_row, + Rast_close, ) # check if GRASS is running or not From 5f2a26ce5e7727c4f616ce4c655fa471d2d749b3 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 16:02:39 -0700 Subject: [PATCH 7/8] Update m.distance.py --- doc/python/m.distance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/m.distance.py b/doc/python/m.distance.py index da0e61cdebf..576760c3b40 100755 --- a/doc/python/m.distance.py +++ b/doc/python/m.distance.py @@ -25,7 +25,7 @@ # %module # % label: Finds the distance between two or more points. -# % description: If the projection is lat-long, distance measured along the geodesic. +# % description: If the projection is latitude-longitude, this distance is measured along the geodesic. # % keyword: miscellaneous # % keyword: distance # % keyword: measure From 0f90e3e8405fcf8f496c73cbd1444853647ed2ad Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Fri, 20 Sep 2024 16:07:07 -0700 Subject: [PATCH 8/8] Update .flake8 --- .flake8 | 1 + 1 file changed, 1 insertion(+) diff --git a/.flake8 b/.flake8 index 4f383ee9467..bd33e493bfc 100644 --- a/.flake8 +++ b/.flake8 @@ -22,6 +22,7 @@ per-file-ignores = __init__.py: F401, F403 man/build_html.py: E501 imagery/i.atcorr/create_iwave.py: F632, F821, W293 + doc/python/m.distance.py: E501 doc/gui/wxpython/example/dialogs.py: F401 locale/grass_po_stats.py: E122, E128, E231, E401, E722 gui/scripts/d.wms.py: E501