[GRASS-git] [OSGeo/grass] 05380b: grass.script: Make setup available without another...

Vaclav Petras noreply at github.com
Tue Jul 26 08:15:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 05380bcc00440c3e7ac94931ff8f0756d5230d3d
      https://github.com/OSGeo/grass/commit/05380bcc00440c3e7ac94931ff8f0756d5230d3d
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2022-07-26 (Tue, 26 Jul 2022)

  Changed paths:
    M doc/notebooks/scripting_example.ipynb
    M lib/gis/tests/lib_gis_env_test.py
    M lib/init/grass.html
    M python/grass/gunittest/invoker.py
    M python/grass/gunittest/multirunner.py
    M python/grass/jupyter/setup.py
    M python/grass/jupyter/tests/conftest.py
    M python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py
    M python/grass/script/__init__.py
    M python/grass/script/setup.py
    M python/grass/script/tests/grass_script_setup_test.py
    M scripts/v.db.univar/tests/conftest.py
    M temporal/t.rast.list/tests/conftest.py

  Log Message:
  -----------
  grass.script: Make setup available without another import (#2451)

import grass.script.setup or similar was needed to get access to functions in the setup module. Now the module is imported in the init file which makes it available without an additional import in user code. gs.setup.init() is now an easy and clear way of getting access to the init function.

Most of the code using grass.script.setup was modified to the new style (except for grass.py and imports of specific functions).

Documentation related to the session returned from gs.setup.init updated as gs.setup.finish() call is not even needed when easier session.finish() call is used instead. (Using session.finish() leaves gs.setup.init() call to be the only one from setup for typical session handling code, so the previously required separate import would be for one call only; now there is no import except for grass.script.)

Alternatives to this implementation would be to import all functions (which would bring many symbols to grass.script) or importing specific functions (e.g., init only), but importing setup makes it most clear (all are available) while keeping them separate under setup. (There are other setup or session related functions in grass.script.core already available after importing grass.script, so there is still some confusion related to that. However, rather than mixing all together, it seems that these need to be separated from core or organized better in some other way.)




More information about the grass-commit mailing list