コード例 #1
0
def create_mapset_interactively(guiparent, grassdb, location):
    """
    Create new mapset
    """
    dlg = MapsetDialog(
        parent=guiparent,
        default=get_default_mapset_name(),
        message=_("Name for the new mapset:"),
        caption=_("Create new mapset"),
        database=grassdb,
        location=location,
    )

    mapset = None
    if dlg.ShowModal() == wx.ID_OK:
        mapset = dlg.GetValue()
        try:
            create_mapset(grassdb, location, mapset)
        except OSError as err:
            mapset = None
            GError(
                parent=guiparent,
                message=_("Unable to create new mapset: {}").format(err),
                showTraceback=False,
            )
    dlg.Destroy()
    return mapset
コード例 #2
0
def _create_startup_mapset(location_path):
    """Create the new empty startup mapset named after user.

    Returns new mapset name if successfully created or None when
    an error was encountered.
    """
    mapset_name = default_name = get_default_mapset_name()
    mapset_path = os.path.join(location_path, mapset_name)

    # Create new startup mapset
    try:
        grassdatabase, location = os.path.split(location_path)
        create_mapset(grassdatabase, location, mapset_name)
        return mapset_name
    except (IOError, OSError):
        pass
    return None