[GRASS-git] [OSGeo/grass] 4daf10: pygrass: Add update parameters method to Module (#...

Vaclav Petras noreply at github.com
Mon Jul 12 21:00:20 PDT 2021


  Branch: refs/heads/master
  Home:   https://github.com/OSGeo/grass
  Commit: 4daf1023e049b05693a94612a88e0eda26e89047
      https://github.com/OSGeo/grass/commit/4daf1023e049b05693a94612a88e0eda26e89047
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2021-07-13 (Tue, 13 Jul 2021)

  Changed paths:
    M python/grass/benchmark/runners.py
    M python/grass/pygrass/modules/interface/module.py

  Log Message:
  -----------
  pygrass: Add update parameters method to Module (#1712)

This adds a new update method which can update the parameters (and generally attributes) of the Module.
The current practice is to use the function call operator to do the update. This seems to go against
the function call operator semantics as the module is not executed unless explicit `run_=True` is passed.
It is also inconsistent with using the function call operator without parameters which runs the module unconditionally.

This PR is not changing the current behavior, but it adds a better way of expressing the same idea. The modification of parameters can now be done using a method called _update_. The name _update_ is based on update function in Python dict since this seems to be a similar case.

The change in doctest and in _grass.benchmark_ (original motivation for this change) shows how the new usage looks like. _grass.benchmark_ update of documentation shows also how clear is the interface with update compared to the very specific original interface, i.e., it is easier to create another class which will behave same way as Module in this context.




More information about the grass-commit mailing list