GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gui_modules.utils Namespace Reference

Functions

def normalize_whitespace
 Remove redundant whitespace from a string.
def split
 Platform spefic shlex.split.
def GetTempfile
 Creates GRASS temporary file using defined prefix.
def GetLayerNameFromCmd
 Get map name from GRASS command.
def GetValidLayerName
 Make layer name SQL compliant, based on G_str_to_sql()
def ListOfCatsToRange
 Convert list of category number to range(s)
def ListOfMapsets
 Get list of available/accessible mapsets.
def ListSortLower
 Sort list items (not case-sensitive)
def GetVectorNumberOfLayers
 Get list of vector layers.
def Deg2DMS
 Convert deg value to dms string.
def DMS2Deg
 Convert dms value to deg.
def GetCmdString
def CmdToTuple
 Convert command list to tuple for gcmd.RunCommand()
def PathJoin
 Check path created by os.path.join.
def ReadEpsgCodes
 Read EPSG code from the file.
def ReprojectCoordinates
 Reproject coordinates.
def GetListOfLocations
 Get list of GRASS locations in given dbase.
def GetListOfMapsets
 Get list of mapsets in given GRASS location.
def GetColorTables
 Get list of color tables.
def DecodeString
 Decode string using system encoding.
def EncodeString
 Return encoded string using system locales.
def UnicodeString
 Return unicode string.
def GetFormats
 Get GDAL/OGR formats.
def GetSettingsPath
 Get full path to the settings directory.

Variables

 formats = None

Function Documentation

def gui_modules.utils.CmdToTuple (   cmd)

Convert command list to tuple for gcmd.RunCommand()

Definition at line 482 of file utils.py.

Referenced by gui_modules.psmap_dialogs.Instruction.SetRegion().

def gui_modules.utils.DecodeString (   string)

Decode string using system encoding.

Parameters
stringstring to be decoded
Returns
decoded string

Definition at line 657 of file utils.py.

def gui_modules.utils.Deg2DMS (   lon,
  lat,
  string = True,
  hemisphere = True,
  precision = 3 
)

Convert deg value to dms string.

Parameters
lonlongitude (x)
latlatitude (y)
stringTrue to return string otherwise tuple
hemisphereprint hemisphere
precisionseconds precision
Returns
DMS string or tuple of values
empty string on error

Definition at line 322 of file utils.py.

def gui_modules.utils.DMS2Deg (   lon,
  lat 
)

Convert dms value to deg.

Parameters
lonlongitude (x)
latlatitude (y)
Returns
tuple of converted values
ValueError on error

Definition at line 376 of file utils.py.

def gui_modules.utils.EncodeString (   string)

Return encoded string using system locales.

Parameters
stringstring to be encoded
Returns
encoded string

Definition at line 674 of file utils.py.

def gui_modules.utils.GetCmdString (   cmd)
Get GRASS command as string.

@param cmd GRASS command given as dictionary

@return command string

Definition at line 454 of file utils.py.

Referenced by gui_modules.psmap_dialogs.Instruction.SetRegion().

def gui_modules.utils.GetColorTables ( )

Get list of color tables.

Definition at line 647 of file utils.py.

def gui_modules.utils.GetFormats ( )

Get GDAL/OGR formats.

Definition at line 756 of file utils.py.

def gui_modules.utils.GetLayerNameFromCmd (   dcmd,
  fullyQualified = False,
  param = None,
  layerType = None 
)

Get map name from GRASS command.

Parameter dcmd can be modified when first parameter is not defined.

Parameters
dcmdGRASS command (given as list)
fullyQualifiedchange map name to be fully qualified
paramparams directory
layerTypecheck also layer type ('raster', 'vector', '3d-raster', ...)
Returns
tuple (name, found)

Definition at line 76 of file utils.py.

References gui_modules.utils.split().

Referenced by gui_modules.utils.GetTempfile().

def gui_modules.utils.GetListOfLocations (   dbase)

Get list of GRASS locations in given dbase.

Parameters
dbaseGRASS database path
Returns
list of locations (sorted)

Definition at line 592 of file utils.py.

References gui_modules.utils.ListSortLower().

def gui_modules.utils.GetListOfMapsets (   dbase,
  location,
  selectable = False 
)

Get list of mapsets in given GRASS location.

Parameters
dbaseGRASS database path
locationGRASS location
selectableTrue to get list of selectable mapsets, otherwise all
Returns
list of mapsets - sorted (PERMANENT first)

Definition at line 615 of file utils.py.

References gui_modules.utils.ListSortLower().

def gui_modules.utils.GetSettingsPath ( )

Get full path to the settings directory.

Definition at line 767 of file utils.py.

References gui_modules.utils.split().

def gui_modules.utils.GetTempfile (   pref = None)

Creates GRASS temporary file using defined prefix.

Todo:
Fix path on MS Windows/MSYS
Parameters
prefprefer the given path
Returns
Path to file name (string) or None

Definition at line 45 of file utils.py.

References gui_modules.utils.GetLayerNameFromCmd().

def gui_modules.utils.GetValidLayerName (   name)

Make layer name SQL compliant, based on G_str_to_sql()

Todo:
: Better use directly GRASS Python SWIG...

Definition at line 165 of file utils.py.

def gui_modules.utils.GetVectorNumberOfLayers (   vector,
  parent = None 
)

Get list of vector layers.

Parameters
vectorname of vector map
parentparent window (to show dialog) or None

Definition at line 281 of file utils.py.

def gui_modules.utils.ListOfCatsToRange (   cats)

Convert list of category number to range(s)

Used for example for d.vect cats=[range]

Parameters
catscategory list
Returns
category range string
'' on error

Definition at line 197 of file utils.py.

References gui_modules.render.map.

Referenced by gui_modules.mapdisp_vdigit.VDigitWindow.OnLeftUpCopyLine().

def gui_modules.utils.ListOfMapsets (   get = 'ordered')

Get list of available/accessible mapsets.

Parameters
getmethod ('all', 'accessible', 'ordered')
Returns
list of mapsets
None on error

Definition at line 235 of file utils.py.

References gui_modules.utils.ListSortLower(), and gui_modules.utils.split().

def gui_modules.utils.ListSortLower (   list)

Sort list items (not case-sensitive)

Definition at line 277 of file utils.py.

Referenced by gui_modules.utils.GetListOfLocations(), gui_modules.utils.GetListOfMapsets(), and gui_modules.utils.ListOfMapsets().

def gui_modules.utils.normalize_whitespace (   text)

Remove redundant whitespace from a string.

Definition at line 32 of file utils.py.

def gui_modules.utils.PathJoin (   args)

Check path created by os.path.join.

Definition at line 504 of file utils.py.

def gui_modules.utils.ReadEpsgCodes (   path)

Read EPSG code from the file.

Parameters
pathfull path to the file with EPSG codes
Returns
dictionary of EPSG code
string on error

Definition at line 513 of file utils.py.

def gui_modules.utils.ReprojectCoordinates (   coord,
  projOut,
  projIn = None,
  flags = '' 
)

Reproject coordinates.

Parameters
coordcoordinates given as tuple
projOutoutput projection
projIninput projection (use location projection settings)
Returns
reprojected coordinates (returned as tuple)

Definition at line 555 of file utils.py.

References gui_modules.utils.split().

def gui_modules.utils.split (   s)

Platform spefic shlex.split.

Definition at line 36 of file utils.py.

Referenced by gui_modules.gcmd.GError.__init__(), gui_modules.ghelp.AboutWindow.__init__(), gui_modules.psmap_dialogs.Text.__str__(), gui_modules.layertree.LayerTree.ChangeLayer(), g.check_dirs(), gui_modules.globalvar.CheckForWx(), gui_modules.globalvar.CheckWxVersion(), gui_modules.render.Map.Clean(), gui_modules.psmap.DialogDataChanged(), gui_modules.psmap_dialogs.RasterLegend.EstimateHeight(), gui_modules.psmap_dialogs.PageSetupDialog.getCtrl(), gui_modules.psmap.getFile(), gui_modules.globalvar.GetGRASSCmds(), gui_modules.utils.GetLayerNameFromCmd(), gui_modules.psmap_dialogs.GetMapBounds(), gui_modules.gcpmanager.GCP.GetNewExtent(), gui_modules.utils.GetSettingsPath(), g.install_extension_other(), g.install_extension_win(), g.install_extension_xml(), g.list_available_extensions(), gui_modules.utils.ListOfMapsets(), gui_modules.psmap.makePSFont(), gui_modules.dbm.AttributeManager.OnDataItemDeleteAll(), gui_modules.prompt.TextCtrlAutoComplete.OnEnteredText(), gui_modules.mapdisp.MapFrame.OnGoTo(), gui_modules.prompt.GPromptSTC.OnItemSelected(), gui_modules.gselect.TreeCtrlComboPopup.OnKeyUp(), gui_modules.gselect.TreeCtrlComboPopup.OnLeftDown(), gui_modules.ghelp.MenuTreeWindow.OnRun(), vkrige.KrigingPanel.OnRunButton(), gui_modules.ghelp.SearchModuleWindow.OnSelectModule(), gui_modules.gdialogs.DxfImportDialog.OnSetDsn(), gui_modules.gselect.GdalSelect.OnSetDsn(), gui_modules.gselect.GdalSelect.OnSettingsSave(), gui_modules.menudata.MenuData.PrintStrings(), gui_modules.psmap_dialogs.MapFrame.Read(), gui_modules.psmap_dialogs.Mapinfo.Read(), gui_modules.psmap_dialogs.VProperties.Read(), gui_modules.psmap.PsMapBufferedWindow.RecalculatePosition(), gui_modules.utils.ReprojectCoordinates(), gui_modules.gcpmanager.GCP.RMSError(), gui_modules.goutput.CmdThread.run(), gui_modules.profile.ProfileFrame.SetRaster(), gui_modules.psmap_dialogs.Instruction.SetRegion(), gui_modules.psmap_dialogs.MapFramePanel.update(), update_menudata.updateData(), gui_modules.psmap.UpdateMapLabel(), gui_modules.nviz_tools.NvizToolWindow.UpdateVectorPage(), python.vector.vector_db(), python.vector.vector_db_select(), and g.write_xml_modules().

def gui_modules.utils.UnicodeString (   string)

Return unicode string.

Parameters
stringstring to be converted
Returns
unicode string

Definition at line 690 of file utils.py.

Variable Documentation

gui_modules.utils.formats = None

Definition at line 754 of file utils.py.