[GRASS-dev] move everything from /lib/init/grass.py to /lib/python/init

Pietro peter.zamb at gmail.com
Sun Jul 16 21:36:50 PDT 2017


Hi Vaclav,

On Fri, Jul 14, 2017 at 6:00 PM, Vaclav Petras <wenzeslaus at gmail.com> wrote:

> This is exactly what I had in my mind when doing the last major changes in
> the grass.py file.
>
I generally like the layout you suggested. It seems to me that choosing a
> good name for the whole module will be a bit tricky.
>

This is intended as a proof of concept to see the feasibility.
I've try to found a better name but didn't come up to my mind...
Perhaps: session instead of init?

My final objective is to be able to do something like:

```python
import os
import sys

*# Perhaps in GRASS8 we will be able to skip this! ;-)*
sys.append(os.environ.get('GISBASE', '/home/pietro/my/gisbase'))

from grass.init import Session

# open - close mode
session = Session('mygisdbase/location/mapset')
session.open()
# do my stuff here...
session.close()

# with statement
with Session('mygisdbase/location/mapset') as session:
    # do my stuff here
```


Also I think one reason for having them there was that grass.py works
> without a the G Python lib found.
>

ok, but I don't see any advantage to have grass.py that works without
loading the grass python libraries. and with the current status we have
code duplication, that mean more code to read, test and maintain.
If you are afraid that the grass python libraries might be broken and
therefore the user can have troubles, they will have troubles in any case
(no gui, several important modules missing). So I will consider stopping
the user earlier.as a feature.

Let me know.

Pietro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20170717/d0197831/attachment.html>


More information about the grass-dev mailing list