From 797784e7831061585b1fef1bc1349f9bdfaf7152 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 15:50:42 -0500 Subject: [PATCH 01/16] fixed 401 in app --- .flake8 | 4 +--- python/grass/app/__init__.py | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index ab4038e4749..94bf0a5dbce 100644 --- a/.flake8 +++ b/.flake8 @@ -84,9 +84,7 @@ per-file-ignores = python/grass/imaging/images2gif.py: E226 # Unused imports in init files # F403 star import used; unable to detect undefined names - python/grass/*/__init__.py: F401, F403 - python/grass/*/*/__init__.py: F403 - python/grass/*/*/*/__init__.py: F403 + python/grass/*/__init__.py: F401 # E402 module level import not at top of file scripts/r.semantic.label/r.semantic.label.py: E501 scripts/db.out.ogr/db.out.ogr.py: F841 diff --git a/python/grass/app/__init__.py b/python/grass/app/__init__.py index df22d8bbb44..4c22d84ebe3 100644 --- a/python/grass/app/__init__.py +++ b/python/grass/app/__init__.py @@ -1 +1,21 @@ -from .data import * +from .data import ( + get_possible_database_path, + create_database_directory, + _get_startup_location_in_distribution, + _copy_startup_location, + create_startup_location_in_grassdb, + ensure_default_data_hierarchy, + MapsetLockingException, + lock_mapset, +) + +__all__ = [ + "MapsetLockingException", + "_copy_startup_location", + "_get_startup_location_in_distribution", + "create_database_directory", + "create_startup_location_in_grassdb", + "ensure_default_data_hierarchy", + "get_possible_database_path", + "lock_mapset", +] From 9f8494bc8bf068527358f2386bb8cc9f0e92c472 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 15:59:09 -0500 Subject: [PATCH 02/16] experimental update --- python/grass/experimental/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/grass/experimental/__init__.py b/python/grass/experimental/__init__.py index 1253d09df0a..8ccb44413bb 100644 --- a/python/grass/experimental/__init__.py +++ b/python/grass/experimental/__init__.py @@ -1,4 +1,11 @@ """Experimental code, all can change""" -from .create import * -from .mapset import * +from .create import require_create_ensure_mapset, create_temporary_mapset +from .mapset import MapsetSession, TemporaryMapsetSession + +__all__ = [ + "MapsetSession", + "TemporaryMapsetSession", + "create_temporary_mapset", + "require_create_ensure_mapset", +] From a34f0e888f0d5a88168e5fa6e87d3b8f4b3a2076 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 16:09:45 -0500 Subject: [PATCH 03/16] experimental update --- python/grass/app/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/python/grass/app/__init__.py b/python/grass/app/__init__.py index 4c22d84ebe3..b7ff0ce08c0 100644 --- a/python/grass/app/__init__.py +++ b/python/grass/app/__init__.py @@ -1,8 +1,6 @@ from .data import ( get_possible_database_path, create_database_directory, - _get_startup_location_in_distribution, - _copy_startup_location, create_startup_location_in_grassdb, ensure_default_data_hierarchy, MapsetLockingException, @@ -11,8 +9,6 @@ __all__ = [ "MapsetLockingException", - "_copy_startup_location", - "_get_startup_location_in_distribution", "create_database_directory", "create_startup_location_in_grassdb", "ensure_default_data_hierarchy", From 27b1f2022aebad3bbeeec26bbbcb490c575219b0 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 17:08:09 -0500 Subject: [PATCH 04/16] update --- .flake8 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 94bf0a5dbce..ab4038e4749 100644 --- a/.flake8 +++ b/.flake8 @@ -84,7 +84,9 @@ per-file-ignores = python/grass/imaging/images2gif.py: E226 # Unused imports in init files # F403 star import used; unable to detect undefined names - python/grass/*/__init__.py: F401 + python/grass/*/__init__.py: F401, F403 + python/grass/*/*/__init__.py: F403 + python/grass/*/*/*/__init__.py: F403 # E402 module level import not at top of file scripts/r.semantic.label/r.semantic.label.py: E501 scripts/db.out.ogr/db.out.ogr.py: F841 From 81b96e2b501a367cd4061f95504b586da8f0810b Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 17:50:56 -0500 Subject: [PATCH 05/16] update --- python/grass/script/__init__.py | 186 ++++++++++++++++++++++++++++++-- 1 file changed, 180 insertions(+), 6 deletions(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index ea82c2fe451..bf15ffeeebe 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -1,10 +1,184 @@ """Python interface to launch GRASS GIS modules in scripts """ -from .core import * -from .db import * -from .raster import * -from .raster3d import * -from .vector import * -from .utils import * +from .core import ( + call, + create_environment, + create_location, + create_project, + compare_key_value_text_files, + debug, + debug_level, + del_temp_region, + error, + exec_command, + fatal, + feed_command, + find_file, + find_program, + gisenv, + get_commands, + get_real_command, + handle_errors, + get_raise_on_error, + get_capture_stderr, + info, + legal_name, + list_grouped, + list_pairs, + list_strings, + locn_is_latlong, + make_command, + mapsets, + message, + overwrite, + parse_command, + parse_color, + parser, + percent, + pipe_command, + read_command, + region, + region_env, + run_command, + set_raise_on_error, + start_command, + sanitize_mapset_environment, + set_capture_stderr, + tempdir, + tempfile, + tempname, + use_temp_region, + version, + verbose, + verbosity, + warning, + write_command, +) + +from .db import ( + db_begin_transaction, + db_commit_transaction, + db_connection, + db_describe, + db_select, + db_table_exist, + db_table_in_vector, +) + +from .raster import mapcalc, mapcalc_start, raster_history, raster_info, raster_what + +from .raster3d import mapcalc3d, raster3d_info + +from .utils import ( + KeyValue, + basename, + decode, + encode, + float_or_dms, + parse_key_val, + try_remove, +) + +from .vector import ( + vector_db, + vector_layer_db, + vector_columns, + vector_history, + vector_info_topo, + vector_info, + vector_db_select, + vector_what, +) from . import setup # noqa: F401 + +__all__ = [ + # utils imports + "KeyValue", + "basename", + # core imports + "call", + "compare_key_value_text_files", + "create_environment", + "create_location", + "create_project", + # db imports + "db_begin_transaction", + "db_commit_transaction", + "db_connection", + "db_describe", + "db_select", + "db_table_exist", + "db_table_in_vector", + "debug", + "debug_level", + "decode", + "del_temp_region", + "encode", + "error", + "exec_command", + "fatal", + "feed_command", + "find_file", + "find_program", + "float_or_dms", + "get_capture_stderr", + "get_commands", + "get_raise_on_error", + "get_real_command", + "gisenv", + "handle_errors", + "info", + "legal_name", + "list_grouped", + "list_pairs", + "list_strings", + "locn_is_latlong", + "make_command", + # raster imports + "mapcalc", + # raster3d imports + "mapcalc3d", + "mapcalc_start", + "mapsets", + "message", + "overwrite", + "parse_color", + "parse_command", + "parse_key_val", + "parser", + "percent", + "pipe_command", + "raster3d_info", + "raster_history", + "raster_info", + "raster_what", + "read_command", + "region", + "region_env", + "run_command", + "sanitize_mapset_environment", + "set_capture_stderr", + "set_raise_on_error", + "start_command", + "tempdir", + "tempfile", + "tempname", + "try_remove", + "use_temp_region", + "vector_columns", + # vector imports + "vector_db", + "vector_db", + "vector_db_select", + "vector_history", + "vector_info", + "vector_info_topo", + "vector_layer_db", + "vector_what", + "verbose", + "verbosity", + "version", + "warning", + "write_command", +] From c43b03bc04c7731996b7123de738abecaf03c50f Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 19:56:26 -0500 Subject: [PATCH 06/16] update --- python/grass/script/__init__.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index bf15ffeeebe..14c43aeec95 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -78,6 +78,20 @@ float_or_dms, parse_key_val, try_remove, + diff_files, + try_rmdir, + text_to_string, + get_num_suffix, + split, + natural_sort, + naturally_sorted, + get_lib_path, + set_path, + clock, + legalize_vector_name, + append_node_pid, + append_uuid, + append_random, ) from .vector import ( @@ -95,9 +109,13 @@ __all__ = [ # utils imports "KeyValue", + "append_node_pid", + "append_random", + "append_uuid", "basename", # core imports "call", + "clock", "compare_key_value_text_files", "create_environment", "create_location", @@ -113,7 +131,10 @@ "debug", "debug_level", "decode", + "decode", "del_temp_region", + "diff_files", + "encode", "encode", "error", "exec_command", @@ -122,14 +143,18 @@ "find_file", "find_program", "float_or_dms", + "float_or_dms", "get_capture_stderr", "get_commands", + "get_lib_path", + "get_num_suffix", "get_raise_on_error", "get_real_command", "gisenv", "handle_errors", "info", "legal_name", + "legalize_vector_name", "list_grouped", "list_pairs", "list_strings", @@ -142,10 +167,14 @@ "mapcalc_start", "mapsets", "message", + "natural_sort", + "naturally_sorted", "overwrite", "parse_color", "parse_command", "parse_key_val", + "parse_key_val", + "parse_key_val", "parser", "percent", "pipe_command", @@ -159,12 +188,17 @@ "run_command", "sanitize_mapset_environment", "set_capture_stderr", + "set_path", "set_raise_on_error", + "split", "start_command", "tempdir", "tempfile", "tempname", + "text_to_string", + "try_remove", "try_remove", + "try_rmdir", "use_temp_region", "vector_columns", # vector imports From 900900906e940dd5f302b8fda3ff0bbf66c16032 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 20:06:42 -0500 Subject: [PATCH 07/16] update --- python/grass/script/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index 14c43aeec95..bca9768ea6c 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -54,6 +54,7 @@ verbosity, warning, write_command, + PIPE, ) from .db import ( @@ -92,6 +93,7 @@ append_node_pid, append_uuid, append_random, + separator, ) from .vector import ( @@ -107,6 +109,7 @@ from . import setup # noqa: F401 __all__ = [ + "PIPE", # utils imports "KeyValue", "append_node_pid", @@ -187,6 +190,7 @@ "region_env", "run_command", "sanitize_mapset_environment", + "separator", "set_capture_stderr", "set_path", "set_raise_on_error", From 40d25c490c667e702eb8c2a90520512d3a8d4c59 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 20:07:58 -0500 Subject: [PATCH 08/16] update --- python/grass/script/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index bca9768ea6c..d21882a4b2c 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -54,7 +54,6 @@ verbosity, warning, write_command, - PIPE, ) from .db import ( @@ -109,7 +108,6 @@ from . import setup # noqa: F401 __all__ = [ - "PIPE", # utils imports "KeyValue", "append_node_pid", From d7efcc512ae39a5db96bec0e293e4cbf44794b3c Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 20:09:58 -0500 Subject: [PATCH 09/16] update --- python/grass/script/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index d21882a4b2c..bca9768ea6c 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -54,6 +54,7 @@ verbosity, warning, write_command, + PIPE, ) from .db import ( @@ -108,6 +109,7 @@ from . import setup # noqa: F401 __all__ = [ + "PIPE", # utils imports "KeyValue", "append_node_pid", From 0c87b4b276eb8627bacf78167f9d03621c770201 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Tue, 5 Nov 2024 14:24:29 -0500 Subject: [PATCH 10/16] fixed --- python/grass/script/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index bca9768ea6c..323e9e8cf74 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -201,7 +201,6 @@ "tempname", "text_to_string", "try_remove", - "try_remove", "try_rmdir", "use_temp_region", "vector_columns", From 492b4b835da9295d63f4eb8f16e8b0e4d0a753ce Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Thu, 7 Nov 2024 22:50:43 -0500 Subject: [PATCH 11/16] removed comment --- python/grass/script/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index 323e9e8cf74..fcaf6bf3a21 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -110,20 +110,17 @@ __all__ = [ "PIPE", - # utils imports "KeyValue", "append_node_pid", "append_random", "append_uuid", "basename", - # core imports "call", "clock", "compare_key_value_text_files", "create_environment", "create_location", "create_project", - # db imports "db_begin_transaction", "db_commit_transaction", "db_connection", @@ -163,9 +160,7 @@ "list_strings", "locn_is_latlong", "make_command", - # raster imports "mapcalc", - # raster3d imports "mapcalc3d", "mapcalc_start", "mapsets", @@ -204,7 +199,6 @@ "try_rmdir", "use_temp_region", "vector_columns", - # vector imports "vector_db", "vector_db", "vector_db_select", From 6d7381ebfd31933a253222af308f8813c39580d3 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 11 Nov 2024 09:10:24 -0500 Subject: [PATCH 12/16] removed duplicates --- python/grass/script/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index fcaf6bf3a21..02973e34d88 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -131,11 +131,9 @@ "debug", "debug_level", "decode", - "decode", "del_temp_region", "diff_files", "encode", - "encode", "error", "exec_command", "fatal", @@ -143,7 +141,6 @@ "find_file", "find_program", "float_or_dms", - "float_or_dms", "get_capture_stderr", "get_commands", "get_lib_path", @@ -171,8 +168,6 @@ "parse_color", "parse_command", "parse_key_val", - "parse_key_val", - "parse_key_val", "parser", "percent", "pipe_command", @@ -200,7 +195,6 @@ "use_temp_region", "vector_columns", "vector_db", - "vector_db", "vector_db_select", "vector_history", "vector_info", From c2d4369098a1e48ed0e78c536a48167466082060 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 11 Nov 2024 11:01:22 -0500 Subject: [PATCH 13/16] added Popen --- python/grass/script/__init__.py | 61 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index 02973e34d88..ebad61d960d 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -1,12 +1,15 @@ """Python interface to launch GRASS GIS modules in scripts """ +from . import setup # noqa: F401 from .core import ( + PIPE, + Popen, call, + compare_key_value_text_files, create_environment, create_location, create_project, - compare_key_value_text_files, debug, debug_level, del_temp_region, @@ -16,12 +19,12 @@ feed_command, find_file, find_program, - gisenv, + get_capture_stderr, get_commands, + get_raise_on_error, get_real_command, + gisenv, handle_errors, - get_raise_on_error, - get_capture_stderr, info, legal_name, list_grouped, @@ -32,8 +35,8 @@ mapsets, message, overwrite, - parse_command, parse_color, + parse_command, parser, percent, pipe_command, @@ -41,22 +44,20 @@ region, region_env, run_command, - set_raise_on_error, - start_command, sanitize_mapset_environment, set_capture_stderr, + set_raise_on_error, + start_command, tempdir, tempfile, tempname, use_temp_region, - version, verbose, verbosity, + version, warning, write_command, - PIPE, ) - from .db import ( db_begin_transaction, db_commit_transaction, @@ -66,51 +67,47 @@ db_table_exist, db_table_in_vector, ) - from .raster import mapcalc, mapcalc_start, raster_history, raster_info, raster_what - from .raster3d import mapcalc3d, raster3d_info - from .utils import ( KeyValue, + append_node_pid, + append_random, + append_uuid, basename, + clock, decode, + diff_files, encode, float_or_dms, - parse_key_val, - try_remove, - diff_files, - try_rmdir, - text_to_string, + get_lib_path, get_num_suffix, - split, + legalize_vector_name, natural_sort, naturally_sorted, - get_lib_path, - set_path, - clock, - legalize_vector_name, - append_node_pid, - append_uuid, - append_random, + parse_key_val, separator, + set_path, + split, + text_to_string, + try_remove, + try_rmdir, ) - from .vector import ( - vector_db, - vector_layer_db, vector_columns, + vector_db, + vector_db_select, vector_history, - vector_info_topo, vector_info, - vector_db_select, + vector_info_topo, + vector_layer_db, vector_what, ) -from . import setup # noqa: F401 __all__ = [ "PIPE", "KeyValue", + "Popen", "append_node_pid", "append_random", "append_uuid", From 001956fef1857a9555d423a2246408f392730f8b Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Wed, 13 Nov 2024 17:15:22 -0500 Subject: [PATCH 14/16] fix setup --- python/grass/script/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index ebad61d960d..e7ec1d99e2b 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -1,7 +1,7 @@ """Python interface to launch GRASS GIS modules in scripts """ -from . import setup # noqa: F401 +from . import setup from .core import ( PIPE, Popen, @@ -181,6 +181,7 @@ "set_capture_stderr", "set_path", "set_raise_on_error", + "setup", "split", "start_command", "tempdir", From 9db6cc702ba4cef395171c2a3ba28c230c4ec760 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Thu, 14 Nov 2024 18:14:06 -0500 Subject: [PATCH 15/16] fixed --- python/grass/temporal/stds_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/grass/temporal/stds_import.py b/python/grass/temporal/stds_import.py index 006ee6a387e..149a3d3cf3e 100644 --- a/python/grass/temporal/stds_import.py +++ b/python/grass/temporal/stds_import.py @@ -240,7 +240,7 @@ def import_stds( :param memory: Cache size for raster rows, used in r.in.gdal """ - old_state = gs.raise_on_error + old_state = gs.get_raise_on_error() gs.set_raise_on_error(True) # Check if input file and extraction directory exits From 6a02b44c44089e0b8dc24e55e95af5c335acc94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sat, 16 Nov 2024 21:10:16 +0000 Subject: [PATCH 16/16] Remove fixed F401 and F403 from .flake8 exclusions --- .flake8 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index ab4038e4749..06e368f4f59 100644 --- a/.flake8 +++ b/.flake8 @@ -18,7 +18,6 @@ per-file-ignores = # F821 undefined name 'unicode' # F841 local variable assigned to but never used # E741 ambiguous variable name 'l' - __init__.py: F403 man/build_html.py: E501 doc/python/m.distance.py: E501 gui/scripts/d.wms.py: E501 @@ -64,7 +63,6 @@ per-file-ignores = python/grass/pygrass/raster/__init__.py: E402 python/grass/pygrass/vector/__init__.py: E402 python/grass/pygrass/raster/category.py: E721 - python/grass/pygrass/rpc/__init__.py: F403 python/grass/pygrass/utils.py: E402 python/grass/temporal/abstract_space_time_dataset.py: E722 python/grass/temporal/c_libraries_interface.py: E722 @@ -84,9 +82,7 @@ per-file-ignores = python/grass/imaging/images2gif.py: E226 # Unused imports in init files # F403 star import used; unable to detect undefined names - python/grass/*/__init__.py: F401, F403 - python/grass/*/*/__init__.py: F403 - python/grass/*/*/*/__init__.py: F403 + python/grass/temporal/__init__.py: F401, F403 # E402 module level import not at top of file scripts/r.semantic.label/r.semantic.label.py: E501 scripts/db.out.ogr/db.out.ogr.py: F841