diff --git a/.flake8 b/.flake8 index 7dfaa4561e0..2c25e658059 100644 --- a/.flake8 +++ b/.flake8 @@ -15,20 +15,19 @@ per-file-ignores = # E501 line too long # E722 do not use bare 'except' # W605 invalid escape sequence - # F401 imported but unused # F821 undefined name 'unicode' # F841 local variable assigned to but never used # E741 ambiguous variable name 'l' - __init__.py: F401, F403 + __init__.py: F403 man/build_html.py: E501 man/build_md.py: E501 doc/python/m.distance.py: E501 gui/scripts/d.wms.py: E501 gui/wxpython/image2target/g.gui.image2target.py: E501 - gui/wxpython/nviz/*: E266, E722, F403, F405 + gui/wxpython/nviz/*: E722 gui/wxpython/photo2image/*: F841, E722, E265 gui/wxpython/photo2image/g.gui.photo2image.py: E501, F841 - gui/wxpython/psmap/*: F841, E266, E722 + gui/wxpython/psmap/*: E501, E722 gui/wxpython/vdigit/*: F841, E722, F405, F403 gui/wxpython/animation/g.gui.animation.py: E501 gui/wxpython/tplot/frame.py: F841, E722 @@ -67,10 +66,8 @@ per-file-ignores = python/grass/pygrass/vector/__init__.py: E402 python/grass/pygrass/raster/__init__.py: E402 python/grass/pygrass/vector/__init__.py: E402 - python/grass/pygrass/modules/interface/*.py: F401 - python/grass/pygrass/modules/grid/*.py: F401 python/grass/pygrass/raster/category.py: E721 - python/grass/pygrass/rpc/__init__.py: F401, F403 + 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 @@ -83,17 +80,16 @@ per-file-ignores = python/grass/temporal/temporal_topology_dataset_connector.py: E722 # Current benchmarks/tests are changing sys.path before import. # Possibly, a different approach should be taken there anyway. - python/grass/pygrass/tests/benchmark.py: E402, F401, F821 + python/grass/pygrass/tests/benchmark.py: E402, F821 # Configuration file for Sphinx: # Ignoring import/code mix and line length. # Files not managed by Black python/grass/imaging/images2gif.py: E226 # Unused imports in init files - # F401 imported but unused # F403 star import used; unable to detect undefined names python/grass/*/__init__.py: F401, F403 - python/grass/*/*/__init__.py: F401, F403 - 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.in.wms/wms_gdal_drv.py: E722 scripts/r.in.wms/wms_drv.py: E402, E722 @@ -107,9 +103,7 @@ per-file-ignores = scripts/db.univar/db.univar.py: E501 scripts/d.frame/d.frame.py: E722 scripts/i.pansharpen/i.pansharpen.py: E722, E501 - scripts/r.in.srtm/r.in.srtm.py: E722 scripts/r.fillnulls/r.fillnulls.py: E722 - scripts/d.rast.edit/d.rast.edit.py: E722 scripts/v.what.strds/v.what.strds.py: E501 # Line too long (esp. module interface definitions) scripts/*/*.py: E501 diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index a91d221f1e4..a2fbfadc36f 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout repository contents - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 31 diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 13ba5bb3cd9..489d8197c09 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -16,7 +16,7 @@ jobs: name: Formatting Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - uses: DoozyX/clang-format-lint-action@c71d0bf4e21876ebec3e5647491186f8797fde31 # v0.18.2 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6672287794c..9c161300170 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Python uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 with: @@ -56,7 +56,7 @@ jobs: if: ${{ matrix.language == 'c-cpp' }} - name: Initialize CodeQL - uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13 + uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 with: languages: ${{ matrix.language }} config-file: ./.github/codeql/codeql-config.yml @@ -81,6 +81,6 @@ jobs: run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install" - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13 + uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 22a6b7a42a8..51ab83015ca 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-22.04 if: github.repository == 'OSGeo/grass' steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get dependencies run: | diff --git a/.github/workflows/create_release_draft.yml b/.github/workflows/create_release_draft.yml index 3112fb8b33f..6c3597599fc 100644 --- a/.github/workflows/create_release_draft.yml +++ b/.github/workflows/create_release_draft.yml @@ -30,7 +30,7 @@ jobs: contents: write steps: - name: Checks-out repository - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.ref }} fetch-depth: 0 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4de674ee9a2..6b2ad83629e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -49,7 +49,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - name: Docker meta diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 651cb272fba..6b6286ef3f0 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -26,7 +26,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get dependencies run: | sudo apt-get update -y diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 41ac51df8ff..cdc02ad1432 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -44,7 +44,7 @@ jobs: -mindepth 1 -maxdepth 1 -type f -print -delete # Rehash to forget about the deleted files hash -r - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get current date cache key segment id: date # Year and week of year so cache key changes weekly diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index a7694fa9b30..30add8dde09 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -31,7 +31,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1 with: path-type: inherit diff --git a/.github/workflows/periodic_update.yml b/.github/workflows/periodic_update.yml index 17855d6149e..d27b8664c55 100644 --- a/.github/workflows/periodic_update.yml +++ b/.github/workflows/periodic_update.yml @@ -21,7 +21,7 @@ jobs: - name: Create URL to the run output id: vars run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: "Check that autoconf scripts are up-to-date:" run: | rm -f config.guess config.sub diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index e1b3b84b54e..b28fb40ad14 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -32,7 +32,7 @@ jobs: PYTHONWARNINGS: always steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Python uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 diff --git a/.github/workflows/python-code-quality.yml b/.github/workflows/python-code-quality.yml index 9f71c28e922..94a8d0be26b 100644 --- a/.github/workflows/python-code-quality.yml +++ b/.github/workflows/python-code-quality.yml @@ -54,7 +54,7 @@ jobs: echo Bandit: ${{ env.BANDIT_VERSION }} echo Ruff: ${{ env.RUFF_VERSION }} - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Python uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 @@ -135,7 +135,7 @@ jobs: path: bandit.sarif - name: Upload SARIF File into Security Tab - uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13 + uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 with: sarif_file: bandit.sarif diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index 62328723f77..ab2168cd1a3 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -25,7 +25,7 @@ jobs: statuses: write steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: # super-linter needs the full git history to get the # list of files that changed across commits diff --git a/.github/workflows/test-nix.yml b/.github/workflows/test-nix.yml index ba14e0747ab..43a1b5d40ab 100644 --- a/.github/workflows/test-nix.yml +++ b/.github/workflows/test-nix.yml @@ -28,7 +28,7 @@ jobs: contents: read steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install nix uses: DeterminateSystems/nix-installer-action@da36cb69b1c3247ad7a1f931ebfd954a1105ef14 # v14 diff --git a/.github/workflows/titles.yml b/.github/workflows/titles.yml index f202fdafe02..9821a209a87 100644 --- a/.github/workflows/titles.yml +++ b/.github/workflows/titles.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout base repository (doesn't include the PR changes) - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Call PR title validation function run: python utils/generate_release_notes.py check "${PR_TITLE}" "" "" env: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 966dbfe21ab..9023df7d1b3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -59,7 +59,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Invert inclusion list to an exclusion list id: get-exclude diff --git a/db/db.login/main.c b/db/db.login/main.c index 9147c0e7f1f..f073b654665 100644 --- a/db/db.login/main.c +++ b/db/db.login/main.c @@ -98,9 +98,9 @@ int main(int argc, char *argv[]) exit(EXIT_SUCCESS); } - if (db_set_login2(driver->answer, database->answer, user->answer, - password->answer, host->answer, port->answer, - G_get_overwrite()) == DB_FAILED) { + if (db_set_login(driver->answer, database->answer, user->answer, + password->answer, host->answer, port->answer, + G_get_overwrite()) == DB_FAILED) { G_fatal_error(_("Unable to set user/password")); } diff --git a/db/drivers/mysql/db.c b/db/drivers/mysql/db.c index 5c98c652e95..b83d3d7064d 100644 --- a/db/drivers/mysql/db.c +++ b/db/drivers/mysql/db.c @@ -51,7 +51,7 @@ int db__driver_open_database(dbHandle *handle) connpar.host, connpar.port, connpar.dbname, connpar.user, connpar.password); - db_get_login2("mysql", name, &user, &password, &host, &port); + db_get_login("mysql", name, &user, &password, &host, &port); connection = mysql_init(NULL); res = diff --git a/db/drivers/postgres/db.c b/db/drivers/postgres/db.c index 5343acf03d8..aa27d370419 100644 --- a/db/drivers/postgres/db.c +++ b/db/drivers/postgres/db.c @@ -54,7 +54,7 @@ int db__driver_open_database(dbHandle *handle) return DB_FAILED; } - db_get_login2("pg", name, &user, &password, &host, &port); + db_get_login("pg", name, &user, &password, &host, &port); pg_conn = PQsetdbLogin(host, port, pgconn.options, pgconn.tty, pgconn.dbname, user, password); @@ -241,7 +241,7 @@ int create_delete_db(dbHandle *handle, int create) pgconn.host, pgconn.port, pgconn.options, pgconn.tty, pgconn.dbname, pgconn.user, pgconn.password, pgconn.host, pgconn.port, pgconn.schema); - db_get_login2("pg", template_db, &user, &password, &host, &port); + db_get_login("pg", template_db, &user, &password, &host, &port); pg_conn = PQsetdbLogin(host, port, pgconn.options, pgconn.tty, pgconn.dbname, user, password); diff --git a/db/drivers/postgres/listdb.c b/db/drivers/postgres/listdb.c index 0efa0328c0f..974141f1e36 100644 --- a/db/drivers/postgres/listdb.c +++ b/db/drivers/postgres/listdb.c @@ -48,7 +48,7 @@ int db__driver_list_databases(dbString *dbpath, int npaths, dbHandle **dblist, pgconn.dbname, pgconn.user, pgconn.password, pgconn.host, pgconn.port, pgconn.options, pgconn.tty); - db_get_login2("pg", NULL, &user, &passwd, &host, &port); + db_get_login("pg", NULL, &user, &passwd, &host, &port); G_debug(1, "user = %s, passwd = %s", user, passwd ? "xxx" : ""); if (user || passwd) { diff --git a/doc/notebooks/hydrology.ipynb b/doc/notebooks/hydrology.ipynb index b9e23acf3c1..f5c853de9a2 100644 --- a/doc/notebooks/hydrology.ipynb +++ b/doc/notebooks/hydrology.ipynb @@ -25,7 +25,6 @@ "outputs": [], "source": [ "# Import Python standard library and IPython packages we need.\n", - "import os\n", "import subprocess\n", "import sys\n", "import csv\n", diff --git a/doc/notebooks/jupyter_tutorial.ipynb b/doc/notebooks/jupyter_tutorial.ipynb index 71852c226e6..6dfdfb63625 100644 --- a/doc/notebooks/jupyter_tutorial.ipynb +++ b/doc/notebooks/jupyter_tutorial.ipynb @@ -30,7 +30,6 @@ "source": [ "# Import Python standard library and IPython packages we need.\n", "import subprocess\n", - "import time\n", "import sys\n", "\n", "# Ask GRASS GIS where its Python packages are.\n", diff --git a/doc/notebooks/parallelization_tutorial.ipynb b/doc/notebooks/parallelization_tutorial.ipynb index 2c5d902e9a4..4611f5d1c24 100644 --- a/doc/notebooks/parallelization_tutorial.ipynb +++ b/doc/notebooks/parallelization_tutorial.ipynb @@ -21,7 +21,6 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import subprocess\n", "import sys\n", "\n", diff --git a/doc/notebooks/solar_potential.ipynb b/doc/notebooks/solar_potential.ipynb index 98253ad6450..07da1af77e2 100644 --- a/doc/notebooks/solar_potential.ipynb +++ b/doc/notebooks/solar_potential.ipynb @@ -28,7 +28,6 @@ "outputs": [], "source": [ "# Import Python standard library and IPython packages we need.\n", - "import os\n", "import subprocess\n", "import sys\n", "\n", diff --git a/doc/notebooks/viewshed_analysis.ipynb b/doc/notebooks/viewshed_analysis.ipynb index a4f0b61744a..5cfe69c4dae 100644 --- a/doc/notebooks/viewshed_analysis.ipynb +++ b/doc/notebooks/viewshed_analysis.ipynb @@ -30,7 +30,6 @@ "outputs": [], "source": [ "# Import Python standard library and IPython packages we need.\n", - "import os\n", "import subprocess\n", "import sys\n", "\n", diff --git a/gui/wxpython/nviz/wxnviz.py b/gui/wxpython/nviz/wxnviz.py index 47cf99c079d..5a223747277 100644 --- a/gui/wxpython/nviz/wxnviz.py +++ b/gui/wxpython/nviz/wxnviz.py @@ -22,9 +22,9 @@ @author Anna Kratochvilova (Google SoC 2011) """ -import sys import locale import struct +import sys from math import sqrt try: @@ -42,26 +42,203 @@ import wx try: - from ctypes import * + from ctypes import ( + CFUNCTYPE, + UNCHECKED, + byref, + c_char_p, + c_double, + c_float, + c_int, + c_ubyte, + create_string_buffer, + pointer, + ) except KeyError as e: print("wxnviz.py: {}".format(e), file=sys.stderr) try: - from grass.lib.gis import * - from grass.lib.raster3d import * - from grass.lib.vector import * - from grass.lib.ogsf import * - from grass.lib.nviz import * - from grass.lib.raster import * + from grass.lib.gis import ( + G_find_raster2, + G_find_raster3d, + G_find_vector2, + G_free, + G_fully_qualified_name, + G_gisinit, + G_set_error_routine, + G_set_percent_routine, + G_unset_error_routine, + G_unset_percent_routine, + G_unset_window, + G_warning, + ) + from grass.lib.nviz import ( + ATT_COLOR, + ATT_EMIT, + ATT_MASK, + ATT_SHINE, + ATT_TOPO, + ATT_TRANSP, + CONST_ATT, + MAP_ATT, + MAP_OBJ_SITE, + MAP_OBJ_SURF, + MAP_OBJ_UNDEFINED, + MAP_OBJ_VECT, + MAP_OBJ_VOL, + Colors, + Nviz_change_exag, + Nviz_color_from_str, + Nviz_del_texture, + Nviz_delete_arrow, + Nviz_delete_scalebar, + Nviz_draw_all, + Nviz_draw_arrow, + Nviz_draw_cplane, + Nviz_draw_fringe, + Nviz_draw_image, + Nviz_draw_model, + Nviz_draw_quick, + Nviz_draw_scalebar, + Nviz_flythrough, + Nviz_get_bgcolor, + Nviz_get_cplane_rotation, + Nviz_get_cplane_translation, + Nviz_get_current_cplane, + Nviz_get_exag, + Nviz_get_exag_height, + Nviz_get_focus, + Nviz_get_longdim, + Nviz_get_max_texture, + Nviz_get_modelview, + Nviz_get_viewpoint_height, + Nviz_get_viewpoint_position, + Nviz_get_xyrange, + Nviz_get_zrange, + Nviz_has_focus, + Nviz_init_data, + Nviz_init_rotation, + Nviz_init_view, + Nviz_load_image, + Nviz_look_here, + Nviz_new_map_obj, + Nviz_num_cplanes, + Nviz_off_cplane, + Nviz_on_cplane, + Nviz_resize_window, + Nviz_set_2D, + Nviz_set_arrow, + Nviz_set_attr, + Nviz_set_bgcolor, + Nviz_set_cplane_here, + Nviz_set_cplane_rotation, + Nviz_set_cplane_translation, + Nviz_set_fence_color, + Nviz_set_focus, + Nviz_set_focus_map, + Nviz_set_fringe, + Nviz_set_light_ambient, + Nviz_set_light_bright, + Nviz_set_light_color, + Nviz_set_light_position, + Nviz_set_rotation, + Nviz_set_scalebar, + Nviz_set_surface_attr_default, + Nviz_set_viewpoint_height, + Nviz_set_viewpoint_persp, + Nviz_set_viewpoint_position, + Nviz_set_viewpoint_twist, + Nviz_unset_attr, + Nviz_unset_rotation, + nv_data, + ) + from grass.lib.ogsf import ( + GS_clear, + GS_delete_surface, + GS_get_cat_at_xy, + GS_get_distance_alongsurf, + GS_get_rotation_matrix, + GS_get_selected_point_on_surface, + GS_get_surf_list, + GS_get_trans, + GS_get_val_at_xy, + GS_get_viewdir, + GS_libinit, + GS_num_surfs, + GS_set_att_const, + GS_set_drawmode, + GS_set_drawres, + GS_set_rotation_matrix, + GS_set_trans, + GS_set_viewdir, + GS_set_wire_color, + GS_setall_drawmode, + GS_setall_drawres, + GS_surf_exists, + GS_write_ppm, + GS_write_tif, + GVL_delete_vol, + GVL_get_trans, + GVL_init_region, + GVL_isosurf_add, + GVL_isosurf_del, + GVL_isosurf_move_down, + GVL_isosurf_move_up, + GVL_isosurf_num_isosurfs, + GVL_isosurf_set_att_const, + GVL_isosurf_set_att_map, + GVL_isosurf_set_drawmode, + GVL_isosurf_set_drawres, + GVL_isosurf_set_flags, + GVL_isosurf_unset_att, + GVL_libinit, + GVL_set_draw_wire, + GVL_set_trans, + GVL_slice_add, + GVL_slice_del, + GVL_slice_move_down, + GVL_slice_move_up, + GVL_slice_num_slices, + GVL_slice_set_drawmode, + GVL_slice_set_drawres, + GVL_slice_set_pos, + GVL_slice_set_transp, + GVL_vol_exists, + ) + from grass.lib.raster import Rast__init_window, Rast_unset_window, Vect_read_colors + from grass.lib.raster3d import ( + GP_delete_site, + GP_get_sitename, + GP_select_surf, + GP_set_style, + GP_set_style_thematic, + GP_set_trans, + GP_set_zmode, + GP_site_exists, + GP_unselect_surf, + GP_unset_style_thematic, + ) + from grass.lib.vector import ( + GV_delete_vector, + GV_get_vectname, + GV_select_surf, + GV_set_style, + GV_set_style_thematic, + GV_set_trans, + GV_surf_is_selected, + GV_unselect_surf, + GV_unset_style_thematic, + GV_vect_exists, + ) except (ImportError, OSError, TypeError) as e: print("wxnviz.py: {}".format(e), file=sys.stderr) +import grass.script as gs from core.debug import Debug -from core.utils import autoCropImageFromFile from core.gcmd import DecodeString from core.globalvar import wxPythonPhoenix +from core.utils import autoCropImageFromFile from gui_core.wrap import Rect -import grass.script as gs log = None progress = None diff --git a/gui/wxpython/photo2image/g.gui.photo2image.py b/gui/wxpython/photo2image/g.gui.photo2image.py index 65b4141873e..fe153b236cc 100755 --- a/gui/wxpython/photo2image/g.gui.photo2image.py +++ b/gui/wxpython/photo2image/g.gui.photo2image.py @@ -121,7 +121,7 @@ def main(): app = wx.App() - wizard = GCPWizard( + GCPWizard( parent=None, giface=StandaloneGrassInterface(), group=group, diff --git a/gui/wxpython/photo2image/ip2i_manager.py b/gui/wxpython/photo2image/ip2i_manager.py index 5a2a1f14f21..711ec4191af 100644 --- a/gui/wxpython/photo2image/ip2i_manager.py +++ b/gui/wxpython/photo2image/ip2i_manager.py @@ -1107,22 +1107,20 @@ def OnGeorect(self, event): else: flags = "a" - busy = wx.BusyInfo(_("Rectifying images, please wait..."), parent=self) - wx.GetApp().Yield() + with wx.BusyInfo(_("Rectifying images, please wait..."), parent=self): + wx.GetApp().Yield() - ret, msg = RunCommand( - "i.rectify", - parent=self, - getErrorMsg=True, - quiet=True, - group=self.xygroup, - extension=self.extension, - order=self.gr_order, - method=self.gr_method, - flags=flags, - ) - - del busy + ret, msg = RunCommand( + "i.rectify", + parent=self, + getErrorMsg=True, + quiet=True, + group=self.xygroup, + extension=self.extension, + order=self.gr_order, + method=self.gr_method, + flags=flags, + ) # provide feedback on failure if ret != 0: @@ -1130,21 +1128,19 @@ def OnGeorect(self, event): print(self.grwiz.src_map, file=sys.stderr) print(msg, file=sys.stderr) - busy = wx.BusyInfo( + with wx.BusyInfo( _("Writing output image to group, please wait..."), parent=self - ) - wx.GetApp().Yield() - - ret1, msg1 = RunCommand( - "i.group", - parent=self, - getErrorMsg=True, - quiet=False, - group=self.xygroup, - input="".join([self.grwiz.src_map.split("@")[0], self.extension]), - ) + ): + wx.GetApp().Yield() - del busy + ret1, msg1 = RunCommand( + "i.group", + parent=self, + getErrorMsg=True, + quiet=False, + group=self.xygroup, + input="".join([self.grwiz.src_map.split("@")[0], self.extension]), + ) if ret1 != 0: print("ip2i: Error in i.group", file=sys.stderr) @@ -1253,7 +1249,6 @@ def OnGROrder(self, event): elif self.gr_order == 2: minNumOfItems = 6 - diff = 6 - numOfItems # self.SetStatusText(_( # "Insufficient points, 6+ points needed for 2nd order")) @@ -1556,7 +1551,6 @@ def OnZoomToTarget(self, event): def OnZoomMenuGCP(self, event): """Popup Zoom menu""" - point = wx.GetMousePosition() zoommenu = Menu() # Add items to the menu @@ -2467,7 +2461,6 @@ def UpdateSettings(self): srcrender = False tgtrender = False - reload_target = False if self.new_src_map != src_map: # remove old layer layers = self.parent.grwiz.SrcMap.GetListOfLayers() @@ -2499,7 +2492,6 @@ def UpdateSettings(self): del layers[0] layers = self.parent.grwiz.TgtMap.GetListOfLayers() # self.parent.grwiz.TgtMap.DeleteAllLayers() - reload_target = True tgt_map["raster"] = self.new_tgt_map["raster"] if tgt_map["raster"] != "": diff --git a/gui/wxpython/photo2image/ip2i_mapdisplay.py b/gui/wxpython/photo2image/ip2i_mapdisplay.py index aa085f2b43a..732716a1a0c 100644 --- a/gui/wxpython/photo2image/ip2i_mapdisplay.py +++ b/gui/wxpython/photo2image/ip2i_mapdisplay.py @@ -466,7 +466,6 @@ def PrintMenu(self, event): """ Print options and output menu for map display """ - point = wx.GetMousePosition() printmenu = Menu() # Add items to the menu setup = wx.MenuItem(printmenu, wx.ID_ANY, _("Page setup")) @@ -510,7 +509,6 @@ def SaveDisplayRegion(self, event): def OnZoomMenu(self, event): """Popup Zoom menu""" - point = wx.GetMousePosition() zoommenu = Menu() # Add items to the menu diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py index c4784525cc9..f086d65dd36 100644 --- a/gui/wxpython/psmap/dialogs.py +++ b/gui/wxpython/psmap/dialogs.py @@ -5731,8 +5731,6 @@ def updateDialog(self): y = self.unitConv.convert(value=y, fromUnit="inch", toUnit=currUnit) self.positionPanel.position["xCtrl"].SetValue("%5.3f" % x) self.positionPanel.position["yCtrl"].SetValue("%5.3f" % y) - # EN coordinates - e, n = self.textDict["east"], self.textDict["north"] self.positionPanel.position["eCtrl"].SetValue(str(self.textDict["east"])) self.positionPanel.position["nCtrl"].SetValue(str(self.textDict["north"])) @@ -6027,7 +6025,7 @@ def OnImageSelectionChanged(self, event): pImg = PILImage.open(file) img = PilImageToWxImage(pImg) except OSError as e: - GError(message=_("Unable to read file %s") % file) + GError(message=_("Unable to read file %s: %s") % (file, str(e))) self.ClearPreview() return self.SetSizeInfoLabel(img) @@ -6140,15 +6138,6 @@ def update(self): else: self.imageDict["XY"] = False - if self.positionPanel.position["eCtrl"].GetValue(): - e = self.positionPanel.position["eCtrl"].GetValue() - else: - self.imageDict["east"] = self.imageDict["east"] - - if self.positionPanel.position["nCtrl"].GetValue(): - n = self.positionPanel.position["nCtrl"].GetValue() - else: - self.imageDict["north"] = self.imageDict["north"] x, y = PaperMapCoordinates( mapInstr=self.instruction[self.mapId], @@ -6211,7 +6200,6 @@ def updateDialog(self): self.positionPanel.position["xCtrl"].SetValue("%5.3f" % x) self.positionPanel.position["yCtrl"].SetValue("%5.3f" % y) # EN coordinates - e, n = self.imageDict["east"], self.imageDict["north"] self.positionPanel.position["eCtrl"].SetValue(str(self.imageDict["east"])) self.positionPanel.position["nCtrl"].SetValue(str(self.imageDict["north"])) @@ -6526,15 +6514,6 @@ def update(self): else: self.pointDict["XY"] = False - if self.positionPanel.position["eCtrl"].GetValue(): - e = self.positionPanel.position["eCtrl"].GetValue() - else: - self.pointDict["east"] = self.pointDict["east"] - - if self.positionPanel.position["nCtrl"].GetValue(): - n = self.positionPanel.position["nCtrl"].GetValue() - else: - self.pointDict["north"] = self.pointDict["north"] x, y = PaperMapCoordinates( mapInstr=self.instruction[self.mapId], @@ -6590,7 +6569,6 @@ def updateDialog(self): self.positionPanel.position["xCtrl"].SetValue("%5.3f" % x) self.positionPanel.position["yCtrl"].SetValue("%5.3f" % y) # EN coordinates - e, n = self.pointDict["east"], self.pointDict["north"] self.positionPanel.position["eCtrl"].SetValue(str(self.pointDict["east"])) self.positionPanel.position["nCtrl"].SetValue(str(self.pointDict["north"])) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 1d937483123..e86b277252c 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -195,7 +195,6 @@ def __init__( self.getInitMap() # image path - env = gs.gisenv() self.imgName = gs.tempfile() # canvas for preview @@ -513,45 +512,44 @@ def OnCmdDone(self, event): env=self.env, ) # wx.BusyInfo does not display the message - busy = wx.BusyInfo(_("Generating preview, wait please"), parent=self) - wx.GetApp().Yield() - try: - im = PILImage.open(event.userData["filename"]) - if self.instruction[self.pageId]["Orientation"] == "Landscape": - import numpy as np - - im_array = np.array(im) - im = PILImage.fromarray(np.rot90(im_array, 3)) - im.save(self.imgName, format="PNG") - except OSError: - del busy - program = self._getGhostscriptProgramName() - dlg = HyperlinkDialog( - self, - title=_("Preview not available"), - message=_( - "Preview is not available probably because Ghostscript is not " - "installed or not on PATH." - ), - hyperlink="https://www.ghostscript.com/releases/gsdnld.html", - hyperlinkLabel=_( - "You can download {program} {arch} version here." - ).format( - program=program, - arch="64bit" if "64" in program else "32bit", - ), - ) - dlg.ShowModal() - dlg.Destroy() - return + with wx.BusyInfo(_("Generating preview, wait please"), parent=self): + wx.GetApp().Yield() + try: + im = PILImage.open(event.userData["filename"]) + if self.instruction[self.pageId]["Orientation"] == "Landscape": + import numpy as np + + im_array = np.array(im) + im = PILImage.fromarray(np.rot90(im_array, 3)) + im.save(self.imgName, format="PNG") + except OSError: + del busy + program = self._getGhostscriptProgramName() + dlg = HyperlinkDialog( + self, + title=_("Preview not available"), + message=_( + "Preview is not available probably because Ghostscript is not " + "installed or not on PATH." + ), + hyperlink="https://www.ghostscript.com/releases/gsdnld.html", + hyperlinkLabel=_( + "You can download {program} {arch} version here." + ).format( + program=program, + arch="64bit" if "64" in program else "32bit", + ), + ) + dlg.ShowModal() + dlg.Destroy() + return - self.book.SetSelection(1) - self.currentPage = 1 - rect = self.previewCanvas.ImageRect() - self.previewCanvas.image = wx.Image(self.imgName, wx.BITMAP_TYPE_PNG) - self.previewCanvas.DrawImage(rect=rect) + self.book.SetSelection(1) + self.currentPage = 1 + rect = self.previewCanvas.ImageRect() + self.previewCanvas.image = wx.Image(self.imgName, wx.BITMAP_TYPE_PNG) + self.previewCanvas.DrawImage(rect=rect) - del busy self.SetStatusText(_("Preview generated"), 0) gs.try_remove(event.userData["instrFile"]) diff --git a/gui/wxpython/psmap/instructions.py b/gui/wxpython/psmap/instructions.py index 845e99b2e6a..82560353806 100644 --- a/gui/wxpython/psmap/instructions.py +++ b/gui/wxpython/psmap/instructions.py @@ -1751,7 +1751,7 @@ def EstimateHeight(self, raster, discrete, fontsize, cols=None, height=None): rinfo = gs.raster_info(raster) if rinfo["datatype"] in {"DCELL", "FCELL"}: - minim, maxim = rinfo["min"], rinfo["max"] + maxim = rinfo["max"] rows = ceil(maxim / cols) else: cat = ( diff --git a/include/grass/defs/dbmi.h b/include/grass/defs/dbmi.h index c5bf648414f..5af0476849d 100644 --- a/include/grass/defs/dbmi.h +++ b/include/grass/defs/dbmi.h @@ -386,10 +386,12 @@ const char *db_whoami(void); void db_zero(void *, int); void db_zero_string(dbString *); unsigned int db_sizeof_string(const dbString *); -int db_set_login(const char *, const char *, const char *, const char *); +int db_set_login(const char *, const char *, const char *, const char *, + const char *, const char *, int); int db_set_login2(const char *, const char *, const char *, const char *, const char *, const char *, int); -int db_get_login(const char *, const char *, const char **, const char **); +int db_get_login(const char *, const char *, const char **, const char **, + const char **, const char **); int db_get_login2(const char *, const char *, const char **, const char **, const char **, const char **); int db_get_login_dump(FILE *); diff --git a/lib/db/dbmi_base/connect.c b/lib/db/dbmi_base/connect.c index 780d929dd3a..ced282405bd 100644 --- a/lib/db/dbmi_base/connect.c +++ b/lib/db/dbmi_base/connect.c @@ -87,11 +87,11 @@ int db_get_connection(dbConnection *connection) connection->group = (char *)G_getenv_nofatal2("DB_GROUP", G_VAR_MAPSET); /* try to get user/password */ - db_get_login2(connection->driverName, connection->databaseName, - (const char **)&(connection->user), - (const char **)&(connection->password), - (const char **)&(connection->hostName), - (const char **)&(connection->port)); + db_get_login(connection->driverName, connection->databaseName, + (const char **)&(connection->user), + (const char **)&(connection->password), + (const char **)&(connection->hostName), + (const char **)&(connection->port)); return DB_OK; } diff --git a/lib/db/dbmi_base/login.c b/lib/db/dbmi_base/login.c index d79fc84e6cf..9c865233d2c 100644 --- a/lib/db/dbmi_base/login.c +++ b/lib/db/dbmi_base/login.c @@ -253,22 +253,23 @@ static int set_login(const char *driver, const char *database, const char *user, /*! \brief Set login parameters for driver/database - \deprecated Use db_set_login2() instead. - - \todo: GRASS 8: to be replaced by db_set_login2(). - \param driver driver name \param database database name \param user user name \param password password string + \param host host name + \param port + \param overwrite TRUE to overwrite existing connections \return DB_OK on success \return DB_FAILED on failure */ -int db_set_login(const char *driver, const char *database, const char *user, - const char *password) +int db_set_login2(const char *driver, const char *database, const char *user, + const char *password, const char *host, const char *port, + int overwrite) { - return set_login(driver, database, user, password, NULL, NULL, FALSE); + return db_set_login(driver, database, user, password, host, port, + overwrite); } /*! @@ -285,9 +286,9 @@ int db_set_login(const char *driver, const char *database, const char *user, \return DB_OK on success \return DB_FAILED on failure */ -int db_set_login2(const char *driver, const char *database, const char *user, - const char *password, const char *host, const char *port, - int overwrite) +int db_set_login(const char *driver, const char *database, const char *user, + const char *password, const char *host, const char *port, + int overwrite) { return set_login(driver, database, user, password, host, port, overwrite); } @@ -346,22 +347,20 @@ static int get_login(const char *driver, const char *database, If driver/database is not found, output arguments are set to NULL. - \deprecated Use db_set_login2() instead. - - \todo: GRASS 8: to be replaced by db_set_login2(). - \param driver driver name \param database database name (can be NULL) \param[out] user name \param[out] password string + \param[out] host name + \param[out] port \return DB_OK on success \return DB_FAILED on failure */ -int db_get_login(const char *driver, const char *database, const char **user, - const char **password) +int db_get_login2(const char *driver, const char *database, const char **user, + const char **password, const char **host, const char **port) { - return get_login(driver, database, user, password, NULL, NULL); + return db_get_login(driver, database, user, password, host, port); } /*! @@ -379,8 +378,8 @@ int db_get_login(const char *driver, const char *database, const char **user, \return DB_OK on success \return DB_FAILED on failure */ -int db_get_login2(const char *driver, const char *database, const char **user, - const char **password, const char **host, const char **port) +int db_get_login(const char *driver, const char *database, const char **user, + const char **password, const char **host, const char **port) { return get_login(driver, database, user, password, host, port); } diff --git a/lib/gis/testsuite/test_gis_lib_getl.py b/lib/gis/testsuite/test_gis_lib_getl.py index 98092955ab2..72e8992ad39 100644 --- a/lib/gis/testsuite/test_gis_lib_getl.py +++ b/lib/gis/testsuite/test_gis_lib_getl.py @@ -5,7 +5,6 @@ import ctypes import pathlib -import platform import unittest import grass.lib.gis as libgis diff --git a/lib/vector/Vlib/open_pg.c b/lib/vector/Vlib/open_pg.c index 7db0113be99..293291066c2 100644 --- a/lib/vector/Vlib/open_pg.c +++ b/lib/vector/Vlib/open_pg.c @@ -535,11 +535,11 @@ void connect_db(struct Format_info_pg *pg_info) /* try connection settings for given database first, then try * any settings defined for pg driver */ - db_get_login2("pg", dbname, &user, &passwd, &host, &port); + db_get_login("pg", dbname, &user, &passwd, &host, &port); /* any settings defined for pg driver disabled - can cause problems when running multiple local/remote db clusters if (strlen(dbname) > 0 && !user && !passwd) - db_get_login2("pg", NULL, &user, &passwd, &host, &port); + db_get_login("pg", NULL, &user, &passwd, &host, &port); */ if (user || passwd || host || port) { char conninfo[DB_SQL_MAX]; diff --git a/pyproject.toml b/pyproject.toml index 4b7856bab3b..a428c79106f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -131,7 +131,6 @@ ignore = [ "E722", # bare-except "E731", # lambda-assignment "E741", # ambiguous-variable-name - "F401", # unused-import "F403", # undefined-local-with-import-star "F405", # undefined-local-with-import-star-usage "F811", # redefined-while-unused @@ -319,7 +318,9 @@ ignore = [ "python/grass/jupyter/testsuite/map_test.py" = ["PGH004"] "python/grass/pydispatch/signal.py" = ["A005"] "python/grass/pygrass/modules/grid/grid.py" = ["SIM115"] +"python/grass/pygrass/modules/grid/testsuite/test_*_modules_grid_doctests.py" = ["F401"] "python/grass/pygrass/modules/interface/env.py" = ["SIM115"] +"python/grass/pygrass/modules/testsuite/test_pygrass_modules_doctests.py" = ["F401"] "python/grass/pygrass/raster/segment.py" = ["SIM115"] "python/grass/pygrass/tests/*.py" = ["SIM115"] "python/grass/pygrass/vector/geometry.py" = ["PYI024"] diff --git a/python/grass/app/runtime.py b/python/grass/app/runtime.py index 3f3805c9dfd..27f35760b8f 100644 --- a/python/grass/app/runtime.py +++ b/python/grass/app/runtime.py @@ -79,10 +79,7 @@ def append_left_addon_paths(paths, config_dir, env): # addons (base) addon_base = env.get("GRASS_ADDON_BASE") if not addon_base: - if MACOS: - name = "Addons" - else: - name = "addons" + name = "addons" if not MACOS else "Addons" addon_base = os.path.join(config_dir, name) env["GRASS_ADDON_BASE"] = addon_base @@ -174,10 +171,7 @@ def set_python_path_variable(install_path, env): """Set PYTHONPATH to find GRASS Python package in subprocesses""" path = env.get("PYTHONPATH") etcpy = os.path.join(install_path, "etc", "python") - if path: - path = etcpy + os.pathsep + path - else: - path = etcpy + path = etcpy + os.pathsep + path if path else etcpy env["PYTHONPATH"] = path diff --git a/python/grass/benchmark/__init__.py b/python/grass/benchmark/__init__.py index a4a7bf4e991..62a6a85c3e1 100644 --- a/python/grass/benchmark/__init__.py +++ b/python/grass/benchmark/__init__.py @@ -34,3 +34,17 @@ save_results_to_file, ) from .runners import benchmark_nprocs, benchmark_resolutions, benchmark_single + +__all__ = [ + "benchmark_nprocs", + "benchmark_resolutions", + "benchmark_single", + "join_results", + "join_results_from_files", + "load_results", + "load_results_from_file", + "nprocs_plot", + "num_cells_plot", + "save_results", + "save_results_to_file", +] diff --git a/python/grass/benchmark/app.py b/python/grass/benchmark/app.py index 09cdf3f9481..835fc0d544b 100644 --- a/python/grass/benchmark/app.py +++ b/python/grass/benchmark/app.py @@ -47,11 +47,7 @@ def join_results_cli(args): def select_only(result): return result.label == args.only - if args.only: - select_function = select_only - else: - select_function = None - + select_function = select_only if args.only else None results = join_results_from_files( source_filenames=args.results, prefixes=args.prefixes, diff --git a/python/grass/benchmark/plots.py b/python/grass/benchmark/plots.py index 9483fda9116..24afcbcfbae 100644 --- a/python/grass/benchmark/plots.py +++ b/python/grass/benchmark/plots.py @@ -25,10 +25,7 @@ def get_pyplot(to_file): """ import matplotlib as mpl # pylint: disable=import-outside-toplevel - if to_file: - backend = "agg" - else: - backend = None + backend = "agg" if to_file else None if backend: mpl.use(backend) @@ -124,10 +121,7 @@ def num_cells_plot(results, filename=None, title=None, show_resolution=False): x_ticks = set() for result in results: - if show_resolution: - x = result.resolutions - else: - x = result.cells + x = result.resolutions if show_resolution else result.cells x_ticks.update(x) plt.plot(x, result.times, label=result.label) if hasattr(result, "all_times"): diff --git a/python/grass/exceptions/__init__.py b/python/grass/exceptions/__init__.py index b22d0a45c1d..deec48ffd96 100644 --- a/python/grass/exceptions/__init__.py +++ b/python/grass/exceptions/__init__.py @@ -71,13 +71,9 @@ def __init__(self, module, code, returncode, errors=None): """ # CalledProcessError has undocumented constructor super().__init__(returncode, module) - if not module or module in code: - # No need to include module name if it is directly in code - # of if it is not set. - executed = code - else: - # Make sure module name is there if provided and not in code. - executed = f"{module} {code}" + # No need to include module name if it is directly in code of if it is not set. + # Otherwise, make sure module name is there if provided and not in code. + executed = code if not module or module in code else f"{module} {code}" if errors: # We assume actual errors, e.g., captured stderr. err = _("See the following errors:\n{errors}").format(errors=errors) diff --git a/python/grass/gunittest/case.py b/python/grass/gunittest/case.py index 1277ee542b5..4e0ee3ab24d 100644 --- a/python/grass/gunittest/case.py +++ b/python/grass/gunittest/case.py @@ -691,10 +691,7 @@ def assertFileMd5(self, filename, md5, text=False, msg=None): at the end of file (as for example, Git or PEP8 requires). """ self.assertFileExists(filename, msg=msg) - if text: - actual = text_file_md5(filename) - else: - actual = file_md5(filename) + actual = text_file_md5(filename) if text else file_md5(filename) if actual != md5: standardMsg = ( "File <{name}> does not have the right MD5 sum.\n" @@ -1339,12 +1336,9 @@ def runModule(cls, module, expecting_stdout=False, **kwargs): errors = " The errors are:\n" + module.outputs.stderr else: errors = " There were no error messages." - if module.outputs.stdout: - # this is not appropriate for translation but we don't want - # and don't need testing to be translated - got = "only whitespace." - else: - got = "nothing." + # This is not appropriate for translation but we don't want + # and don't need testing to be translated + got = "only whitespace." if module.outputs.stdout else "nothing." raise RuntimeError( "Module call " + module.get_python() diff --git a/python/grass/gunittest/invoker.py b/python/grass/gunittest/invoker.py index 2fe9c898b8b..29b62830e25 100644 --- a/python/grass/gunittest/invoker.py +++ b/python/grass/gunittest/invoker.py @@ -54,10 +54,7 @@ def update_keyval_file(filename, module, returncode): keyval["name"] = module.name keyval["tested_dir"] = module.tested_dir if "status" not in keyval.keys(): - if returncode is None or returncode: - status = "failed" - else: - status = "passed" + status = "failed" if returncode is None or returncode else "passed" keyval["status"] = status keyval["returncode"] = returncode keyval["test_file_authors"] = test_file_authors diff --git a/python/grass/gunittest/multireport.py b/python/grass/gunittest/multireport.py index c5f36a6e0db..5a0350f1786 100644 --- a/python/grass/gunittest/multireport.py +++ b/python/grass/gunittest/multireport.py @@ -119,10 +119,7 @@ def median(values): smedian = median(successes) smax = max(successes) - if successes[-1] < smedian: - color = "r" - else: - color = "g" + color = "r" if successes[-1] < smedian else "g" # another possibility is to color according to the gradient, ideally # on the whole curve but that's much more complicated diff --git a/python/grass/gunittest/reporters.py b/python/grass/gunittest/reporters.py index 09f371dfffc..57b0a8fc643 100644 --- a/python/grass/gunittest/reporters.py +++ b/python/grass/gunittest/reporters.py @@ -234,11 +234,8 @@ def get_svn_path_authors(path, from_date=None): :returns: a set of authors """ - if from_date is None: - # this is the SVN default for local copies - revision_range = "BASE:1" - else: - revision_range = "BASE:{%s}" % from_date + # "BASE:1" is the SVN default for local copies + revision_range = "BASE:1" if from_date is None else "BASE:{%s}" % from_date try: # TODO: allow also usage of --limit p = subprocess.Popen( @@ -487,10 +484,7 @@ def tail(filename, n): def returncode_to_html_text(returncode, timed_out=None): if returncode: - if timed_out is not None: - extra = f" (timeout >{timed_out}s)" - else: - extra = "" + extra = f" (timeout >{timed_out}s)" if timed_out is not None else "" return f'FAILED{extra}' # alternatives: SUCCEEDED, passed, OK return 'succeeded' @@ -857,10 +851,7 @@ def finish(self): # this shoul be moved to some additional meta passed in constructor svn_info = get_svn_info() - if not svn_info: - svn_revision = "" - else: - svn_revision = svn_info["revision"] + svn_revision = "" if not svn_info else svn_info["revision"] summary = {} summary["files_total"] = self.test_files @@ -1025,10 +1016,7 @@ def end_file_test( num_failed = test_summary.get("failures", 0) num_failed += test_summary.get("errors", 0) if num_failed: - if num_failed > 1: - text = " ({f} tests failed)" - else: - text = " ({f} test failed)" + text = " ({f} tests failed)" if num_failed > 1 else " ({f} test failed)" self._stream.write(text.format(f=num_failed)) self._stream.write("\n") # TODO: here we lost the possibility to include also file name diff --git a/python/grass/imaging/__init__.py b/python/grass/imaging/__init__.py index 41626697f8e..7434942abe0 100644 --- a/python/grass/imaging/__init__.py +++ b/python/grass/imaging/__init__.py @@ -1,4 +1,15 @@ -from grass.imaging.images2gif import readGif, writeGif -from grass.imaging.images2swf import readSwf, writeSwf from grass.imaging.images2avi import readAvi, writeAvi +from grass.imaging.images2gif import readGif, writeGif from grass.imaging.images2ims import readIms, writeIms +from grass.imaging.images2swf import readSwf, writeSwf + +__all__ = [ + "readAvi", + "readGif", + "readIms", + "readSwf", + "writeAvi", + "writeGif", + "writeIms", + "writeSwf", +] diff --git a/python/grass/jupyter/__init__.py b/python/grass/jupyter/__init__.py index 91457f07ac3..21223c2cd47 100644 --- a/python/grass/jupyter/__init__.py +++ b/python/grass/jupyter/__init__.py @@ -109,6 +109,17 @@ from .interactivemap import InteractiveMap, Raster, Vector from .map import Map from .map3d import Map3D +from .seriesmap import SeriesMap from .setup import init from .timeseriesmap import TimeSeriesMap -from .seriesmap import SeriesMap + +__all__ = [ + "InteractiveMap", + "Map", + "Map3D", + "Raster", + "SeriesMap", + "TimeSeriesMap", + "Vector", + "init", +] diff --git a/python/grass/jupyter/map3d.py b/python/grass/jupyter/map3d.py index dd373f315a7..99253251406 100644 --- a/python/grass/jupyter/map3d.py +++ b/python/grass/jupyter/map3d.py @@ -210,10 +210,7 @@ def render(self, **kwargs): with Display( size=(self._width, self._height), **additional_kwargs ) as display: - if has_env_copy: - env = display.env() - else: - env = os.environ.copy() + env = display.env() if has_env_copy else os.environ.copy() self._region_manager.set_region_from_command(env=env, **kwargs) self.overlay.region_manager.set_region_from_env(env) gs.run_command(module, env=env, **kwargs) diff --git a/python/grass/pydispatch/signal.py b/python/grass/pydispatch/signal.py index 1e968e99dca..51808e01ee3 100644 --- a/python/grass/pydispatch/signal.py +++ b/python/grass/pydispatch/signal.py @@ -7,7 +7,7 @@ from grass.pydispatch import dispatcher -def _islambda(function): +def _islambda(function) -> bool: """ Tests if object is a lambda function. @@ -146,10 +146,7 @@ class connects to the signal:: will print """ if weak is None: - if _islambda(handler): - weak = False - else: - weak = True + weak = not _islambda(handler) dispatcher.connect(receiver=handler, signal=self, weak=weak) def disconnect(self, handler, weak=True): diff --git a/python/grass/pygrass/modules/__init__.py b/python/grass/pygrass/modules/__init__.py index 61073791599..ce4d169fedd 100644 --- a/python/grass/pygrass/modules/__init__.py +++ b/python/grass/pygrass/modules/__init__.py @@ -1,2 +1,9 @@ -from grass.pygrass.modules.interface import Module, MultiModule, ParallelModuleQueue from grass.pygrass.modules import shortcuts +from grass.pygrass.modules.interface import Module, MultiModule, ParallelModuleQueue + +__all__ = [ + "Module", + "MultiModule", + "ParallelModuleQueue", + "shortcuts", +] diff --git a/python/grass/pygrass/modules/grid/__init__.py b/python/grass/pygrass/modules/grid/__init__.py index 1c971174998..0d770ed3ad2 100644 --- a/python/grass/pygrass/modules/grid/__init__.py +++ b/python/grass/pygrass/modules/grid/__init__.py @@ -1 +1,3 @@ from grass.pygrass.modules.grid.grid import GridModule + +__all__ = ["GridModule"] diff --git a/python/grass/pygrass/modules/interface/__init__.py b/python/grass/pygrass/modules/interface/__init__.py index a05211e21c3..bde59049c6e 100644 --- a/python/grass/pygrass/modules/interface/__init__.py +++ b/python/grass/pygrass/modules/interface/__init__.py @@ -4,14 +4,20 @@ @author: pietro """ -from grass.pygrass.modules.interface import flag -from grass.pygrass.modules.interface import parameter -from grass.pygrass.modules.interface import module -from grass.pygrass.modules.interface import typedict -from grass.pygrass.modules.interface import read - +from grass.pygrass.modules.interface import flag, module, parameter, read, typedict from grass.pygrass.modules.interface.module import ( Module, MultiModule, ParallelModuleQueue, ) + +__all__ = [ + "Module", + "MultiModule", + "ParallelModuleQueue", + "flag", + "module", + "parameter", + "read", + "typedict", +] diff --git a/python/grass/pygrass/modules/interface/parameter.py b/python/grass/pygrass/modules/interface/parameter.py index 3b58ea2b372..1ec5466bc74 100644 --- a/python/grass/pygrass/modules/interface/parameter.py +++ b/python/grass/pygrass/modules/interface/parameter.py @@ -337,10 +337,7 @@ def __doc__(self): .. """ if hasattr(self, "values"): - if self.isrange: - vals = self.isrange - else: - vals = ", ".join([repr(val) for val in self.values]) + vals = self.isrange or ", ".join([repr(val) for val in self.values]) else: vals = False if self.keydescvalues: diff --git a/python/grass/pygrass/modules/testsuite/test_import_isolation.py b/python/grass/pygrass/modules/testsuite/test_import_isolation.py index d1321a554d0..af643ec2fee 100644 --- a/python/grass/pygrass/modules/testsuite/test_import_isolation.py +++ b/python/grass/pygrass/modules/testsuite/test_import_isolation.py @@ -36,14 +36,17 @@ def test_import_isolation(self): isolate, check(*self.patterns), msg="Test isolation before any import." ) # same import done in __init__ file - from grass.pygrass.modules.interface import Module, ParallelModuleQueue - from grass.pygrass.modules import shortcuts + from grass.pygrass.modules.interface import ( + Module, # noqa: F401 + ParallelModuleQueue, # noqa: F401 + ) + from grass.pygrass.modules import shortcuts # noqa: F401 self.assertEqual( isolate, check(*self.patterns), msg="Test isolation after import Module." ) # test the other way round - from grass.pygrass.vector import VectorTopo + from grass.pygrass.vector import VectorTopo # noqa: F401 self.assertNotEqual( isolate, diff --git a/python/grass/pygrass/rpc/__init__.py b/python/grass/pygrass/rpc/__init__.py index 07cbfe6503a..a6ab19b9369 100644 --- a/python/grass/pygrass/rpc/__init__.py +++ b/python/grass/pygrass/rpc/__init__.py @@ -10,8 +10,6 @@ :authors: Soeren Gebbert """ -import time -import threading import sys from multiprocessing import Process, Lock, Pipe from ctypes import CFUNCTYPE, c_void_p @@ -24,7 +22,6 @@ from .base import RPCServerBase from grass.pygrass.gis.region import Region from grass.pygrass import utils -import logging ############################################################################### ############################################################################### diff --git a/python/grass/pygrass/vector/__init__.py b/python/grass/pygrass/vector/__init__.py index 461050807b0..6723b2e44b3 100644 --- a/python/grass/pygrass/vector/__init__.py +++ b/python/grass/pygrass/vector/__init__.py @@ -859,10 +859,7 @@ def features_to_wkb_list(self, bbox=None, feature_type="point", field=1): ok = libvect.Vect_cat_get( ctypes.byref(line_c), field, ctypes.byref(cat) ) - if ok < 1: - pcat = None - else: - pcat = cat.value + pcat = None if ok < 1 else cat.value wkb_list.append((f_id, pcat, ctypes.string_at(barray, size.value))) libgis.G_free(barray) diff --git a/python/grass/pygrass/vector/geometry.py b/python/grass/pygrass/vector/geometry.py index 10ecb1d2d13..b734161d1ea 100644 --- a/python/grass/pygrass/vector/geometry.py +++ b/python/grass/pygrass/vector/geometry.py @@ -810,10 +810,7 @@ def extend(self, line, forward=True): """ # set direction - if forward: - direction = libvect.GV_FORWARD - else: - direction = libvect.GV_BACKWARD + direction = libvect.GV_FORWARD if forward else libvect.GV_BACKWARD # check if is a Line object if isinstance(line, Line): c_points = line.c_points diff --git a/python/grass/pygrass/vector/table.py b/python/grass/pygrass/vector/table.py index 9c8d0c3f9a2..5442d2f1e51 100644 --- a/python/grass/pygrass/vector/table.py +++ b/python/grass/pygrass/vector/table.py @@ -1261,10 +1261,7 @@ def create(self, cols, name=None, overwrite=False, cursor=None): """ cur = cursor or self.conn.cursor() coldef = ",\n".join(["%s %s" % col for col in cols]) - if name: - newname = name - else: - newname = self.name + newname = name or self.name try: cur.execute(sql.CREATE_TAB.format(tname=newname, coldef=coldef)) self.conn.commit() diff --git a/python/grass/pygrass/vector/testsuite/test_filters.py b/python/grass/pygrass/vector/testsuite/test_filters.py index 9252b134c02..9adba4cdefc 100644 --- a/python/grass/pygrass/vector/testsuite/test_filters.py +++ b/python/grass/pygrass/vector/testsuite/test_filters.py @@ -6,7 +6,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - from grass.pygrass.vector.table import Filters diff --git a/python/grass/pygrass/vector/testsuite/test_geometry.py b/python/grass/pygrass/vector/testsuite/test_geometry.py index b2a7a1e37df..6957a473165 100644 --- a/python/grass/pygrass/vector/testsuite/test_geometry.py +++ b/python/grass/pygrass/vector/testsuite/test_geometry.py @@ -6,18 +6,15 @@ import sys import unittest + import numpy as np +import grass.lib.vector as libvect from grass.gunittest.case import TestCase from grass.gunittest.main import test - -import grass.lib.vector as libvect -from grass.script.core import run_command - -from grass.pygrass.vector import Vector, VectorTopo -from grass.pygrass.vector.geometry import Point, Line, Node -from grass.pygrass.vector.geometry import Area, Boundary, Centroid +from grass.pygrass.vector import VectorTopo from grass.pygrass.vector.basic import Bbox +from grass.pygrass.vector.geometry import Area, Line, Node, Point class PointTestCase(TestCase): diff --git a/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py b/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py index 356a55ec4d7..cba638b1901 100644 --- a/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py +++ b/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py @@ -4,16 +4,8 @@ @author: pietro """ -import sys -import unittest -import numpy as np - from grass.gunittest.case import TestCase from grass.gunittest.main import test - -import grass.lib.vector as libvect -from grass.script.core import run_command - from grass.pygrass.vector import VectorTopo diff --git a/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py b/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py index b3d26220ec1..2cf0d0ba0c5 100644 --- a/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py +++ b/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py @@ -7,10 +7,7 @@ import grass.gunittest.case import grass.gunittest.main import grass.gunittest.utils - import grass.pygrass.vector as gvector -import grass.pygrass.utils as gutils - # doctest does not allow changing the base classes of test case, skip test case # and test suite, so we need to create a new type which inherits from our class diff --git a/python/grass/pygrass/vector/testsuite/test_table.py b/python/grass/pygrass/vector/testsuite/test_table.py index d87786fb3bd..c77233400b1 100644 --- a/python/grass/pygrass/vector/testsuite/test_table.py +++ b/python/grass/pygrass/vector/testsuite/test_table.py @@ -7,16 +7,15 @@ import os import sqlite3 import tempfile as tmp -from string import ascii_letters, digits from random import choice +from string import ascii_letters, digits + import numpy as np from grass.gunittest.case import TestCase from grass.gunittest.main import test - from grass.pygrass.vector.table import Table, get_path - # dictionary that generate random data RNG = np.random.default_rng() COL2VALS = { diff --git a/python/grass/pygrass/vector/testsuite/test_vector.py b/python/grass/pygrass/vector/testsuite/test_vector.py index 5d16333c31f..b4eebb2ab1e 100644 --- a/python/grass/pygrass/vector/testsuite/test_vector.py +++ b/python/grass/pygrass/vector/testsuite/test_vector.py @@ -6,8 +6,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import run_command from grass.pygrass.vector import VectorTopo diff --git a/python/grass/pygrass/vector/testsuite/test_vector3d.py b/python/grass/pygrass/vector/testsuite/test_vector3d.py index 796f85ca529..84e688d22e8 100644 --- a/python/grass/pygrass/vector/testsuite/test_vector3d.py +++ b/python/grass/pygrass/vector/testsuite/test_vector3d.py @@ -8,13 +8,9 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import run_command - +from grass.pygrass.gis.region import Region from grass.pygrass.vector import VectorTopo from grass.pygrass.vector.geometry import Point -from grass.pygrass.gis.region import Region -from grass.pygrass.utils import get_mapset_vector def generate_coordinates(number, bbox=None, with_z=False): diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index 8589e8a1521..ea82c2fe451 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -7,4 +7,4 @@ from .raster3d import * from .vector import * from .utils import * -from . import setup +from . import setup # noqa: F401 diff --git a/python/grass/script/core.py b/python/grass/script/core.py index 4f70f525133..0b51e7fdbe9 100644 --- a/python/grass/script/core.py +++ b/python/grass/script/core.py @@ -334,10 +334,7 @@ def get_module_and_code(args, kwargs): args = make_command(*args, **kwargs) # Since we are in error handler, let's be extra cautious # about an empty command. - if args: - module = args[0] - else: - module = None + module = args[0] if args else None code = " ".join(args) return module, code @@ -1699,10 +1696,7 @@ def mapsets(search_path=False, env=None): :return: list of mapsets """ - if search_path: - flags = "p" - else: - flags = "l" + flags = "p" if search_path else "l" mapsets = read_command("g.mapsets", flags=flags, sep="newline", quiet=True, env=env) if not mapsets: fatal(_("Unable to list mapsets")) @@ -2033,10 +2027,7 @@ def create_environment(gisdbase, location, mapset, env=None): f.write("GISDBASE: {g}\n".format(g=gisdbase)) f.write("LOCATION_NAME: {l}\n".format(l=location)) f.write("GUI: text\n") - if env: - env = env.copy() - else: - env = os.environ.copy() + env = env.copy() if env else os.environ.copy() env["GISRC"] = f.name # remove mapset-specific env vars env = sanitize_mapset_environment(env) diff --git a/python/grass/script/raster.py b/python/grass/script/raster.py index 54c1219dbaf..d82780d7c5c 100644 --- a/python/grass/script/raster.py +++ b/python/grass/script/raster.py @@ -218,10 +218,7 @@ def raster_what(map, coord, env=None, localized=False): query :param env: """ - if isinstance(map, (bytes, str)): - map_list = [map] - else: - map_list = map + map_list = [map] if isinstance(map, (bytes, str)) else map coord_list = [] if isinstance(coord, tuple): diff --git a/python/grass/script/task.py b/python/grass/script/task.py index cf398c59214..9867b3d8c49 100644 --- a/python/grass/script/task.py +++ b/python/grass/script/task.py @@ -345,14 +345,8 @@ def _process_params(self): for ki in node_key_desc.findall("item"): key_desc.append(ki.text) - if p.get("multiple", "no") == "yes": - multiple = True - else: - multiple = False - if p.get("required", "no") == "yes": - required = True - else: - required = False + multiple = p.get("multiple", "no") == "yes" + required = p.get("required", "no") == "yes" if ( self.task.blackList["enabled"] diff --git a/python/grass/script/testsuite/data/script_using_temporary_region.py b/python/grass/script/testsuite/data/script_using_temporary_region.py index 5bb5a4cda26..839bf3d0a72 100755 --- a/python/grass/script/testsuite/data/script_using_temporary_region.py +++ b/python/grass/script/testsuite/data/script_using_temporary_region.py @@ -65,15 +65,9 @@ def main(): argument = sys.argv[1] sizes = argument.split(",", 1) size = sizes[0] - if len(sizes) > 1: - remaining = sizes[1] - else: - remaining = None + remaining = sizes[1] if len(sizes) > 1 else None nesting = int(sys.argv[2]) - if len(sys.argv) == 4: - map_name = sys.argv[3] - else: - map_name = None + map_name = sys.argv[3] if len(sys.argv) == 4 else None call_use_temp_region( script=this_file, size=size, diff --git a/python/grass/script/utils.py b/python/grass/script/utils.py index 448289b57aa..25eb70190c5 100644 --- a/python/grass/script/utils.py +++ b/python/grass/script/utils.py @@ -190,10 +190,7 @@ def decode(bytes_, encoding=None): if isinstance(bytes_, str): return bytes_ if isinstance(bytes_, bytes): - if encoding is None: - enc = _get_encoding() - else: - enc = encoding + enc = _get_encoding() if encoding is None else encoding return bytes_.decode(enc) # only text should be used raise TypeError("can only accept types str and bytes") @@ -221,10 +218,7 @@ def encode(string, encoding=None): if isinstance(string, bytes): return string if isinstance(string, str): - if encoding is None: - enc = _get_encoding() - else: - enc = encoding + enc = _get_encoding() if encoding is None else encoding return string.encode(enc) # if something else than text raise TypeError("can only accept types str and bytes") @@ -276,10 +270,7 @@ def parse_key_val(s, sep="=", dflt=None, val_type=None, vsep=None): for line in lines: kv = line.split(sep, 1) k = decode(kv[0].strip()) - if len(kv) > 1: - v = decode(kv[1].strip()) - else: - v = dflt + v = decode(kv[1].strip()) if len(kv) > 1 else dflt if val_type: result[k] = val_type(v) @@ -353,10 +344,7 @@ def convert(text): return int(text) if text.isdigit() else text.lower() def alphanum_key(actual_key): - if key: - sort_key = key(actual_key) - else: - sort_key = actual_key + sort_key = key(actual_key) if key else actual_key return [convert(c) for c in re.split("([0-9]+)", sort_key)] items.sort(key=alphanum_key) diff --git a/python/grass/script/vector.py b/python/grass/script/vector.py index ca3caf18471..2d484f7d590 100644 --- a/python/grass/script/vector.py +++ b/python/grass/script/vector.py @@ -129,10 +129,7 @@ def vector_columns(map, layer=None, getDict=True, env=None, **kwargs): s = read_command( "v.info", flags="c", map=map, layer=layer, quiet=True, env=env, **kwargs ) - if getDict: - result = {} - else: - result = [] + result = {} if getDict else [] i = 0 for line in s.splitlines(): ctype, cname = line.split("|") @@ -377,10 +374,7 @@ def vector_what( if "LC_ALL" in env: env["LC_ALL"] = "C" - if isinstance(map, (bytes, str)): - map_list = [map] - else: - map_list = map + map_list = [map] if isinstance(map, (bytes, str)) else map if layer: if isinstance(layer, (tuple, list)): diff --git a/python/grass/semantic_label/__init__.py b/python/grass/semantic_label/__init__.py index 9f0b9b6caed..58bfe11a418 100644 --- a/python/grass/semantic_label/__init__.py +++ b/python/grass/semantic_label/__init__.py @@ -1 +1,3 @@ from .reader import SemanticLabelReader, SemanticLabelReaderError + +__all__ = ["SemanticLabelReader", "SemanticLabelReaderError"] diff --git a/python/grass/temporal/abstract_map_dataset.py b/python/grass/temporal/abstract_map_dataset.py index ecbf761d139..f6bec2bfef3 100644 --- a/python/grass/temporal/abstract_map_dataset.py +++ b/python/grass/temporal/abstract_map_dataset.py @@ -820,10 +820,7 @@ def temporal_buffer(self, increment, update=False, dbif=None): else: start, end, unit = self.get_relative_time() new_start = start - increment - if end is None: - new_end = start + increment - else: - new_end = end + increment + new_end = start + increment if end is None else end + increment if update: self.update_relative_time(new_start, new_end, unit, dbif=dbif) diff --git a/python/grass/temporal/abstract_space_time_dataset.py b/python/grass/temporal/abstract_space_time_dataset.py index d17baaab6ae..8140a2da261 100644 --- a/python/grass/temporal/abstract_space_time_dataset.py +++ b/python/grass/temporal/abstract_space_time_dataset.py @@ -779,10 +779,7 @@ def sample_by_dataset(self, stds, method=None, spatial=False, dbif=None): # print(relations) tb = SpatioTemporalTopologyBuilder() - if spatial: - spatial = "2D" - else: - spatial = None + spatial = "2D" if spatial else None mapsA = self.get_registered_maps_as_objects(dbif=dbif) mapsB = stds.get_registered_maps_as_objects_with_gaps(dbif=dbif) @@ -1429,10 +1426,7 @@ def get_registered_maps_as_objects_with_gaps( start1, end1 = maps[i].get_temporal_extent_as_tuple() start2, end2 = maps[i + 1].get_temporal_extent_as_tuple() end = start2 - if end1 is not None: - start = end1 - else: - start = start1 + start = end1 if end1 is not None else start1 map = self.get_new_map_instance(None) diff --git a/python/grass/temporal/c_libraries_interface.py b/python/grass/temporal/c_libraries_interface.py index 85a19a3ec6e..0d24fc0f732 100644 --- a/python/grass/temporal/c_libraries_interface.py +++ b/python/grass/temporal/c_libraries_interface.py @@ -256,11 +256,7 @@ def _get_driver_name(lock, conn, data): :returns: Name of the driver or None if no temporal database present """ mapset = data[1] - if not mapset: - mapset = libgis.G_mapset() - else: - mapset = encode(mapset) - + mapset = libgis.G_mapset() if not mapset else encode(mapset) drstring = libtgis.tgis_get_mapset_driver_name(mapset) conn.send(decode(drstring.data)) @@ -280,10 +276,7 @@ def _get_database_name(lock, conn, data): dbstring = None try: mapset = data[1] - if not mapset: - mapset = libgis.G_mapset() - else: - mapset = encode(mapset) + mapset = libgis.G_mapset() if not mapset else encode(mapset) dbstring = libtgis.tgis_get_mapset_database_name(mapset) dbstring = dbstring.data diff --git a/python/grass/temporal/datetime_math.py b/python/grass/temporal/datetime_math.py index 1031582fe23..b986637162a 100644 --- a/python/grass/temporal/datetime_math.py +++ b/python/grass/temporal/datetime_math.py @@ -694,10 +694,7 @@ def compute_datetime_delta(start, end): else: d += 24 * 60 * day_diff elif d == 0: - if comp["hour"]: - d = 60 * comp["hour"] - else: - d = 24 * 60 * day_diff + d = 60 * comp["hour"] if comp["hour"] else 24 * 60 * day_diff comp["minute"] = d @@ -914,10 +911,7 @@ def datetime_to_grass_datetime_string(dt): # Check for time zone info in the datetime object if dt.tzinfo is not None: tz = dt.tzinfo.utcoffset(0) - if tz.seconds > 86400 / 2: - tz = (tz.seconds - 86400) / 60 - else: - tz = tz.seconds / 60 + tz = (tz.seconds - 86400) / 60 if tz.seconds > 86400 / 2 else tz.seconds / 60 string = "%.2i %s %.2i %.2i:%.2i:%.2i %+.4i" % ( dt.day, @@ -999,10 +993,7 @@ def create_numeric_suffix(base, count, zeros): if len(spli) == 2: suff = spli[1] if suff.isdigit(): - if int(suff[0]) == 0: - zero = suff - else: - zero = "0{nu}".format(nu=suff) + zero = suff if int(suff[0]) == 0 else "0{nu}".format(nu=suff) else: zero = "05" else: diff --git a/python/grass/temporal/gui_support.py b/python/grass/temporal/gui_support.py index 41f22edc6b7..d2cbca13d68 100644 --- a/python/grass/temporal/gui_support.py +++ b/python/grass/temporal/gui_support.py @@ -37,16 +37,14 @@ def tlist_grouped(type, group_type=False, dbif=None): :return: directory of mapsets/elements """ result = {} + _type = type dbif, connection_state_changed = init_dbif(dbif) mapset = None - if type == "stds": - types = ["strds", "str3ds", "stvds"] - else: - types = [type] - for type in types: + types = ["strds", "str3ds", "stvds"] if _type == "stds" else [_type] + for _type in types: try: - tlist_result = tlist(type=type, dbif=dbif) + tlist_result = tlist(type=_type, dbif=dbif) except gs.ScriptError as e: gs.warning(e) continue @@ -65,10 +63,10 @@ def tlist_grouped(type, group_type=False, dbif=None): result[mapset] = [] if group_type: - if type in result[mapset]: - result[mapset][type].append(name) + if _type in result[mapset]: + result[mapset][_type].append(name) else: - result[mapset][type] = [ + result[mapset][_type] = [ name, ] else: @@ -90,19 +88,20 @@ def tlist(type, dbif=None): :return: a list of space time dataset ids """ + _type = type id = None - sp = dataset_factory(type, id) + sp = dataset_factory(_type, id) dbif, connection_state_changed = init_dbif(dbif) mapsets = get_available_temporal_mapsets() output = [] temporal_type = ["absolute", "relative"] - for type in temporal_type: + for _type in temporal_type: # For each available mapset for mapset in mapsets.keys(): # Table name - if type == "absolute": + if _type == "absolute": table = sp.get_type() + "_view_abs_time" else: table = sp.get_type() + "_view_rel_time" diff --git a/python/grass/temporal/list_stds.py b/python/grass/temporal/list_stds.py index 9f6b6867766..22a2708123d 100644 --- a/python/grass/temporal/list_stds.py +++ b/python/grass/temporal/list_stds.py @@ -325,10 +325,7 @@ def _get_get_registered_maps_as_objects_delta_gran( msgr.fatal(_("Empty entry in map list, this should not happen")) start, end = map_object.get_temporal_extent_as_tuple() - if end: - delta = end - start - else: - delta = None + delta = end - start if end else None delta_first = start - first_time if map_object.is_time_absolute(): diff --git a/python/grass/temporal/register.py b/python/grass/temporal/register.py index 92be36a3547..d8705765d02 100644 --- a/python/grass/temporal/register.py +++ b/python/grass/temporal/register.py @@ -158,10 +158,7 @@ def register_maps_in_space_time_dataset( # Read the map list from file if file: - if hasattr(file, "readline"): - fd = file - else: - fd = open(file) + fd = file if hasattr(file, "readline") else open(file) line = True while True: @@ -639,10 +636,7 @@ def register_map_object_list( string = f"{id}|{start}|{end}\n" register_file.write(string) - if output_stds: - output_stds_id = output_stds.get_id() - else: - output_stds_id = None + output_stds_id = output_stds.get_id() if output_stds else None register_maps_in_space_time_dataset( type, output_stds_id, unit=unit, file=filename, dbif=dbif diff --git a/python/grass/temporal/sampling.py b/python/grass/temporal/sampling.py index 425ca484da5..5209ce6a80c 100644 --- a/python/grass/temporal/sampling.py +++ b/python/grass/temporal/sampling.py @@ -82,19 +82,11 @@ def sample_stds_by_stds_topology( sts = [] for input in inputs: - if input.find("@") >= 0: - id = input - else: - id = input + "@" + mapset - + id = input if input.find("@") >= 0 else input + "@" + mapset st = dataset_factory(intype, id) sts.append(st) - if sampler.find("@") >= 0: - sid = sampler - else: - sid = sampler + "@" + mapset - + sid = sampler if sampler.find("@") >= 0 else sampler + "@" + mapset sst = dataset_factory(sampletype, sid) dbif = SQLDatabaseInterfaceConnection() @@ -156,10 +148,7 @@ def sample_stds_by_stds_topology( map = entry["granule"] start, end = map.get_temporal_extent_as_tuple() - if end: - delta = end - start - else: - delta = None + delta = end - start if end else None delta_first = start - first_time if map.is_time_absolute(): diff --git a/python/grass/temporal/temporal_algebra.py b/python/grass/temporal/temporal_algebra.py index e4717eb3326..2429b61e35e 100644 --- a/python/grass/temporal/temporal_algebra.py +++ b/python/grass/temporal/temporal_algebra.py @@ -992,10 +992,7 @@ def generate_map_name(self): same object for map name generation in multiple threads. """ self.count += 1 - if self.pid is not None: - pid = self.pid - else: - pid = os.getpid() + pid = self.pid if self.pid is not None else os.getpid() name = "tmp_map_name_%i_%i" % (pid, self.count) self.names[name] = name return name @@ -1234,10 +1231,7 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True): """ if isinstance(input, str): # Check for mapset in given stds input. - if input.find("@") >= 0: - id_input = input - else: - id_input = input + "@" + self.mapset + id_input = input if input.find("@") >= 0 else input + "@" + self.mapset # Create empty spacetime dataset. if stds_type: stds = dataset_factory(stds_type, id_input) @@ -1634,7 +1628,7 @@ def build_spatio_temporal_topology_list( def assign_bool_value( self, map_i, temporal_topo_list=["EQUAL"], spatial_topo_list=[] - ): + ) -> bool: """Function to assign boolean map value based on the map_values from the compared map list by topological relationships. @@ -1668,10 +1662,7 @@ def assign_bool_value( str(relationmap.get_temporal_extent_as_tuple()) + str(boolean), ) - if all(condition_value_list): - resultbool = True - else: - resultbool = False + resultbool = bool(all(condition_value_list)) map_i.condition_value = [resultbool] return resultbool @@ -2296,20 +2287,14 @@ def recurse_compare(conditionlist): ele_index = conditionlist.index(ele) right = conditionlist.pop(ele_index) left = conditionlist.pop(ele_index - 2) - if any([left, right]): - result = True - else: - result = False + result = bool(any([left, right])) conditionlist[ele_index - 2] = result recurse_compare(conditionlist) if ele == "&&": ele_index = conditionlist.index(ele) right = conditionlist.pop(ele_index) left = conditionlist.pop(ele_index - 2) - if all([left, right]): - result = True - else: - result = False + result = bool(all([left, right])) conditionlist[ele_index - 2] = result recurse_compare(conditionlist) @@ -2643,10 +2628,7 @@ def p_expr_tmap_function(self, t): input = t[3] if not isinstance(input, list): # Check for mapset in given stds input. - if input.find("@") >= 0: - id_input = input - else: - id_input = input + "@" + self.mapset + id_input = input if input.find("@") >= 0 else input + "@" + self.mapset # Create empty map dataset. map_i = dataset_factory(self.maptype, id_input) # Check for occurrence of space time dataset. @@ -3079,10 +3061,7 @@ def p_expr_t_select_operator(self, t): # Evaluate temporal operator. operators = self.eval_toperator(t[2], optype="select") # Check for negative selection. - if operators[2] == "!:": - negation = True - else: - negation = False + negation = operators[2] == "!:" # Perform selection. selectlist = self.perform_temporal_selection( maplistA, maplistB, topolist=operators[0], inverse=negation diff --git a/python/grass/temporal/temporal_granularity.py b/python/grass/temporal/temporal_granularity.py index b4043054520..173e4e715ea 100644 --- a/python/grass/temporal/temporal_granularity.py +++ b/python/grass/temporal/temporal_granularity.py @@ -494,7 +494,7 @@ def compute_absolute_time_granularity(maps): # Keep the temporal extent to compare to the following/next map previous_start, previous_end = start, end - # Create a list with a single time unit only + # Create a set with a single time unit only dlist = set() assigned_time_unit = None time_unit_multipliers = { @@ -529,11 +529,8 @@ def compute_absolute_time_granularity(maps): if not dlist: return None - if len(dlist) > 1: - # Find greatest common divisor - granularity = gcd_list(dlist) - else: - granularity = dlist.pop() + # Find greatest common divisor to get a single time unit + granularity = gcd_list(dlist) if len(dlist) > 1 else dlist.pop() if granularity is None: return None diff --git a/python/grass/temporal/temporal_raster_base_algebra.py b/python/grass/temporal/temporal_raster_base_algebra.py index 8ff156cbed5..cb2122f4a37 100644 --- a/python/grass/temporal/temporal_raster_base_algebra.py +++ b/python/grass/temporal/temporal_raster_base_algebra.py @@ -960,10 +960,7 @@ def p_expr_spmap_function(self, t): input = t[3] if not isinstance(input, list): # Check for mapset in given stds input. - if input.find("@") >= 0: - id_input = input - else: - id_input = input + "@" + self.mapset + id_input = input if input.find("@") >= 0 else input + "@" + self.mapset # Create empty map dataset. map_i = dataset_factory(self.maptype, id_input) # Check for occurrence of space time dataset. diff --git a/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py b/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py index 7e0db57a8ce..d7a81bcb34d 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py +++ b/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py @@ -8,7 +8,6 @@ """ import datetime -import os import grass.temporal as tgis from grass.gunittest.case import TestCase diff --git a/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py b/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py index cf0e9c82bb7..ce911839049 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py +++ b/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py @@ -8,7 +8,6 @@ """ import datetime -import os import grass.temporal as tgis from grass.gunittest.case import TestCase diff --git a/python/grass/temporal/testsuite/unittests_temporal_conditionals.py b/python/grass/temporal/testsuite/unittests_temporal_conditionals.py index ff0703aec1d..800c7d30bf6 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_conditionals.py +++ b/python/grass/temporal/testsuite/unittests_temporal_conditionals.py @@ -8,7 +8,6 @@ """ import datetime -import os import grass.temporal as tgis from grass.gunittest.case import TestCase diff --git a/python/grass/temporal/univar_statistics.py b/python/grass/temporal/univar_statistics.py index dd334e7e9f1..b6a9c1ac508 100755 --- a/python/grass/temporal/univar_statistics.py +++ b/python/grass/temporal/univar_statistics.py @@ -304,10 +304,7 @@ def print_vector_dataset_univar_statistics( mapset = get_current_mapset() - if input.find("@") >= 0: - id = input - else: - id = input + "@" + mapset + id = input if input.find("@") >= 0 else input + "@" + mapset sp = dataset_factory("stvds", id) diff --git a/raster/r.in.ascii/testsuite/test_r_in_ascii.py b/raster/r.in.ascii/testsuite/test_r_in_ascii.py index baa892d83a8..8db06f83517 100644 --- a/raster/r.in.ascii/testsuite/test_r_in_ascii.py +++ b/raster/r.in.ascii/testsuite/test_r_in_ascii.py @@ -11,7 +11,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.script.core import read_command INPUT_NOQUOTES = """north: 4299000.00 south: 4247000.00 diff --git a/raster/r.object.geometry/testsuite/test_r_object_geometry.py b/raster/r.object.geometry/testsuite/test_r_object_geometry.py index 419df4d780b..279d46ae4f0 100644 --- a/raster/r.object.geometry/testsuite/test_r_object_geometry.py +++ b/raster/r.object.geometry/testsuite/test_r_object_geometry.py @@ -6,11 +6,9 @@ import json import os -from sys import stderr from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.gunittest.gmodules import call_module from grass.gunittest.gmodules import SimpleModule diff --git a/raster/r.viewshed/testsuite/test_r_viewshed.py b/raster/r.viewshed/testsuite/test_r_viewshed.py index 2b136abd551..a341d8e97b5 100644 --- a/raster/r.viewshed/testsuite/test_r_viewshed.py +++ b/raster/r.viewshed/testsuite/test_r_viewshed.py @@ -1,6 +1,5 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.gunittest.gmodules import call_module class TestViewshed(TestCase): diff --git a/raster3d/r3.showdspf/main_ogl.c b/raster3d/r3.showdspf/main_ogl.c index 55b3097e2cf..da6e90a3721 100644 --- a/raster3d/r3.showdspf/main_ogl.c +++ b/raster3d/r3.showdspf/main_ogl.c @@ -1159,7 +1159,7 @@ void do__draw(file_info *Headp, struct dspec *D_spec) fdraw_polys(D_spec); break; case 2: - case3: + case 3: gdraw_polys(D_spec); break; } diff --git a/scripts/d.rast.edit/d.rast.edit.py b/scripts/d.rast.edit/d.rast.edit.py index ea6cc1e46bf..102d7e447d8 100755 --- a/scripts/d.rast.edit/d.rast.edit.py +++ b/scripts/d.rast.edit/d.rast.edit.py @@ -295,10 +295,7 @@ def paint_cell(self, dc, r, c): px, py = -dy, dx r, g, b, a = wx.Colour(fill).Get() - if r + g + b > 384: - line = "black" - else: - line = "white" + line = "black" if r + g + b > 384 else "white" dc.SetPen(wx.Pen(line)) dc.DrawLine(x0, y0, x1, y1) @@ -647,28 +644,9 @@ def update_status(self, row, col): if self.angles: self.status["aspect"] = self.angles[row][col] - def force_color(self, val): - run("g.region", rows=1, cols=1) - run("r.mapcalc", expression="%s = %d" % (self.tempmap, val)) - run("r.colors", map=self.tempmap, rast=self.inmap) - run("r.out.ppm", input=self.tempmap, out=self.tempfile) - run("g.remove", flags="f", type="raster", name=self.tempmap) - - tempimg = wx.Image(self.tempfile) - gs.try_remove(self.tempfile) - - rgb = tempimg.get(0, 0) - color = "#%02x%02x%02x" % rgb - self.colors[val] = color - tempimg.delete() - def get_color(self, val): if val not in self.colors: - try: - self.force_color(val) - except: - self.colors[val] = "#ffffff" - + self.colors[val] = "#ffffff" return self.colors[val] def refresh_canvas(self): diff --git a/scripts/d.rast.leg/d.rast.leg.py b/scripts/d.rast.leg/d.rast.leg.py index 85cb423f9e9..74576113577 100755 --- a/scripts/d.rast.leg/d.rast.leg.py +++ b/scripts/d.rast.leg/d.rast.leg.py @@ -132,16 +132,10 @@ def main(): if not nlines: nlines = None - if rast: - lmap = rast - else: - lmap = map + lmap = rast or map kv = gs.raster_info(map=lmap) - if kv["datatype"] == "CELL": - leg_at = None - else: - leg_at = "%f,95,5,10" % VSpacing + leg_at = None if kv["datatype"] == "CELL" else "%f,95,5,10" % VSpacing # checking for histogram causes more problems than it solves # histfiledir = grass.find_file(lmap, 'cell_misc')['file'] diff --git a/scripts/db.droptable/db.droptable.py b/scripts/db.droptable/db.droptable.py index 571638748cf..39408221acc 100755 --- a/scripts/db.droptable/db.droptable.py +++ b/scripts/db.droptable/db.droptable.py @@ -56,14 +56,8 @@ def main(): gs.run_command("db.connect", flags="c", quiet=True) kv = gs.db_connection() - if options["database"]: - database = options["database"] - else: - database = kv["database"] - if options["driver"]: - driver = options["driver"] - else: - driver = kv["driver"] + database = options["database"] or kv["database"] + driver = options["driver"] or kv["driver"] # schema needed for PG? if force: diff --git a/scripts/db.in.ogr/testsuite/test_db_in_ogr.py b/scripts/db.in.ogr/testsuite/test_db_in_ogr.py index 423917e1b93..b79efa1f096 100644 --- a/scripts/db.in.ogr/testsuite/test_db_in_ogr.py +++ b/scripts/db.in.ogr/testsuite/test_db_in_ogr.py @@ -8,7 +8,6 @@ from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule -from grass.script.core import run_command from grass.script.utils import decode import os diff --git a/scripts/db.out.ogr/db.out.ogr.py b/scripts/db.out.ogr/db.out.ogr.py index 4a840755b20..4fdfed23648 100755 --- a/scripts/db.out.ogr/db.out.ogr.py +++ b/scripts/db.out.ogr/db.out.ogr.py @@ -72,10 +72,7 @@ def main(): if format.lower() == "dbf": format = "ESRI_Shapefile" - if format.lower() == "csv": - olayer = basename(output, "csv") - else: - olayer = None + olayer = basename(output, "csv") if format.lower() == "csv" else None # is there a simpler way of testing for --overwrite? dbffile = input + ".dbf" diff --git a/scripts/db.univar/db.univar.py b/scripts/db.univar/db.univar.py index 97dfbdb7dbe..4654e3011a0 100755 --- a/scripts/db.univar/db.univar.py +++ b/scripts/db.univar/db.univar.py @@ -118,10 +118,7 @@ def main(): perc = [float(p) for p in perc.split(",")] if not output_format: - if shellstyle: - output_format = "shell" - else: - output_format = "plain" + output_format = "shell" if shellstyle else "plain" elif shellstyle: # This can be a message or warning in future versions. # In version 9, -g may be removed. diff --git a/scripts/g.extension/g.extension.py b/scripts/g.extension/g.extension.py index 194f498d49c..f14a742ca06 100644 --- a/scripts/g.extension/g.extension.py +++ b/scripts/g.extension/g.extension.py @@ -1608,10 +1608,7 @@ def install_extension_win(name): source, url = resolve_source_code(url="{0}/{1}.zip".format(base_url, name)) # to hide non-error messages from subprocesses - if gs.verbosity() <= 2: - outdev = open(os.devnull, "w") - else: - outdev = sys.stdout + outdev = open(os.devnull, "w") if gs.verbosity() <= 2 else sys.stdout # download Addons ZIP file os.chdir(TMPDIR) # this is just to not leave something behind @@ -1961,10 +1958,7 @@ def install_extension_std_platforms(name, source, url, branch): path_to_src_code_message = _("Path to the source code:") # to hide non-error messages from subprocesses - if gs.verbosity() <= 2: - outdev = open(os.devnull, "w") - else: - outdev = sys.stdout + outdev = open(os.devnull, "w") if gs.verbosity() <= 2 else sys.stdout os.chdir(TMPDIR) # this is just to not leave something behind srcdir = os.path.join(TMPDIR, name) @@ -2578,10 +2572,7 @@ def resolve_known_host_service(url, name, branch): ) return None, None if match: - if not actual_start: - actual_start = match["url_start"] - else: - actual_start = "" + actual_start = match["url_start"] if not actual_start else "" if "branch" in match["url_end"]: suffix = match["url_end"].format( name=name, diff --git a/scripts/g.manual/g.manual.py b/scripts/g.manual/g.manual.py index f4ecf961076..345a6d1714a 100755 --- a/scripts/g.manual/g.manual.py +++ b/scripts/g.manual/g.manual.py @@ -132,10 +132,7 @@ def main(): elif flags["t"]: special = "topics" - if flags["m"]: - start = start_man - else: - start = start_browser + start = start_man if flags["m"] else start_browser entry = options["entry"] gisbase = os.environ["GISBASE"] diff --git a/scripts/i.in.spotvgt/i.in.spotvgt.py b/scripts/i.in.spotvgt/i.in.spotvgt.py index cd744d4c252..666f3721761 100755 --- a/scripts/i.in.spotvgt/i.in.spotvgt.py +++ b/scripts/i.in.spotvgt/i.in.spotvgt.py @@ -136,11 +136,7 @@ def main(): spotdir = os.path.dirname(infile) spotname = gs.basename(infile, "hdf") - - if rast: - name = rast - else: - name = spotname + name = rast or spotname if not gs.overwrite() and gs.find_file(name)["file"]: gs.fatal(_("<%s> already exists. Aborting.") % name) diff --git a/scripts/i.oif/i.oif.py b/scripts/i.oif/i.oif.py index 0dabbe7cb38..cb156675927 100755 --- a/scripts/i.oif/i.oif.py +++ b/scripts/i.oif/i.oif.py @@ -90,10 +90,7 @@ def main(): stddev[band] = float(kv["stddev"]) else: # run all bands in parallel - if "WORKERS" in os.environ: - workers = int(os.environ["WORKERS"]) - else: - workers = len(bands) + workers = int(os.environ["WORKERS"]) if "WORKERS" in os.environ else len(bands) proc = {} pout = {} @@ -142,10 +139,7 @@ def main(): _("The Optimum Index Factor analysis result (best combination shown first):") ) - if shell: - fmt = "%s,%s,%s:%.4f\n" - else: - fmt = "%s, %s, %s: %.4f\n" + fmt = "%s,%s,%s:%.4f\n" if shell else "%s, %s, %s: %.4f\n" if not output or output == "-": for v, p in oif: diff --git a/scripts/i.spectral/i.spectral.py b/scripts/i.spectral/i.spectral.py index 171eac7359c..07efd8af31f 100755 --- a/scripts/i.spectral/i.spectral.py +++ b/scripts/i.spectral/i.spectral.py @@ -136,10 +136,7 @@ def draw_gnuplot(what, xlabels, output, img_format, coord_legend): cmd = [] for i, row in enumerate(what): - if not coord_legend: - title = "Pick " + str(i + 1) - else: - title = str(tuple(row[0:2])) + title = "Pick " + str(i + 1) if not coord_legend else str(tuple(row[0:2])) x_datafile = os.path.join(tmp_dir, "data_%d" % i) cmd.append(" '%s' title '%s'" % (x_datafile, title)) diff --git a/scripts/m.proj/m.proj.py b/scripts/m.proj/m.proj.py index 4540b3dcd0a..a018606fff9 100755 --- a/scripts/m.proj/m.proj.py +++ b/scripts/m.proj/m.proj.py @@ -236,14 +236,8 @@ def main(): gcore.debug("output file=[%s]" % outfile) # set up output style - if not decimal: - outfmt = ["-w5"] - else: - outfmt = ["-f", "%.8f"] - if not copy_input: - copyinp = [] - else: - copyinp = ["-E"] + outfmt = ["-w5"] if not decimal else ["-f", "%.8f"] + copyinp = [] if not copy_input else ["-E"] # do the conversion # Convert cs2cs DMS format to GRASS DMS format: diff --git a/scripts/r.buffer.lowmem/r.buffer.lowmem.py b/scripts/r.buffer.lowmem/r.buffer.lowmem.py index 2916ad95e7d..8866c21faeb 100755 --- a/scripts/r.buffer.lowmem/r.buffer.lowmem.py +++ b/scripts/r.buffer.lowmem/r.buffer.lowmem.py @@ -92,10 +92,7 @@ def main(): s = gs.read_command("g.proj", flags="j") kv = gs.parse_key_val(s) - if kv["+proj"] == "longlat": - metric = "geodesic" - else: - metric = "squared" + metric = "geodesic" if kv["+proj"] == "longlat" else "squared" gs.run_command( "r.grow.distance", input=input, metric=metric, distance=temp_dist, flags="m" diff --git a/scripts/r.fillnulls/testsuite/test_r_fillnulls.py b/scripts/r.fillnulls/testsuite/test_r_fillnulls.py index 975fd5330f2..dda6d99ed95 100644 --- a/scripts/r.fillnulls/testsuite/test_r_fillnulls.py +++ b/scripts/r.fillnulls/testsuite/test_r_fillnulls.py @@ -4,8 +4,6 @@ @author: Sanjeet Bhatti """ -import os - from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule diff --git a/scripts/r.grow/testsuite/test_r_grow.py b/scripts/r.grow/testsuite/test_r_grow.py index 3d54b9ab993..1c9488b4180 100644 --- a/scripts/r.grow/testsuite/test_r_grow.py +++ b/scripts/r.grow/testsuite/test_r_grow.py @@ -7,7 +7,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule -from grass.script.core import run_command class TestRGrow(TestCase): diff --git a/scripts/r.in.aster/r.in.aster.py b/scripts/r.in.aster/r.in.aster.py index 24722293dde..626d27e7976 100755 --- a/scripts/r.in.aster/r.in.aster.py +++ b/scripts/r.in.aster/r.in.aster.py @@ -152,10 +152,7 @@ def main(): # Band 3b is not included ASTER L1T if proctype == "L1T": allbands.remove("3b") - if band == "all": - bandlist = allbands - else: - bandlist = band.split(",") + bandlist = allbands if band == "all" else band.split(",") # initialize datasets for L1A, L1B, L1T if proctype in {"L1A", "L1B", "L1T"}: diff --git a/scripts/r.in.srtm/r.in.srtm.py b/scripts/r.in.srtm/r.in.srtm.py index 1e4c585ac02..49c7cef9758 100755 --- a/scripts/r.in.srtm/r.in.srtm.py +++ b/scripts/r.in.srtm/r.in.srtm.py @@ -76,6 +76,7 @@ import atexit import grass.script as gs import zipfile as zfile +from grass.exceptions import CalledModuleError tmpl1sec = """BYTEORDER M @@ -177,10 +178,7 @@ def main(): infile = infile[:-4] (fdir, tile) = os.path.split(infile) - if not output: - tileout = tile - else: - tileout = output + tileout = output or tile if ".hgt" in input: suff = ".hgt" @@ -230,7 +228,7 @@ def main(): try: zf = zfile.ZipFile(zipfile) zf.extractall() - except: + except (zfile.BadZipfile, zfile.LargeZipFile, PermissionError): gs.fatal(_("Unable to unzip file.")) gs.message(_("Converting input file to BIL...")) @@ -277,7 +275,7 @@ def main(): try: gs.run_command("r.in.gdal", input=bilfile, out=tileout) - except: + except CalledModuleError: gs.fatal(_("Unable to import data")) # nice color table diff --git a/scripts/r.in.wms/wms_cap_parsers.py b/scripts/r.in.wms/wms_cap_parsers.py index 56b1d0ce48c..723a63f0b23 100644 --- a/scripts/r.in.wms/wms_cap_parsers.py +++ b/scripts/r.in.wms/wms_cap_parsers.py @@ -501,10 +501,7 @@ def _find(self, etreeElement, tag, ns=None): """!Find child element. If the element is not found it raises xml.etree.ElementTree.ParseError. """ - if not ns: - res = etreeElement.find(tag) - else: - res = etreeElement.find(ns(tag)) + res = etreeElement.find(tag) if not ns else etreeElement.find(ns(tag)) if res is None: raise ParseError( @@ -521,10 +518,7 @@ def _findall(self, etreeElement, tag, ns=None): """!Find all children element. If no element is found it raises xml.etree.ElementTree.ParseError. """ - if not ns: - res = etreeElement.findall(tag) - else: - res = etreeElement.findall(ns(tag)) + res = etreeElement.findall(tag) if not ns else etreeElement.findall(ns(tag)) if not res: raise ParseError( diff --git a/scripts/r.in.wms/wms_drv.py b/scripts/r.in.wms/wms_drv.py index 531112a1a6c..e1131918c4a 100644 --- a/scripts/r.in.wms/wms_drv.py +++ b/scripts/r.in.wms/wms_drv.py @@ -995,10 +995,7 @@ def _parseTilePattern(self, group_t_patts, bbox, region): res["y"] = (bbox["maxy"] - bbox["miny"]) / region["rows"] res["x"] = (bbox["maxx"] - bbox["minx"]) / region["cols"] - if res["x"] < res["y"]: - comp_res = "x" - else: - comp_res = "y" + comp_res = "x" if res["x"] < res["y"] else "y" t_res = {} best_patt = None diff --git a/scripts/r.out.xyz/r.out.xyz.py b/scripts/r.out.xyz/r.out.xyz.py index ae8e04de4d6..6df97f3c202 100755 --- a/scripts/r.out.xyz/r.out.xyz.py +++ b/scripts/r.out.xyz/r.out.xyz.py @@ -48,10 +48,7 @@ def main(): output = options["output"] donodata = flags["i"] - if donodata: - statsflags = "1g" - else: - statsflags = "1gn" + statsflags = "1g" if donodata else "1gn" parameters = { "flags": statsflags, "input": options["input"], diff --git a/scripts/r.reclass.area/r.reclass.area.py b/scripts/r.reclass.area/r.reclass.area.py index 5d6fc1292bc..01e474659bc 100755 --- a/scripts/r.reclass.area/r.reclass.area.py +++ b/scripts/r.reclass.area/r.reclass.area.py @@ -152,10 +152,7 @@ def reclass(inf, outf, lim, clump, diag, les): if len(f) < 5: continue hectares = float(f[4]) * 0.0001 - if lesser: - test = hectares <= limit - else: - test = hectares >= limit + test = hectares <= limit if lesser else hectares >= limit if test: rules += "%s = %s %s\n" % (f[0], f[2], f[3]) if rules: diff --git a/scripts/r.unpack/r.unpack.py b/scripts/r.unpack/r.unpack.py index 575d465ebb5..dd595b4722b 100644 --- a/scripts/r.unpack/r.unpack.py +++ b/scripts/r.unpack/r.unpack.py @@ -92,10 +92,7 @@ def main(): return 0 - if options["output"]: - map_name = options["output"] - else: - map_name = data_names[0].split("@")[0] + map_name = options["output"] or data_names[0].split("@")[0] gfile = grass.find_file(name=map_name, element="cell", mapset=".") if gfile["file"]: diff --git a/scripts/r3.in.xyz/r3.in.xyz.py b/scripts/r3.in.xyz/r3.in.xyz.py index b17d59506b7..5b2c8be4a65 100755 --- a/scripts/r3.in.xyz/r3.in.xyz.py +++ b/scripts/r3.in.xyz/r3.in.xyz.py @@ -226,10 +226,7 @@ def main(): addl_opts["flags"] = "i" if scan_only or shell_style: - if shell_style: - doShell = "g" - else: - doShell = "" + doShell = "g" if shell_style else "" grass.run_command( "r.in.xyz", flags="s" + doShell, @@ -243,10 +240,7 @@ def main(): ) sys.exit() - if dtype == "float": - data_type = "FCELL" - else: - data_type = "DCELL" + data_type = "FCELL" if dtype == "float" else "DCELL" region = grass.region(region3d=True) diff --git a/scripts/v.build.all/v.build.all.py b/scripts/v.build.all/v.build.all.py index 69b0837209f..8691ecddc32 100755 --- a/scripts/v.build.all/v.build.all.py +++ b/scripts/v.build.all/v.build.all.py @@ -31,10 +31,7 @@ def main(): vectors = grass.list_grouped("vect")[mapset] num_vectors = len(vectors) - if grass.verbosity() < 2: - quiet = True - else: - quiet = False + quiet = grass.verbosity() < 2 i = 1 for vect in vectors: diff --git a/scripts/v.db.reconnect.all/v.db.reconnect.all.py b/scripts/v.db.reconnect.all/v.db.reconnect.all.py index b42b8006673..9a9d46356a9 100755 --- a/scripts/v.db.reconnect.all/v.db.reconnect.all.py +++ b/scripts/v.db.reconnect.all/v.db.reconnect.all.py @@ -255,10 +255,7 @@ def main(): schema = "" table = schema_table - if new_schema: - new_schema_table = "%s.%s" % (new_schema, table) - else: - new_schema_table = table + new_schema_table = "%s.%s" % (new_schema, table) if new_schema else table gs.debug( "DATABASE = '%s' SCHEMA = '%s' TABLE = '%s' ->\n" diff --git a/scripts/v.dissolve/tests/conftest.py b/scripts/v.dissolve/tests/conftest.py index 9b069330488..e5e9a38818d 100644 --- a/scripts/v.dissolve/tests/conftest.py +++ b/scripts/v.dissolve/tests/conftest.py @@ -13,10 +13,7 @@ def updates_as_transaction(table, cat_column, column, column_quote, cats, values): """Create SQL statement for categories and values for a given column""" sql = ["BEGIN TRANSACTION"] - if column_quote: - quote = "'" - else: - quote = "" + quote = "'" if column_quote else "" for cat, value in zip(cats, values): sql.append( f"UPDATE {table} SET {column} = {quote}{value}{quote} " diff --git a/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py b/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py index 68ca178b864..90dc3de075e 100644 --- a/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py +++ b/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py @@ -101,10 +101,7 @@ def test_aggregate_column_result(dataset, backend): for stats_column in stats_columns: assert stats_column in columns column_info = columns[stats_column] - if stats_column.endswith("_n"): - correct_type = "integer" - else: - correct_type = "double precision" + correct_type = "integer" if stats_column.endswith("_n") else "double precision" assert ( columns[stats_column]["type"].lower() == correct_type ), f"{stats_column} has a wrong type" @@ -221,10 +218,7 @@ def test_sqlite_agg_accepted(dataset): for method, stats_column in zip(stats, expected_stats_columns): assert stats_column in columns column_info = columns[stats_column] - if method == "count": - correct_type = "integer" - else: - correct_type = "double precision" + correct_type = "integer" if method == "count" else "double precision" assert ( columns[stats_column]["type"].lower() == correct_type ), f"{stats_column} has a wrong type" diff --git a/scripts/v.dissolve/tests/v_dissolve_layers_test.py b/scripts/v.dissolve/tests/v_dissolve_layers_test.py index 702aa8f8496..f6986d35917 100644 --- a/scripts/v.dissolve/tests/v_dissolve_layers_test.py +++ b/scripts/v.dissolve/tests/v_dissolve_layers_test.py @@ -50,10 +50,7 @@ def test_layer_2(dataset_layer_2): for method, stats_column in zip(stats, expected_stats_columns): assert stats_column in columns column_info = columns[stats_column] - if method == "count": - correct_type = "integer" - else: - correct_type = "double precision" + correct_type = "integer" if method == "count" else "double precision" assert ( columns[stats_column]["type"].lower() == correct_type ), f"{stats_column} has a wrong type" diff --git a/scripts/v.dissolve/v_dissolve.ipynb b/scripts/v.dissolve/v_dissolve.ipynb index f90907a704d..085b23828d8 100644 --- a/scripts/v.dissolve/v_dissolve.ipynb +++ b/scripts/v.dissolve/v_dissolve.ipynb @@ -19,7 +19,6 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import json\n", "import subprocess\n", "import sys\n", diff --git a/scripts/v.in.e00/v.in.e00.py b/scripts/v.in.e00/v.in.e00.py index 4d63636199f..4258fa3181a 100755 --- a/scripts/v.in.e00/v.in.e00.py +++ b/scripts/v.in.e00/v.in.e00.py @@ -86,10 +86,7 @@ def main(): ) merging = True - if vect: - name = vect - else: - name = e00name + name = vect or e00name # do import diff --git a/scripts/v.in.lines/v.in.lines.py b/scripts/v.in.lines/v.in.lines.py index 44112b297a3..35991988f6b 100755 --- a/scripts/v.in.lines/v.in.lines.py +++ b/scripts/v.in.lines/v.in.lines.py @@ -50,12 +50,7 @@ def main(): fs = separator(options["separator"]) threeD = flags["z"] - - if threeD: - do3D = "z" - else: - do3D = "" - + do3D = "z" if threeD else "" tmp = grass.tempfile() # set up input file diff --git a/scripts/v.in.mapgen/v.in.mapgen.py b/scripts/v.in.mapgen/v.in.mapgen.py index 404fb7ec6b2..efe7af1075d 100755 --- a/scripts/v.in.mapgen/v.in.mapgen.py +++ b/scripts/v.in.mapgen/v.in.mapgen.py @@ -73,18 +73,12 @@ def main(): if not os.path.isfile(infile): grass.fatal(_("Input file <%s> not found") % infile) - if output: - name = output - else: - name = "" + name = output or "" if threeD: matlab = True - if threeD: - do3D = "z" - else: - do3D = "" + do3D = "z" if threeD else "" tmp = grass.tempfile() diff --git a/scripts/v.pack/v.pack.py b/scripts/v.pack/v.pack.py index 4468c888bcb..e39d52dbafe 100755 --- a/scripts/v.pack/v.pack.py +++ b/scripts/v.pack/v.pack.py @@ -73,10 +73,7 @@ def main(): infile = infile.split("@")[0] # output name - if options["output"]: - outfile = options["output"] - else: - outfile = infile + ".pack" + outfile = options["output"] or infile + ".pack" # check if exists the output file if os.path.exists(outfile): diff --git a/scripts/v.rast.stats/v.rast.stats.py b/scripts/v.rast.stats/v.rast.stats.py index 803fc8691ad..4096aa49caf 100644 --- a/scripts/v.rast.stats/v.rast.stats.py +++ b/scripts/v.rast.stats/v.rast.stats.py @@ -116,10 +116,7 @@ def main(): # Get mapset of the vector vs = vector.split("@") - if len(vs) > 1: - vect_mapset = vs[1] - else: - vect_mapset = mapset + vect_mapset = vs[1] if len(vs) > 1 else mapset # does map exist in CURRENT mapset? if vect_mapset != mapset or not gs.find_file(vector, "vector", mapset)["file"]: @@ -373,10 +370,7 @@ def set_up_columns(vector, layer, percentile, colprefix, basecols, dbfdriver, c) perc = b if perc: # namespace is limited in DBF but the % value is important - if dbfdriver: - perccol = "per" + percentile - else: - perccol = "percentile_" + percentile + perccol = "per" + percentile if dbfdriver else "percentile_" + percentile percindex = basecols.index(perc) basecols[percindex] = perccol @@ -424,10 +418,7 @@ def set_up_columns(vector, layer, percentile, colprefix, basecols, dbfdriver, c) + _("Use -c flag to update values in this column.") ) else: - if i == "n": - coltype = "INTEGER" - else: - coltype = "DOUBLE PRECISION" + coltype = "INTEGER" if i == "n" else "DOUBLE PRECISION" addcols.append(currcolumn + " " + coltype) if addcols: diff --git a/scripts/v.report/v.report.py b/scripts/v.report/v.report.py index cec84582155..29d9d3c914e 100755 --- a/scripts/v.report/v.report.py +++ b/scripts/v.report/v.report.py @@ -91,10 +91,7 @@ def main(): isConnection = False colnames = ["cat"] - if option == "coor": - extracolnames = ["x", "y", "z"] - else: - extracolnames = [option] + extracolnames = ["x", "y", "z"] if option == "coor" else [option] if units == "percent": unitsp = "meters" diff --git a/scripts/v.unpack/v.unpack.py b/scripts/v.unpack/v.unpack.py index ea75d443b57..c3a7a55deb7 100644 --- a/scripts/v.unpack/v.unpack.py +++ b/scripts/v.unpack/v.unpack.py @@ -93,10 +93,7 @@ def main(): return 0 # set the output name - if options["output"]: - map_name = options["output"] - else: - map_name = data_name + map_name = options["output"] or data_name # grass env gisenv = grass.gisenv() @@ -233,19 +230,13 @@ def main(): # for each old connection for t in dbnlist: # it split the line of each connection, to found layer number and key - if len(t.split("|")) != 1: - values = t.split("|") - else: - values = t.split(" ") + values = t.split("|") if len(t.split("|")) != 1 else t.split(" ") from_table = values[1] layer = values[0].split("/")[0] # we need to take care about the table name in case of several layer if options["output"]: - if len(dbnlist) > 1: - to_table = "%s_%s" % (map_name, layer) - else: - to_table = map_name + to_table = "%s_%s" % (map_name, layer) if len(dbnlist) > 1 else map_name else: to_table = from_table diff --git a/temporal/t.rast.accumulate/testsuite/test_accumulation.py b/temporal/t.rast.accumulate/testsuite/test_accumulation.py index 566c1971f99..6c277c320cf 100644 --- a/temporal/t.rast.accumulate/testsuite/test_accumulation.py +++ b/temporal/t.rast.accumulate/testsuite/test_accumulation.py @@ -12,7 +12,6 @@ import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestAccumulate(TestCase): diff --git a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py index 924e3950ca8..e7702ba23b5 100644 --- a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py +++ b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py index 2b56dd30615..5ad25e2e32c 100644 --- a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py +++ b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py @@ -11,7 +11,6 @@ import os from datetime import datetime -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py b/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py index 244b0d519d5..dc1da4c1cc3 100644 --- a/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py +++ b/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py b/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py index cf3d12a1aae..f07fabc9106 100644 --- a/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py +++ b/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py @@ -12,7 +12,6 @@ import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule from grass.gunittest.main import test diff --git a/temporal/t.rast.extract/testsuite/test_t_rast_extract.py b/temporal/t.rast.extract/testsuite/test_t_rast_extract.py index ca3c1a4c1db..b9fff4753c2 100644 --- a/temporal/t.rast.extract/testsuite/test_t_rast_extract.py +++ b/temporal/t.rast.extract/testsuite/test_t_rast_extract.py @@ -8,9 +8,6 @@ @author Soeren Gebbert """ -import subprocess - -import grass.pygrass.modules as pymod from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.gapfill/testsuite/test_gapfill.py b/temporal/t.rast.gapfill/testsuite/test_gapfill.py index 7b083617d08..bfc8f48f581 100644 --- a/temporal/t.rast.gapfill/testsuite/test_gapfill.py +++ b/temporal/t.rast.gapfill/testsuite/test_gapfill.py @@ -8,8 +8,6 @@ @author Soeren Gebbert """ -import subprocess - from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule from grass.gunittest.utils import xfail_windows diff --git a/temporal/t.rast.neighbors/testsuite/test_neighbors.py b/temporal/t.rast.neighbors/testsuite/test_neighbors.py index 414b009fb1d..b48df4df169 100644 --- a/temporal/t.rast.neighbors/testsuite/test_neighbors.py +++ b/temporal/t.rast.neighbors/testsuite/test_neighbors.py @@ -5,6 +5,7 @@ """ import os + import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.series/testsuite/test_series.py b/temporal/t.rast.series/testsuite/test_series.py index e936e10e0e7..97df7c048fc 100644 --- a/temporal/t.rast.series/testsuite/test_series.py +++ b/temporal/t.rast.series/testsuite/test_series.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py b/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py index 3a6eb7d45cc..28853ecbff1 100644 --- a/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py +++ b/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py @@ -8,11 +8,7 @@ @author Soeren Gebbert """ -import subprocess - -import grass.pygrass.modules as pymod from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSTRDSToRast3(TestCase): diff --git a/temporal/t.rast.to.vect/testsuite/test_to_vect.py b/temporal/t.rast.to.vect/testsuite/test_to_vect.py index 2217b46a909..b429d8bf0dc 100644 --- a/temporal/t.rast.to.vect/testsuite/test_to_vect.py +++ b/temporal/t.rast.to.vect/testsuite/test_to_vect.py @@ -8,8 +8,6 @@ @author Soeren Gebbert """ -import subprocess - from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.univar/testsuite/test_t_rast_univar.py b/temporal/t.rast.univar/testsuite/test_t_rast_univar.py index 17831b9b5b9..83e5c2d6229 100644 --- a/temporal/t.rast.univar/testsuite/test_t_rast_univar.py +++ b/temporal/t.rast.univar/testsuite/test_t_rast_univar.py @@ -9,6 +9,7 @@ """ from pathlib import Path + from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule from grass.gunittest.utils import xfail_windows diff --git a/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py b/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py index 4f0d476e0e8..3ae010e8423 100644 --- a/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py +++ b/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py @@ -8,9 +8,6 @@ :authors: Soeren Gebbert """ -import subprocess - -import grass.pygrass.modules as pymod from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py b/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py index 4ca64e88442..21980921168 100644 --- a/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py +++ b/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py @@ -9,6 +9,7 @@ """ from pathlib import Path + from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule from grass.gunittest.utils import xfail_windows diff --git a/temporal/t.shift/testsuite/test_shift.py b/temporal/t.shift/testsuite/test_shift.py index ea28e165995..3d55b059b4c 100644 --- a/temporal/t.shift/testsuite/test_shift.py +++ b/temporal/t.shift/testsuite/test_shift.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestShiftAbsoluteSTRDS(TestCase): diff --git a/temporal/t.snap/testsuite/test_snap.py b/temporal/t.snap/testsuite/test_snap.py index 36a71c420bf..e46e25c454d 100644 --- a/temporal/t.snap/testsuite/test_snap.py +++ b/temporal/t.snap/testsuite/test_snap.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSnapAbsoluteSTRDS(TestCase): diff --git a/temporal/t.support/testsuite/test_support_str3ds.py b/temporal/t.support/testsuite/test_support_str3ds.py index 928826dbd72..533a9649692 100644 --- a/temporal/t.support/testsuite/test_support_str3ds.py +++ b/temporal/t.support/testsuite/test_support_str3ds.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSupportAbsoluteSTR3DS(TestCase): diff --git a/temporal/t.support/testsuite/test_support_strds.py b/temporal/t.support/testsuite/test_support_strds.py index f5e9ac3aa29..397a4a5e88d 100644 --- a/temporal/t.support/testsuite/test_support_strds.py +++ b/temporal/t.support/testsuite/test_support_strds.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSupportAbsoluteSTRDS(TestCase): diff --git a/temporal/t.support/testsuite/test_support_stvds.py b/temporal/t.support/testsuite/test_support_stvds.py index 2b6e347dead..b7ecc1aee01 100644 --- a/temporal/t.support/testsuite/test_support_stvds.py +++ b/temporal/t.support/testsuite/test_support_stvds.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSupportAbsoluteSTVDS(TestCase): diff --git a/temporal/t.unregister/testsuite/test_unregister.py b/temporal/t.unregister/testsuite/test_unregister.py index a32d33c1f32..b0102095e3d 100644 --- a/temporal/t.unregister/testsuite/test_unregister.py +++ b/temporal/t.unregister/testsuite/test_unregister.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/vector/v.external/dsn.c b/vector/v.external/dsn.c index 1a0d6bc2a57..c56009a64e2 100644 --- a/vector/v.external/dsn.c +++ b/vector/v.external/dsn.c @@ -31,7 +31,7 @@ char *get_datasource_name(const char *opt_dsn, int use_ogr) /* add db.login settings (user, password, host, port) */ if (DB_OK == - db_get_login2("pg", database, &user, &passwd, &host, &port)) { + db_get_login("pg", database, &user, &passwd, &host, &port)) { if (user) { if (!G_strcasestr(opt_dsn, "user=")) { strcat(connect_str, " user="); diff --git a/vector/v.extract/testsuite/test_v_extract.py b/vector/v.extract/testsuite/test_v_extract.py index 958f153d1a3..c46505a5527 100644 --- a/vector/v.extract/testsuite/test_v_extract.py +++ b/vector/v.extract/testsuite/test_v_extract.py @@ -11,7 +11,6 @@ import os from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule from grass.script.core import read_command TABLE_1 = """cat|MAJORRDS_|ROAD_NAME|MULTILANE|PROPYEAR|OBJECTID|SHAPE_LEN diff --git a/vector/v.fill.holes/examples.ipynb b/vector/v.fill.holes/examples.ipynb index fcc006501e4..a6b3ea746ce 100644 --- a/vector/v.fill.holes/examples.ipynb +++ b/vector/v.fill.holes/examples.ipynb @@ -15,12 +15,10 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import sys\n", "\n", "from IPython.display import Image\n", "\n", - "import grass.script as gs\n", "import grass.jupyter as gj" ] }, diff --git a/vector/v.in.ogr/dsn.c b/vector/v.in.ogr/dsn.c index 2fecff7e9fb..7e483e71050 100644 --- a/vector/v.in.ogr/dsn.c +++ b/vector/v.in.ogr/dsn.c @@ -38,7 +38,7 @@ char *get_datasource_name(const char *opt_dsn, int use_ogr) /* add db.login settings (user, password, host, port) */ if (DB_OK == - db_get_login2("pg", database, &user, &passwd, &host, &port)) { + db_get_login("pg", database, &user, &passwd, &host, &port)) { if (user) { if (!G_strcasestr(opt_dsn, "user=")) { strcat(connect_str, " user="); diff --git a/vector/v.in.ogr/testsuite/test_v_in_ogr.py b/vector/v.in.ogr/testsuite/test_v_in_ogr.py index 167cd8747e8..31d2ef7ef3b 100644 --- a/vector/v.in.ogr/testsuite/test_v_in_ogr.py +++ b/vector/v.in.ogr/testsuite/test_v_in_ogr.py @@ -4,7 +4,6 @@ """ from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestOgrImport(TestCase): diff --git a/vector/v.out.ogr/dsn.c b/vector/v.out.ogr/dsn.c index 31d258c05c7..bd7ce101ed2 100644 --- a/vector/v.out.ogr/dsn.c +++ b/vector/v.out.ogr/dsn.c @@ -37,7 +37,7 @@ char *get_datasource_name(const char *opt_dsn, int use_ogr) /* add db.login settings (user, password, host, port) */ if (DB_OK == - db_get_login2("pg", database, &user, &passwd, &host, &port)) { + db_get_login("pg", database, &user, &passwd, &host, &port)) { if (user) { if (!G_strcasestr(opt_dsn, "user=")) { strcat(connect_str, " user=");