accessmod/grasshelper.py
def check_mapset(gisdb_path, location_name, mapset_name):
    """Create a GRASS mapset if necessary."""
    # Check if PERMANENT mapset exists
    permanent_path = os.path.join(gisdb_path, location_name, "PERMANENT")
    if os.path.exists(permanent_path):
        # The `WIND` file is required too
        wind_path = os.path.join(permanent_path, "WIND")
        if not os.path.exists(wind_path):
            logger.error("PERMANENT mapset already exists, but a WIND file is missing.")
        else:
            mapset_path = os.path.join(gisdb_path, location_name, mapset_name)
            if not os.path.exists(mapset_path):
                os.makedirs(mapset_path)
                shutil.copy(wind_path, os.path.join(mapset_path, "WIND"))
                logger.info(f"'{mapset_name}' created in location '{location_name}'.")
            else:
                logger.info(f"'{mapset_name}' mapset already exists.")
    else:
        logger.error("'PERMANENT' mapset does not exist.")
Create a GRASS mapset if necessary.
Create a GRASS mapset if necessary.
Create a GRASS mapset if necessary .
def check_mapset(gisdb_path, location_name, mapset_name):
    permanent_path = os.path.join(gisdb_path, location_name, "PERMANENT")
    if os.path.exists(permanent_path):
        wind_path = os.path.join(permanent_path, "WIND")
        if not os.path.exists(wind_path):
            logger.error("PERMANENT mapset already exists, but a WIND file is missing.")
        else:
            mapset_path = os.path.join(gisdb_path, location_name, mapset_name)
            if not os.path.exists(mapset_path):
                os.makedirs(mapset_path)
                shutil.copy(wind_path, os.path.join(mapset_path, "WIND"))
                logger.info(f"'{mapset_name}' created in location '{location_name}'.")
            else:
                logger.info(f"'{mapset_name}' mapset already exists.")
    else:
        logger.error("'PERMANENT' mapset does not exist.")
def check_mapset ( gisdb_path , location_name , mapset_name ) : permanent_path = os . path . join ( gisdb_path , location_name , "PERMANENT" ) if os . path . exists ( permanent_path ) : wind_path = os . path . join ( permanent_path , "WIND" ) if not os . path . exists ( wind_path ) : logger . error ( "PERMANENT mapset already exists, but a WIND file is missing." ) else : mapset_path = os . path . join ( gisdb_path , location_name , mapset_name ) if not os . path . exists ( mapset_path ) : os . makedirs ( mapset_path ) shutil . copy ( wind_path , os . path . join ( mapset_path , "WIND" ) ) logger . info ( f"'{mapset_name}' created in location '{location_name}'." ) else : logger . info ( f"'{mapset_name}' mapset already exists." ) else : logger . error ( "'PERMANENT' mapset does not exist." )
Create a GRASS mapset if necessary.
Create a GRASS mapset if necessary .
"""Create a GRASS mapset if necessary.""" # Check if PERMANENT mapset exists # The `WIND` file is required too
gisdb_path
location_name
mapset_name