repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.hide_busy
def hide_busy(self, check_next_impact=True): """A helper function to indicate processing is done. :param check_next_impact: Flag to check if we can validate the next IF. :type check_next_impact: bool """ self.progress_bar.hide() self.show_question_button.setVisible(True)...
python
def hide_busy(self, check_next_impact=True): """A helper function to indicate processing is done. :param check_next_impact: Flag to check if we can validate the next IF. :type check_next_impact: bool """ self.progress_bar.hide() self.show_question_button.setVisible(True)...
[ "def", "hide_busy", "(", "self", ",", "check_next_impact", "=", "True", ")", ":", "self", ".", "progress_bar", ".", "hide", "(", ")", "self", ".", "show_question_button", ".", "setVisible", "(", "True", ")", "self", ".", "question_group", ".", "setEnabled", ...
A helper function to indicate processing is done. :param check_next_impact: Flag to check if we can validate the next IF. :type check_next_impact: bool
[ "A", "helper", "function", "to", "indicate", "processing", "is", "done", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L882-L899
train
27,100
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.show_impact
def show_impact(self, report_path): """Show the report. .. versionadded: 4.0 :param report_path: The path to the report. :type report_path: basestring """ # We can display an impact report. # We need to open the file in UTF-8, the HTML may have some accents ...
python
def show_impact(self, report_path): """Show the report. .. versionadded: 4.0 :param report_path: The path to the report. :type report_path: basestring """ # We can display an impact report. # We need to open the file in UTF-8, the HTML may have some accents ...
[ "def", "show_impact", "(", "self", ",", "report_path", ")", ":", "# We can display an impact report.", "# We need to open the file in UTF-8, the HTML may have some accents", "with", "codecs", ".", "open", "(", "report_path", ",", "'r'", ",", "'utf-8'", ")", "as", "report_...
Show the report. .. versionadded: 4.0 :param report_path: The path to the report. :type report_path: basestring
[ "Show", "the", "report", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L901-L920
train
27,101
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.show_generic_keywords
def show_generic_keywords(self, layer): """Show the keywords defined for the active layer. .. note:: The print button will be disabled if this method is called. .. versionchanged:: 3.3 - changed parameter from keywords object to a layer object so that we can show extra stuff like C...
python
def show_generic_keywords(self, layer): """Show the keywords defined for the active layer. .. note:: The print button will be disabled if this method is called. .. versionchanged:: 3.3 - changed parameter from keywords object to a layer object so that we can show extra stuff like C...
[ "def", "show_generic_keywords", "(", "self", ",", "layer", ")", ":", "keywords", "=", "KeywordIO", "(", "layer", ")", "self", ".", "print_button", ".", "setEnabled", "(", "False", ")", "try", ":", "message", "=", "keywords", ".", "to_message", "(", ")", ...
Show the keywords defined for the active layer. .. note:: The print button will be disabled if this method is called. .. versionchanged:: 3.3 - changed parameter from keywords object to a layer object so that we can show extra stuff like CRS and data source in the keywords. ...
[ "Show", "the", "keywords", "defined", "for", "the", "active", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L922-L944
train
27,102
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.layer_changed
def layer_changed(self, layer): """Handler for when the QGIS active layer is changed. If the active layer is changed and it has keywords and a report, show the report. :param layer: QgsMapLayer instance that is now active. :type layer: QgsMapLayer, QgsRasterLayer, QgsVectorLaye...
python
def layer_changed(self, layer): """Handler for when the QGIS active layer is changed. If the active layer is changed and it has keywords and a report, show the report. :param layer: QgsMapLayer instance that is now active. :type layer: QgsMapLayer, QgsRasterLayer, QgsVectorLaye...
[ "def", "layer_changed", "(", "self", ",", "layer", ")", ":", "# Don't handle this event if we are already handling another layer", "# addition or removal event.", "if", "self", ".", "get_layers_lock", "or", "layer", "is", "None", ":", "return", "# Do nothing if there is no ac...
Handler for when the QGIS active layer is changed. If the active layer is changed and it has keywords and a report, show the report. :param layer: QgsMapLayer instance that is now active. :type layer: QgsMapLayer, QgsRasterLayer, QgsVectorLayer
[ "Handler", "for", "when", "the", "QGIS", "active", "layer", "is", "changed", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L947-L1068
train
27,103
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.save_state
def save_state(self): """Save the current state of the ui to an internal class member. The saved state can be restored again easily using :func:`restore_state` """ state = { 'hazard': self.hazard_layer_combo.currentText(), 'exposure': self.exposure_layer_...
python
def save_state(self): """Save the current state of the ui to an internal class member. The saved state can be restored again easily using :func:`restore_state` """ state = { 'hazard': self.hazard_layer_combo.currentText(), 'exposure': self.exposure_layer_...
[ "def", "save_state", "(", "self", ")", ":", "state", "=", "{", "'hazard'", ":", "self", ".", "hazard_layer_combo", ".", "currentText", "(", ")", ",", "'exposure'", ":", "self", ".", "exposure_layer_combo", ".", "currentText", "(", ")", ",", "'aggregation'", ...
Save the current state of the ui to an internal class member. The saved state can be restored again easily using :func:`restore_state`
[ "Save", "the", "current", "state", "of", "the", "ui", "to", "an", "internal", "class", "member", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L1070-L1081
train
27,104
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.restore_state
def restore_state(self): """Restore the state of the dock to the last known state.""" if self.state is None: return for myCount in range(0, self.exposure_layer_combo.count()): item_text = self.exposure_layer_combo.itemText(myCount) if item_text == self.state['...
python
def restore_state(self): """Restore the state of the dock to the last known state.""" if self.state is None: return for myCount in range(0, self.exposure_layer_combo.count()): item_text = self.exposure_layer_combo.itemText(myCount) if item_text == self.state['...
[ "def", "restore_state", "(", "self", ")", ":", "if", "self", ".", "state", "is", "None", ":", "return", "for", "myCount", "in", "range", "(", "0", ",", "self", ".", "exposure_layer_combo", ".", "count", "(", ")", ")", ":", "item_text", "=", "self", "...
Restore the state of the dock to the last known state.
[ "Restore", "the", "state", "of", "the", "dock", "to", "the", "last", "known", "state", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L1083-L1102
train
27,105
inasafe/inasafe
safe/gui/widgets/dock.py
Dock.define_user_analysis_extent
def define_user_analysis_extent(self, extent, crs): """Slot called when user has defined a custom analysis extent. .. versionadded: 2.2.0 :param extent: Extent of the user's preferred analysis area. :type extent: QgsRectangle :param crs: Coordinate reference system for user de...
python
def define_user_analysis_extent(self, extent, crs): """Slot called when user has defined a custom analysis extent. .. versionadded: 2.2.0 :param extent: Extent of the user's preferred analysis area. :type extent: QgsRectangle :param crs: Coordinate reference system for user de...
[ "def", "define_user_analysis_extent", "(", "self", ",", "extent", ",", "crs", ")", ":", "extent", "=", "QgsGeometry", ".", "fromRect", "(", "extent", ")", "self", ".", "extent", ".", "set_user_extent", "(", "extent", ",", "crs", ")", "self", ".", "validate...
Slot called when user has defined a custom analysis extent. .. versionadded: 2.2.0 :param extent: Extent of the user's preferred analysis area. :type extent: QgsRectangle :param crs: Coordinate reference system for user defined analysis extent. :type crs: QgsCoordi...
[ "Slot", "called", "when", "user", "has", "defined", "a", "custom", "analysis", "extent", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L1227-L1241
train
27,106
inasafe/inasafe
safe/gui/widgets/dock.py
Dock._search_inasafe_layer
def _search_inasafe_layer(self): """Search for an inasafe layer in an active group. :returns: A valid layer. :rtype: QgsMapLayer .. versionadded:: 4.3 """ selected_nodes = self.iface.layerTreeView().selectedNodes() for selected_node in selected_nodes: ...
python
def _search_inasafe_layer(self): """Search for an inasafe layer in an active group. :returns: A valid layer. :rtype: QgsMapLayer .. versionadded:: 4.3 """ selected_nodes = self.iface.layerTreeView().selectedNodes() for selected_node in selected_nodes: ...
[ "def", "_search_inasafe_layer", "(", "self", ")", ":", "selected_nodes", "=", "self", ".", "iface", ".", "layerTreeView", "(", ")", ".", "selectedNodes", "(", ")", "for", "selected_node", "in", "selected_nodes", ":", "tree_layers", "=", "[", "child", "for", ...
Search for an inasafe layer in an active group. :returns: A valid layer. :rtype: QgsMapLayer .. versionadded:: 4.3
[ "Search", "for", "an", "inasafe", "layer", "in", "an", "active", "group", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L1265-L1282
train
27,107
inasafe/inasafe
safe/gui/widgets/dock.py
Dock._visible_layers_count
def _visible_layers_count(self): """Calculate the number of visible layers in the legend. .. versionadded: 3.1 :returns: Count of layers that are actually visible. :rtype: int """ treeroot = QgsProject.instance().layerTreeRoot() return len([lyr for lyr in treero...
python
def _visible_layers_count(self): """Calculate the number of visible layers in the legend. .. versionadded: 3.1 :returns: Count of layers that are actually visible. :rtype: int """ treeroot = QgsProject.instance().layerTreeRoot() return len([lyr for lyr in treero...
[ "def", "_visible_layers_count", "(", "self", ")", ":", "treeroot", "=", "QgsProject", ".", "instance", "(", ")", ".", "layerTreeRoot", "(", ")", "return", "len", "(", "[", "lyr", "for", "lyr", "in", "treeroot", ".", "findLayers", "(", ")", "if", "lyr", ...
Calculate the number of visible layers in the legend. .. versionadded: 3.1 :returns: Count of layers that are actually visible. :rtype: int
[ "Calculate", "the", "number", "of", "visible", "layers", "in", "the", "legend", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L1296-L1305
train
27,108
inasafe/inasafe
safe/gui/widgets/dock.py
Dock._validate_question_area
def _validate_question_area(self): """Helper method to evaluate the current state of the dialog. This function will determine if it is appropriate for the OK button to be enabled or not. .. note:: The enabled state of the OK button on the dialog will NOT be updated (set True...
python
def _validate_question_area(self): """Helper method to evaluate the current state of the dialog. This function will determine if it is appropriate for the OK button to be enabled or not. .. note:: The enabled state of the OK button on the dialog will NOT be updated (set True...
[ "def", "_validate_question_area", "(", "self", ")", ":", "hazard_index", "=", "self", ".", "hazard_layer_combo", ".", "currentIndex", "(", ")", "exposure_index", "=", "self", ".", "exposure_layer_combo", ".", "currentIndex", "(", ")", "if", "hazard_index", "==", ...
Helper method to evaluate the current state of the dialog. This function will determine if it is appropriate for the OK button to be enabled or not. .. note:: The enabled state of the OK button on the dialog will NOT be updated (set True or False) depending on the outcome of ...
[ "Helper", "method", "to", "evaluate", "the", "current", "state", "of", "the", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/dock.py#L1564-L1593
train
27,109
inasafe/inasafe
safe/common/parameters/default_select_parameter.py
DefaultSelectParameter.default_value
def default_value(self, default_value): """Setter for default_value. :param default_value: The default value. :type default_value: object """ # For custom value if default_value not in self.default_values: if len(self.default_labels) == len(self.default_value...
python
def default_value(self, default_value): """Setter for default_value. :param default_value: The default value. :type default_value: object """ # For custom value if default_value not in self.default_values: if len(self.default_labels) == len(self.default_value...
[ "def", "default_value", "(", "self", ",", "default_value", ")", ":", "# For custom value", "if", "default_value", "not", "in", "self", ".", "default_values", ":", "if", "len", "(", "self", ".", "default_labels", ")", "==", "len", "(", "self", ".", "default_v...
Setter for default_value. :param default_value: The default value. :type default_value: object
[ "Setter", "for", "default_value", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_select_parameter.py#L101-L114
train
27,110
inasafe/inasafe
__init__.py
classFactory
def classFactory(iface): """Load Plugin class from file Plugin.""" # Try to import submodule to check if there are present. try: from parameters.generic_parameter import GenericParameter except ImportError: # Don't use safe.utilities.i18n.tr as we need to be outside of `safe`. # ...
python
def classFactory(iface): """Load Plugin class from file Plugin.""" # Try to import submodule to check if there are present. try: from parameters.generic_parameter import GenericParameter except ImportError: # Don't use safe.utilities.i18n.tr as we need to be outside of `safe`. # ...
[ "def", "classFactory", "(", "iface", ")", ":", "# Try to import submodule to check if there are present.", "try", ":", "from", "parameters", ".", "generic_parameter", "import", "GenericParameter", "except", "ImportError", ":", "# Don't use safe.utilities.i18n.tr as we need to be ...
Load Plugin class from file Plugin.
[ "Load", "Plugin", "class", "from", "file", "Plugin", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/__init__.py#L68-L90
train
27,111
inasafe/inasafe
safe/gui/tools/help/metadata_converter_help.py
metadata_converter_help
def metadata_converter_help(): """Help message for metadata converter Dialog. .. versionadded:: 4.3 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(conte...
python
def metadata_converter_help(): """Help message for metadata converter Dialog. .. versionadded:: 4.3 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(conte...
[ "def", "metadata_converter_help", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "heading", "(", ")", ")", "message", ".", "add", "(", "content...
Help message for metadata converter Dialog. .. versionadded:: 4.3 :returns: A message object containing helpful information. :rtype: messaging.message.Message
[ "Help", "message", "for", "metadata", "converter", "Dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/metadata_converter_help.py#L19-L31
train
27,112
inasafe/inasafe
safe/utilities/qt.py
qt_at_least
def qt_at_least(needed_version, test_version=None): """Check if the installed Qt version is greater than the requested :param needed_version: minimally needed Qt version in format like 4.8.4 :type needed_version: str :param test_version: Qt version as returned from Qt.QT_VERSION. As in 0x040100 T...
python
def qt_at_least(needed_version, test_version=None): """Check if the installed Qt version is greater than the requested :param needed_version: minimally needed Qt version in format like 4.8.4 :type needed_version: str :param test_version: Qt version as returned from Qt.QT_VERSION. As in 0x040100 T...
[ "def", "qt_at_least", "(", "needed_version", ",", "test_version", "=", "None", ")", ":", "major", ",", "minor", ",", "patch", "=", "needed_version", ".", "split", "(", "'.'", ")", "needed_version", "=", "'0x0%s0%s0%s'", "%", "(", "major", ",", "minor", ","...
Check if the installed Qt version is greater than the requested :param needed_version: minimally needed Qt version in format like 4.8.4 :type needed_version: str :param test_version: Qt version as returned from Qt.QT_VERSION. As in 0x040100 This is used only for tests :type test_version: int ...
[ "Check", "if", "the", "installed", "Qt", "version", "is", "greater", "than", "the", "requested" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/qt.py#L15-L39
train
27,113
inasafe/inasafe
safe/utilities/qt.py
disable_busy_cursor
def disable_busy_cursor(): """Disable the hourglass cursor and listen for layer changes.""" while QgsApplication.instance().overrideCursor() is not None and \ QgsApplication.instance().overrideCursor().shape() == \ QtCore.Qt.WaitCursor: QgsApplication.instance().restoreOverrideCu...
python
def disable_busy_cursor(): """Disable the hourglass cursor and listen for layer changes.""" while QgsApplication.instance().overrideCursor() is not None and \ QgsApplication.instance().overrideCursor().shape() == \ QtCore.Qt.WaitCursor: QgsApplication.instance().restoreOverrideCu...
[ "def", "disable_busy_cursor", "(", ")", ":", "while", "QgsApplication", ".", "instance", "(", ")", ".", "overrideCursor", "(", ")", "is", "not", "None", "and", "QgsApplication", ".", "instance", "(", ")", ".", "overrideCursor", "(", ")", ".", "shape", "(",...
Disable the hourglass cursor and listen for layer changes.
[ "Disable", "the", "hourglass", "cursor", "and", "listen", "for", "layer", "changes", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/qt.py#L49-L54
train
27,114
inasafe/inasafe
safe/gui/tools/wizard/step_kw05_subcategory.py
StepKwSubcategory.subcategories_for_layer
def subcategories_for_layer(self): """Return a list of valid subcategories for a layer. Subcategory is hazard type or exposure type. :returns: A list where each value represents a valid subcategory. :rtype: list """ purpose = self.parent.step_kw_purpose.selected_purpo...
python
def subcategories_for_layer(self): """Return a list of valid subcategories for a layer. Subcategory is hazard type or exposure type. :returns: A list where each value represents a valid subcategory. :rtype: list """ purpose = self.parent.step_kw_purpose.selected_purpo...
[ "def", "subcategories_for_layer", "(", "self", ")", ":", "purpose", "=", "self", ".", "parent", ".", "step_kw_purpose", ".", "selected_purpose", "(", ")", "layer_geometry_key", "=", "self", ".", "parent", ".", "get_layer_geometry_key", "(", ")", "if", "purpose",...
Return a list of valid subcategories for a layer. Subcategory is hazard type or exposure type. :returns: A list where each value represents a valid subcategory. :rtype: list
[ "Return", "a", "list", "of", "valid", "subcategories", "for", "a", "layer", ".", "Subcategory", "is", "hazard", "type", "or", "exposure", "type", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw05_subcategory.py#L59-L71
train
27,115
inasafe/inasafe
safe/gui/tools/wizard/step_kw05_subcategory.py
StepKwSubcategory.on_lstSubcategories_itemSelectionChanged
def on_lstSubcategories_itemSelectionChanged(self): """Update subcategory description label. .. note:: This is an automatic Qt slot executed when the subcategory selection changes. """ self.clear_further_steps() # Set widgets subcategory = self.selected_subcat...
python
def on_lstSubcategories_itemSelectionChanged(self): """Update subcategory description label. .. note:: This is an automatic Qt slot executed when the subcategory selection changes. """ self.clear_further_steps() # Set widgets subcategory = self.selected_subcat...
[ "def", "on_lstSubcategories_itemSelectionChanged", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "# Set widgets", "subcategory", "=", "self", ".", "selected_subcategory", "(", ")", "# Exit if no selection", "if", "not", "subcategory", ":", "retu...
Update subcategory description label. .. note:: This is an automatic Qt slot executed when the subcategory selection changes.
[ "Update", "subcategory", "description", "label", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw05_subcategory.py#L74-L93
train
27,116
inasafe/inasafe
safe/gui/tools/wizard/step_kw05_subcategory.py
StepKwSubcategory.selected_subcategory
def selected_subcategory(self): """Obtain the subcategory selected by user. :returns: Metadata of the selected subcategory. :rtype: dict, None """ item = self.lstSubcategories.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) except ...
python
def selected_subcategory(self): """Obtain the subcategory selected by user. :returns: Metadata of the selected subcategory. :rtype: dict, None """ item = self.lstSubcategories.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) except ...
[ "def", "selected_subcategory", "(", "self", ")", ":", "item", "=", "self", ".", "lstSubcategories", ".", "currentItem", "(", ")", "try", ":", "return", "definition", "(", "item", ".", "data", "(", "QtCore", ".", "Qt", ".", "UserRole", ")", ")", "except",...
Obtain the subcategory selected by user. :returns: Metadata of the selected subcategory. :rtype: dict, None
[ "Obtain", "the", "subcategory", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw05_subcategory.py#L95-L105
train
27,117
inasafe/inasafe
safe/gui/tools/wizard/step_kw05_subcategory.py
StepKwSubcategory.set_widgets
def set_widgets(self): """Set widgets on the Subcategory tab.""" self.clear_further_steps() # Set widgets purpose = self.parent.step_kw_purpose.selected_purpose() self.lstSubcategories.clear() self.lblDescribeSubcategory.setText('') self.lblIconSubcategory.setPixm...
python
def set_widgets(self): """Set widgets on the Subcategory tab.""" self.clear_further_steps() # Set widgets purpose = self.parent.step_kw_purpose.selected_purpose() self.lstSubcategories.clear() self.lblDescribeSubcategory.setText('') self.lblIconSubcategory.setPixm...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "# Set widgets", "purpose", "=", "self", ".", "parent", ".", "step_kw_purpose", ".", "selected_purpose", "(", ")", "self", ".", "lstSubcategories", ".", "clear", "(", ...
Set widgets on the Subcategory tab.
[ "Set", "widgets", "on", "the", "Subcategory", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw05_subcategory.py#L116-L151
train
27,118
inasafe/inasafe
safe/gui/tools/metadata_converter_dialog.py
MetadataConverterDialog.select_output_directory
def select_output_directory(self): """Select output directory""" # Input layer input_layer_path = self.layer.source() input_file_name = os.path.basename(input_layer_path) input_extension = os.path.splitext(input_file_name)[1] # Get current path current_file_path ...
python
def select_output_directory(self): """Select output directory""" # Input layer input_layer_path = self.layer.source() input_file_name = os.path.basename(input_layer_path) input_extension = os.path.splitext(input_file_name)[1] # Get current path current_file_path ...
[ "def", "select_output_directory", "(", "self", ")", ":", "# Input layer", "input_layer_path", "=", "self", ".", "layer", ".", "source", "(", ")", "input_file_name", "=", "os", ".", "path", ".", "basename", "(", "input_layer_path", ")", "input_extension", "=", ...
Select output directory
[ "Select", "output", "directory" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/metadata_converter_dialog.py#L297-L325
train
27,119
inasafe/inasafe
safe/gui/tools/metadata_converter_dialog.py
MetadataConverterDialog.show_current_metadata
def show_current_metadata(self): """Show metadata of the current selected layer.""" LOGGER.debug('Showing layer: ' + self.layer.name()) keywords = KeywordIO(self.layer) content_html = keywords.to_message().to_html() full_html = html_header() + content_html + html_footer() ...
python
def show_current_metadata(self): """Show metadata of the current selected layer.""" LOGGER.debug('Showing layer: ' + self.layer.name()) keywords = KeywordIO(self.layer) content_html = keywords.to_message().to_html() full_html = html_header() + content_html + html_footer() ...
[ "def", "show_current_metadata", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Showing layer: '", "+", "self", ".", "layer", ".", "name", "(", ")", ")", "keywords", "=", "KeywordIO", "(", "self", ".", "layer", ")", "content_html", "=", "keywords", ...
Show metadata of the current selected layer.
[ "Show", "metadata", "of", "the", "current", "selected", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/metadata_converter_dialog.py#L327-L333
train
27,120
inasafe/inasafe
extras/system_tools.py
get_user_name
def get_user_name(): """Get user name provide by operating system """ if sys.platform == 'win32': #user = os.getenv('USERPROFILE') user = os.getenv('USERNAME') else: user = os.getenv('LOGNAME') return user
python
def get_user_name(): """Get user name provide by operating system """ if sys.platform == 'win32': #user = os.getenv('USERPROFILE') user = os.getenv('USERNAME') else: user = os.getenv('LOGNAME') return user
[ "def", "get_user_name", "(", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "#user = os.getenv('USERPROFILE')", "user", "=", "os", ".", "getenv", "(", "'USERNAME'", ")", "else", ":", "user", "=", "os", ".", "getenv", "(", "'LOGNAME'", ")", ...
Get user name provide by operating system
[ "Get", "user", "name", "provide", "by", "operating", "system" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L19-L29
train
27,121
inasafe/inasafe
extras/system_tools.py
get_host_name
def get_host_name(): """Get host name provide by operating system """ if sys.platform == 'win32': host = os.getenv('COMPUTERNAME') else: host = os.uname()[1] return host
python
def get_host_name(): """Get host name provide by operating system """ if sys.platform == 'win32': host = os.getenv('COMPUTERNAME') else: host = os.uname()[1] return host
[ "def", "get_host_name", "(", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "host", "=", "os", ".", "getenv", "(", "'COMPUTERNAME'", ")", "else", ":", "host", "=", "os", ".", "uname", "(", ")", "[", "1", "]", "return", "host" ]
Get host name provide by operating system
[ "Get", "host", "name", "provide", "by", "operating", "system" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L31-L41
train
27,122
inasafe/inasafe
extras/system_tools.py
compute_checksum
def compute_checksum(filename, max_length=2**20): """Compute the CRC32 checksum for specified file Optional parameter max_length sets the maximum number of bytes used to limit time used with large files. Default = 2**20 (1MB) """ fid = open(filename, 'rb') # Use binary for portability crcv...
python
def compute_checksum(filename, max_length=2**20): """Compute the CRC32 checksum for specified file Optional parameter max_length sets the maximum number of bytes used to limit time used with large files. Default = 2**20 (1MB) """ fid = open(filename, 'rb') # Use binary for portability crcv...
[ "def", "compute_checksum", "(", "filename", ",", "max_length", "=", "2", "**", "20", ")", ":", "fid", "=", "open", "(", "filename", ",", "'rb'", ")", "# Use binary for portability", "crcval", "=", "safe_crc", "(", "fid", ".", "read", "(", "max_length", ")"...
Compute the CRC32 checksum for specified file Optional parameter max_length sets the maximum number of bytes used to limit time used with large files. Default = 2**20 (1MB)
[ "Compute", "the", "CRC32", "checksum", "for", "specified", "file" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L58-L70
train
27,123
inasafe/inasafe
extras/system_tools.py
clean_line
def clean_line(str, delimiter): """Split string on given delimiter, remove whitespace from each field.""" return [x.strip() for x in str.strip().split(delimiter) if x != '']
python
def clean_line(str, delimiter): """Split string on given delimiter, remove whitespace from each field.""" return [x.strip() for x in str.strip().split(delimiter) if x != '']
[ "def", "clean_line", "(", "str", ",", "delimiter", ")", ":", "return", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "str", ".", "strip", "(", ")", ".", "split", "(", "delimiter", ")", "if", "x", "!=", "''", "]" ]
Split string on given delimiter, remove whitespace from each field.
[ "Split", "string", "on", "given", "delimiter", "remove", "whitespace", "from", "each", "field", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L112-L115
train
27,124
inasafe/inasafe
extras/system_tools.py
string_to_char
def string_to_char(l): '''Convert 1-D list of strings to 2-D list of chars.''' if not l: return [] if l == ['']: l = [' '] maxlen = reduce(max, map(len, l)) ll = [x.ljust(maxlen) for x in l] result = [] for s in ll: result.append([x for x in s]) return result
python
def string_to_char(l): '''Convert 1-D list of strings to 2-D list of chars.''' if not l: return [] if l == ['']: l = [' '] maxlen = reduce(max, map(len, l)) ll = [x.ljust(maxlen) for x in l] result = [] for s in ll: result.append([x for x in s]) return result
[ "def", "string_to_char", "(", "l", ")", ":", "if", "not", "l", ":", "return", "[", "]", "if", "l", "==", "[", "''", "]", ":", "l", "=", "[", "' '", "]", "maxlen", "=", "reduce", "(", "max", ",", "map", "(", "len", ",", "l", ")", ")", "ll", ...
Convert 1-D list of strings to 2-D list of chars.
[ "Convert", "1", "-", "D", "list", "of", "strings", "to", "2", "-", "D", "list", "of", "chars", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L148-L162
train
27,125
inasafe/inasafe
extras/system_tools.py
get_vars_in_expression
def get_vars_in_expression(source): '''Get list of variable names in a python expression.''' import compiler from compiler.ast import Node ## # @brief Internal recursive function. # @param node An AST parse Node. # @param var_list Input list of variables. # @return An updated list of v...
python
def get_vars_in_expression(source): '''Get list of variable names in a python expression.''' import compiler from compiler.ast import Node ## # @brief Internal recursive function. # @param node An AST parse Node. # @param var_list Input list of variables. # @return An updated list of v...
[ "def", "get_vars_in_expression", "(", "source", ")", ":", "import", "compiler", "from", "compiler", ".", "ast", "import", "Node", "##", "# @brief Internal recursive function.", "# @param node An AST parse Node.", "# @param var_list Input list of variables.", "# @return An updated...
Get list of variable names in a python expression.
[ "Get", "list", "of", "variable", "names", "in", "a", "python", "expression", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L182-L207
train
27,126
inasafe/inasafe
extras/system_tools.py
tar_file
def tar_file(files, tarname): '''Compress a file or directory into a tar file.''' if isinstance(files, basestring): files = [files] o = tarfile.open(tarname, 'w:gz') for file in files: o.add(file) o.close()
python
def tar_file(files, tarname): '''Compress a file or directory into a tar file.''' if isinstance(files, basestring): files = [files] o = tarfile.open(tarname, 'w:gz') for file in files: o.add(file) o.close()
[ "def", "tar_file", "(", "files", ",", "tarname", ")", ":", "if", "isinstance", "(", "files", ",", "basestring", ")", ":", "files", "=", "[", "files", "]", "o", "=", "tarfile", ".", "open", "(", "tarname", ",", "'w:gz'", ")", "for", "file", "in", "f...
Compress a file or directory into a tar file.
[ "Compress", "a", "file", "or", "directory", "into", "a", "tar", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L323-L332
train
27,127
inasafe/inasafe
extras/system_tools.py
untar_file
def untar_file(tarname, target_dir='.'): '''Uncompress a tar file.''' o = tarfile.open(tarname, 'r:gz') members = o.getmembers() for member in members: o.extract(member, target_dir) o.close()
python
def untar_file(tarname, target_dir='.'): '''Uncompress a tar file.''' o = tarfile.open(tarname, 'r:gz') members = o.getmembers() for member in members: o.extract(member, target_dir) o.close()
[ "def", "untar_file", "(", "tarname", ",", "target_dir", "=", "'.'", ")", ":", "o", "=", "tarfile", ".", "open", "(", "tarname", ",", "'r:gz'", ")", "members", "=", "o", ".", "getmembers", "(", ")", "for", "member", "in", "members", ":", "o", ".", "...
Uncompress a tar file.
[ "Uncompress", "a", "tar", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L339-L346
train
27,128
inasafe/inasafe
extras/system_tools.py
get_file_hexdigest
def get_file_hexdigest(filename, blocksize=1024*1024*10): '''Get a hex digest of a file.''' if hashlib.__name__ == 'hashlib': m = hashlib.md5() # new - 'hashlib' module else: m = hashlib.new() # old - 'md5' module - remove once py2.4 gone fd = open(filename, 'r') while ...
python
def get_file_hexdigest(filename, blocksize=1024*1024*10): '''Get a hex digest of a file.''' if hashlib.__name__ == 'hashlib': m = hashlib.md5() # new - 'hashlib' module else: m = hashlib.new() # old - 'md5' module - remove once py2.4 gone fd = open(filename, 'r') while ...
[ "def", "get_file_hexdigest", "(", "filename", ",", "blocksize", "=", "1024", "*", "1024", "*", "10", ")", ":", "if", "hashlib", ".", "__name__", "==", "'hashlib'", ":", "m", "=", "hashlib", ".", "md5", "(", ")", "# new - 'hashlib' module", "else", ":", "...
Get a hex digest of a file.
[ "Get", "a", "hex", "digest", "of", "a", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L355-L371
train
27,129
inasafe/inasafe
extras/system_tools.py
make_digest_file
def make_digest_file(data_file, digest_file): '''Create a file containing the hex digest string of a data file.''' hexdigest = get_file_hexdigest(data_file) fd = open(digest_file, 'w') fd.write(hexdigest) fd.close()
python
def make_digest_file(data_file, digest_file): '''Create a file containing the hex digest string of a data file.''' hexdigest = get_file_hexdigest(data_file) fd = open(digest_file, 'w') fd.write(hexdigest) fd.close()
[ "def", "make_digest_file", "(", "data_file", ",", "digest_file", ")", ":", "hexdigest", "=", "get_file_hexdigest", "(", "data_file", ")", "fd", "=", "open", "(", "digest_file", ",", "'w'", ")", "fd", ".", "write", "(", "hexdigest", ")", "fd", ".", "close",...
Create a file containing the hex digest string of a data file.
[ "Create", "a", "file", "containing", "the", "hex", "digest", "string", "of", "a", "data", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L379-L385
train
27,130
inasafe/inasafe
extras/system_tools.py
file_length
def file_length(in_file): '''Function to return the length of a file.''' fid = open(in_file) data = fid.readlines() fid.close() return len(data)
python
def file_length(in_file): '''Function to return the length of a file.''' fid = open(in_file) data = fid.readlines() fid.close() return len(data)
[ "def", "file_length", "(", "in_file", ")", ":", "fid", "=", "open", "(", "in_file", ")", "data", "=", "fid", ".", "readlines", "(", ")", "fid", ".", "close", "(", ")", "return", "len", "(", "data", ")" ]
Function to return the length of a file.
[ "Function", "to", "return", "the", "length", "of", "a", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/system_tools.py#L395-L401
train
27,131
inasafe/inasafe
safe/gis/vector/convert_geojson_to_shapefile.py
convert_geojson_to_shapefile
def convert_geojson_to_shapefile(geojson_path): """Convert geojson file to shapefile. It will create a necessary file next to the geojson file. It will not affect another files (e.g. .xml, .qml, etc). :param geojson_path: The path to geojson file. :type geojson_path: basestring :returns: True...
python
def convert_geojson_to_shapefile(geojson_path): """Convert geojson file to shapefile. It will create a necessary file next to the geojson file. It will not affect another files (e.g. .xml, .qml, etc). :param geojson_path: The path to geojson file. :type geojson_path: basestring :returns: True...
[ "def", "convert_geojson_to_shapefile", "(", "geojson_path", ")", ":", "layer", "=", "QgsVectorLayer", "(", "geojson_path", ",", "'vector layer'", ",", "'ogr'", ")", "if", "not", "layer", ".", "isValid", "(", ")", ":", "return", "False", "# Construct shapefile path...
Convert geojson file to shapefile. It will create a necessary file next to the geojson file. It will not affect another files (e.g. .xml, .qml, etc). :param geojson_path: The path to geojson file. :type geojson_path: basestring :returns: True if shapefile layer created, False otherwise. :rtyp...
[ "Convert", "geojson", "file", "to", "shapefile", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/convert_geojson_to_shapefile.py#L18-L43
train
27,132
inasafe/inasafe
safe/gui/tools/help/peta_bencana_help.py
peta_bencana_help
def peta_bencana_help(): """Help message for PetaBencana dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content()) ...
python
def peta_bencana_help(): """Help message for PetaBencana dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content()) ...
[ "def", "peta_bencana_help", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "heading", "(", ")", ")", "message", ".", "add", "(", "content", "...
Help message for PetaBencana dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message
[ "Help", "message", "for", "PetaBencana", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/peta_bencana_help.py#L13-L26
train
27,133
inasafe/inasafe
safe/messaging/item/row.py
Row.add
def add(self, item, header_flag=False, align=None): """Add a Cell to the row :param item: An element to add to the Cells can be list or Cell object. :type item: basestring, QString, list, Cell :param header_flag: Flag indicating it the item is a header or not. :type header_flag...
python
def add(self, item, header_flag=False, align=None): """Add a Cell to the row :param item: An element to add to the Cells can be list or Cell object. :type item: basestring, QString, list, Cell :param header_flag: Flag indicating it the item is a header or not. :type header_flag...
[ "def", "add", "(", "self", ",", "item", ",", "header_flag", "=", "False", ",", "align", "=", "None", ")", ":", "if", "self", ".", "_is_stringable", "(", "item", ")", "or", "self", ".", "_is_qstring", "(", "item", ")", ":", "self", ".", "cells", "."...
Add a Cell to the row :param item: An element to add to the Cells can be list or Cell object. :type item: basestring, QString, list, Cell :param header_flag: Flag indicating it the item is a header or not. :type header_flag: bool :param align: Optional alignment qualifier for ...
[ "Add", "a", "Cell", "to", "the", "row" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/row.py#L76-L100
train
27,134
inasafe/inasafe
safe/messaging/utilities.py
generate_insufficient_overlap_message
def generate_insufficient_overlap_message( e, exposure_geoextent, exposure_layer, hazard_geoextent, hazard_layer, viewport_geoextent): """Generate insufficient overlap message. :param e: An exception. :type e: Exception :param exposure_geoextent: Extent ...
python
def generate_insufficient_overlap_message( e, exposure_geoextent, exposure_layer, hazard_geoextent, hazard_layer, viewport_geoextent): """Generate insufficient overlap message. :param e: An exception. :type e: Exception :param exposure_geoextent: Extent ...
[ "def", "generate_insufficient_overlap_message", "(", "e", ",", "exposure_geoextent", ",", "exposure_layer", ",", "hazard_geoextent", ",", "hazard_layer", ",", "viewport_geoextent", ")", ":", "description", "=", "tr", "(", "'There was insufficient overlap between the input lay...
Generate insufficient overlap message. :param e: An exception. :type e: Exception :param exposure_geoextent: Extent of the exposure layer in the form [xmin, ymin, xmax, ymax] in EPSG:4326. :type exposure_geoextent: list :param exposure_layer: Exposure layer. :type exposure_layer: QgsM...
[ "Generate", "insufficient", "overlap", "message", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/utilities.py#L18-L77
train
27,135
inasafe/inasafe
safe/utilities/extent.py
singleton
def singleton(class_): """Singleton definition. Method 1 from https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python """ instances = {} def get_instance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) ret...
python
def singleton(class_): """Singleton definition. Method 1 from https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python """ instances = {} def get_instance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) ret...
[ "def", "singleton", "(", "class_", ")", ":", "instances", "=", "{", "}", "def", "get_instance", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "class_", "not", "in", "instances", ":", "instances", "[", "class_", "]", "=", "class_", "(", ...
Singleton definition. Method 1 from https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
[ "Singleton", "definition", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/extent.py#L30-L42
train
27,136
inasafe/inasafe
safe/report/extractors/infographics.py
population_chart_legend_extractor
def population_chart_legend_extractor(impact_report, component_metadata): """Extracting legend of population chart. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param compon...
python
def population_chart_legend_extractor(impact_report, component_metadata): """Extracting legend of population chart. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param compon...
[ "def", "population_chart_legend_extractor", "(", "impact_report", ",", "component_metadata", ")", ":", "context", "=", "{", "}", "context", "[", "'inasafe_resources_base_dir'", "]", "=", "resources_path", "(", ")", "\"\"\"Population Charts.\"\"\"", "population_donut_path", ...
Extracting legend of population chart. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param component_metadata: the component metadata. Used to obtain information about th...
[ "Extracting", "legend", "of", "population", "chart", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/infographics.py#L18-L67
train
27,137
inasafe/inasafe
safe/report/extractors/infographics.py
infographic_people_section_notes_extractor
def infographic_people_section_notes_extractor( impact_report, component_metadata): """Extracting notes for people section in the infographic. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_rep...
python
def infographic_people_section_notes_extractor( impact_report, component_metadata): """Extracting notes for people section in the infographic. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_rep...
[ "def", "infographic_people_section_notes_extractor", "(", "impact_report", ",", "component_metadata", ")", ":", "extra_args", "=", "component_metadata", ".", "extra_args", "provenance", "=", "impact_report", ".", "impact_function", ".", "provenance", "hazard_keywords", "=",...
Extracting notes for people section in the infographic. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param component_metadata: the component metadata. Used to obtain inf...
[ "Extracting", "notes", "for", "people", "section", "in", "the", "infographic", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/infographics.py#L70-L135
train
27,138
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.is_ready_to_next_step
def is_ready_to_next_step(self): """Check if the step is complete. :returns: True if new step may be enabled. :rtype: bool """ # Still editing if self.mode == EDIT_MODE: return False for combo_box in self.exposure_combo_boxes: # Enable if ...
python
def is_ready_to_next_step(self): """Check if the step is complete. :returns: True if new step may be enabled. :rtype: bool """ # Still editing if self.mode == EDIT_MODE: return False for combo_box in self.exposure_combo_boxes: # Enable if ...
[ "def", "is_ready_to_next_step", "(", "self", ")", ":", "# Still editing", "if", "self", ".", "mode", "==", "EDIT_MODE", ":", "return", "False", "for", "combo_box", "in", "self", ".", "exposure_combo_boxes", ":", "# Enable if there is one that has classification", "if"...
Check if the step is complete. :returns: True if new step may be enabled. :rtype: bool
[ "Check", "if", "the", "step", "is", "complete", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L125-L141
train
27,139
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.set_wizard_step_description
def set_wizard_step_description(self): """Set the text for description.""" subcategory = self.parent.step_kw_subcategory.selected_subcategory() field = self.parent.step_kw_field.selected_fields() is_raster = is_raster_layer(self.parent.layer) if is_raster: if self.la...
python
def set_wizard_step_description(self): """Set the text for description.""" subcategory = self.parent.step_kw_subcategory.selected_subcategory() field = self.parent.step_kw_field.selected_fields() is_raster = is_raster_layer(self.parent.layer) if is_raster: if self.la...
[ "def", "set_wizard_step_description", "(", "self", ")", ":", "subcategory", "=", "self", ".", "parent", ".", "step_kw_subcategory", ".", "selected_subcategory", "(", ")", "field", "=", "self", ".", "parent", ".", "step_kw_field", ".", "selected_fields", "(", ")"...
Set the text for description.
[ "Set", "the", "text", "for", "description", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L178-L201
train
27,140
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.edit_button_clicked
def edit_button_clicked(self, edit_button, exposure_combo_box, exposure): """Method to handle when an edit button is clicked. :param edit_button: The edit button. :type edit_button: QPushButton :param exposure_combo_box: The combo box of the exposure, contains list of class...
python
def edit_button_clicked(self, edit_button, exposure_combo_box, exposure): """Method to handle when an edit button is clicked. :param edit_button: The edit button. :type edit_button: QPushButton :param exposure_combo_box: The combo box of the exposure, contains list of class...
[ "def", "edit_button_clicked", "(", "self", ",", "edit_button", ",", "exposure_combo_box", ",", "exposure", ")", ":", "# Note(IS): Do not change the text of edit button for now until we", "# have better behaviour.", "classification", "=", "self", ".", "get_classification", "(", ...
Method to handle when an edit button is clicked. :param edit_button: The edit button. :type edit_button: QPushButton :param exposure_combo_box: The combo box of the exposure, contains list of classifications. :type exposure_combo_box: QComboBox :param exposure: Exp...
[ "Method", "to", "handle", "when", "an", "edit", "button", "is", "clicked", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L343-L389
train
27,141
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.set_widgets
def set_widgets(self): """Set widgets on the Multi classification step.""" self.clear() self.layer_mode = self.parent.step_kw_layermode.selected_layermode() self.layer_purpose = self.parent.step_kw_purpose.selected_purpose() self.set_current_state() # Set the step descri...
python
def set_widgets(self): """Set widgets on the Multi classification step.""" self.clear() self.layer_mode = self.parent.step_kw_layermode.selected_layermode() self.layer_purpose = self.parent.step_kw_purpose.selected_purpose() self.set_current_state() # Set the step descri...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "clear", "(", ")", "self", ".", "layer_mode", "=", "self", ".", "parent", ".", "step_kw_layermode", ".", "selected_layermode", "(", ")", "self", ".", "layer_purpose", "=", "self", ".", "parent", "...
Set widgets on the Multi classification step.
[ "Set", "widgets", "on", "the", "Multi", "classification", "step", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L471-L485
train
27,142
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.add_buttons
def add_buttons(self, classification): """Helper to setup 3 buttons. :param classification: The current classification. :type classification: dict """ # Note(IS): Until we have good behaviour, we will disable cancel # button. # Add 3 buttons: Restore default, Can...
python
def add_buttons(self, classification): """Helper to setup 3 buttons. :param classification: The current classification. :type classification: dict """ # Note(IS): Until we have good behaviour, we will disable cancel # button. # Add 3 buttons: Restore default, Can...
[ "def", "add_buttons", "(", "self", ",", "classification", ")", ":", "# Note(IS): Until we have good behaviour, we will disable cancel", "# button.", "# Add 3 buttons: Restore default, Cancel, Save", "# Restore default button, only for continuous layer (with threshold)", "if", "self", "."...
Helper to setup 3 buttons. :param classification: The current classification. :type classification: dict
[ "Helper", "to", "setup", "3", "buttons", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L755-L791
train
27,143
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.update_dragged_item_flags
def update_dragged_item_flags(self, item): """Fix the drop flag after the item is dropped. Check if it looks like an item dragged from QListWidget to QTreeWidget and disable the drop flag. For some reasons the flag is set when dragging. :param item: Item which is dragged. ...
python
def update_dragged_item_flags(self, item): """Fix the drop flag after the item is dropped. Check if it looks like an item dragged from QListWidget to QTreeWidget and disable the drop flag. For some reasons the flag is set when dragging. :param item: Item which is dragged. ...
[ "def", "update_dragged_item_flags", "(", "self", ",", "item", ")", ":", "if", "int", "(", "item", ".", "flags", "(", ")", "&", "Qt", ".", "ItemIsDropEnabled", ")", "and", "int", "(", "item", ".", "flags", "(", ")", "&", "Qt", ".", "ItemIsDragEnabled", ...
Fix the drop flag after the item is dropped. Check if it looks like an item dragged from QListWidget to QTreeWidget and disable the drop flag. For some reasons the flag is set when dragging. :param item: Item which is dragged. :type item: QTreeWidgetItem .. note:: This...
[ "Fix", "the", "drop", "flag", "after", "the", "item", "is", "dropped", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L944-L958
train
27,144
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.cancel_button_clicked
def cancel_button_clicked(self): """Action for cancel button clicked.""" # Change mode self.mode = CHOOSE_MODE # Enable all edit buttons and combo boxes for i in range(len(self.exposures)): if i == self.special_case_index: self.exposure_edit_buttons[i]...
python
def cancel_button_clicked(self): """Action for cancel button clicked.""" # Change mode self.mode = CHOOSE_MODE # Enable all edit buttons and combo boxes for i in range(len(self.exposures)): if i == self.special_case_index: self.exposure_edit_buttons[i]...
[ "def", "cancel_button_clicked", "(", "self", ")", ":", "# Change mode", "self", ".", "mode", "=", "CHOOSE_MODE", "# Enable all edit buttons and combo boxes", "for", "i", "in", "range", "(", "len", "(", "self", ".", "exposures", ")", ")", ":", "if", "i", "==", ...
Action for cancel button clicked.
[ "Action", "for", "cancel", "button", "clicked", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1032-L1056
train
27,145
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.save_button_clicked
def save_button_clicked(self, classification): """Action for save button clicked. :param classification: The classification that being edited. :type classification: dict """ # Save current edit if self.layer_mode == layer_mode_continuous: thresholds = self.ge...
python
def save_button_clicked(self, classification): """Action for save button clicked. :param classification: The classification that being edited. :type classification: dict """ # Save current edit if self.layer_mode == layer_mode_continuous: thresholds = self.ge...
[ "def", "save_button_clicked", "(", "self", ",", "classification", ")", ":", "# Save current edit", "if", "self", ".", "layer_mode", "==", "layer_mode_continuous", ":", "thresholds", "=", "self", ".", "get_threshold", "(", ")", "classification_class", "=", "{", "'c...
Action for save button clicked. :param classification: The classification that being edited. :type classification: dict
[ "Action", "for", "save", "button", "clicked", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1058-L1098
train
27,146
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.restore_default_button_clicked
def restore_default_button_clicked(self, classification): """Action for restore default button clicked. It will set the threshold with default value. :param classification: The classification that being edited. :type classification: dict """ # Obtain default value ...
python
def restore_default_button_clicked(self, classification): """Action for restore default button clicked. It will set the threshold with default value. :param classification: The classification that being edited. :type classification: dict """ # Obtain default value ...
[ "def", "restore_default_button_clicked", "(", "self", ",", "classification", ")", ":", "# Obtain default value", "class_dict", "=", "{", "}", "for", "the_class", "in", "classification", ".", "get", "(", "'classes'", ")", ":", "class_dict", "[", "the_class", "[", ...
Action for restore default button clicked. It will set the threshold with default value. :param classification: The classification that being edited. :type classification: dict
[ "Action", "for", "restore", "default", "button", "clicked", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1100-L1118
train
27,147
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.get_threshold
def get_threshold(self): """Return threshold based on current state.""" value_map = dict() for key, value in list(self.threshold_classes.items()): value_map[key] = [ value[0].value(), value[1].value(), ] return value_map
python
def get_threshold(self): """Return threshold based on current state.""" value_map = dict() for key, value in list(self.threshold_classes.items()): value_map[key] = [ value[0].value(), value[1].value(), ] return value_map
[ "def", "get_threshold", "(", "self", ")", ":", "value_map", "=", "dict", "(", ")", "for", "key", ",", "value", "in", "list", "(", "self", ".", "threshold_classes", ".", "items", "(", ")", ")", ":", "value_map", "[", "key", "]", "=", "[", "value", "...
Return threshold based on current state.
[ "Return", "threshold", "based", "on", "current", "state", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1120-L1128
train
27,148
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.set_current_state
def set_current_state(self): """"Helper to set the state of the step from current keywords.""" if not self.thresholds: self.thresholds = self.parent.get_existing_keyword('thresholds') if not self.value_maps: self.value_maps = self.parent.get_existing_keyword('value_maps')
python
def set_current_state(self): """"Helper to set the state of the step from current keywords.""" if not self.thresholds: self.thresholds = self.parent.get_existing_keyword('thresholds') if not self.value_maps: self.value_maps = self.parent.get_existing_keyword('value_maps')
[ "def", "set_current_state", "(", "self", ")", ":", "if", "not", "self", ".", "thresholds", ":", "self", ".", "thresholds", "=", "self", ".", "parent", ".", "get_existing_keyword", "(", "'thresholds'", ")", "if", "not", "self", ".", "value_maps", ":", "self...
Helper to set the state of the step from current keywords.
[ "Helper", "to", "set", "the", "state", "of", "the", "step", "from", "current", "keywords", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1146-L1151
train
27,149
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.classifications_combo_box_changed
def classifications_combo_box_changed( self, index, exposure, exposure_combo_box, edit_button): """Action when classification combo box changed. :param index: The index of the combo box. :type index: int :param exposure: The exposure associated with the combo box. :...
python
def classifications_combo_box_changed( self, index, exposure, exposure_combo_box, edit_button): """Action when classification combo box changed. :param index: The index of the combo box. :type index: int :param exposure: The exposure associated with the combo box. :...
[ "def", "classifications_combo_box_changed", "(", "self", ",", "index", ",", "exposure", ",", "exposure_combo_box", ",", "edit_button", ")", ":", "# Disable button if it's no classification", "edit_button", ".", "setEnabled", "(", "bool", "(", "index", ")", ")", "class...
Action when classification combo box changed. :param index: The index of the combo box. :type index: int :param exposure: The exposure associated with the combo box. :type exposure: dict :param exposure_combo_box: Combo box for the classification. :type exposure_combo_...
[ "Action", "when", "classification", "combo", "box", "changed", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1153-L1180
train
27,150
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
StepKwMultiClassifications.activate_classification
def activate_classification(self, exposure, classification=None): """Set active to True for classification for the exposure. If classification = None, all classification set active = False. :param exposure: Exposure definition. :type exposure: dict :param classification: Class...
python
def activate_classification(self, exposure, classification=None): """Set active to True for classification for the exposure. If classification = None, all classification set active = False. :param exposure: Exposure definition. :type exposure: dict :param classification: Class...
[ "def", "activate_classification", "(", "self", ",", "exposure", ",", "classification", "=", "None", ")", ":", "if", "self", ".", "layer_mode", "==", "layer_mode_continuous", ":", "selected_unit", "=", "self", ".", "parent", ".", "step_kw_unit", ".", "selected_un...
Set active to True for classification for the exposure. If classification = None, all classification set active = False. :param exposure: Exposure definition. :type exposure: dict :param classification: Classification definition. :type classification: dict
[ "Set", "active", "to", "True", "for", "classification", "for", "the", "exposure", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L1182-L1231
train
27,151
inasafe/inasafe
safe/utilities/default_values.py
set_inasafe_default_value_qsetting
def set_inasafe_default_value_qsetting( qsetting, category, inasafe_field_key, value): """Helper method to set inasafe default value to qsetting. :param qsetting: QSettings. :type qsetting: QSettings :param category: Category of the default value. It can be global or recent. Global mea...
python
def set_inasafe_default_value_qsetting( qsetting, category, inasafe_field_key, value): """Helper method to set inasafe default value to qsetting. :param qsetting: QSettings. :type qsetting: QSettings :param category: Category of the default value. It can be global or recent. Global mea...
[ "def", "set_inasafe_default_value_qsetting", "(", "qsetting", ",", "category", ",", "inasafe_field_key", ",", "value", ")", ":", "key", "=", "'inasafe/default_value/%s/%s'", "%", "(", "category", ",", "inasafe_field_key", ")", "qsetting", ".", "setValue", "(", "key"...
Helper method to set inasafe default value to qsetting. :param qsetting: QSettings. :type qsetting: QSettings :param category: Category of the default value. It can be global or recent. Global means the global setting for default value. Recent means the last set custom for default value fr...
[ "Helper", "method", "to", "set", "inasafe", "default", "value", "to", "qsetting", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/default_values.py#L14-L33
train
27,152
inasafe/inasafe
safe/utilities/default_values.py
get_inasafe_default_value_qsetting
def get_inasafe_default_value_qsetting( qsetting, category, inasafe_field_key): """Helper method to get the inasafe default value from qsetting. :param qsetting: QSetting. :type qsetting: QSetting :param category: Category of the default value. It can be global or recent. Global means ...
python
def get_inasafe_default_value_qsetting( qsetting, category, inasafe_field_key): """Helper method to get the inasafe default value from qsetting. :param qsetting: QSetting. :type qsetting: QSetting :param category: Category of the default value. It can be global or recent. Global means ...
[ "def", "get_inasafe_default_value_qsetting", "(", "qsetting", ",", "category", ",", "inasafe_field_key", ")", ":", "key", "=", "'inasafe/default_value/%s/%s'", "%", "(", "category", ",", "inasafe_field_key", ")", "default_value", "=", "qsetting", ".", "value", "(", ...
Helper method to get the inasafe default value from qsetting. :param qsetting: QSetting. :type qsetting: QSetting :param category: Category of the default value. It can be global or recent. Global means the global setting for default value. Recent means the last set custom for default valu...
[ "Helper", "method", "to", "get", "the", "inasafe", "default", "value", "from", "qsetting", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/default_values.py#L36-L67
train
27,153
inasafe/inasafe
safe/utilities/file_downloader.py
FileDownloader.download
def download(self): """Downloading the file. :returns: True if success, otherwise returns a tuple with format like this (QNetworkReply.NetworkError, error_message) :raises: IOError - when cannot create output_path """ # Prepare output path self.output_file =...
python
def download(self): """Downloading the file. :returns: True if success, otherwise returns a tuple with format like this (QNetworkReply.NetworkError, error_message) :raises: IOError - when cannot create output_path """ # Prepare output path self.output_file =...
[ "def", "download", "(", "self", ")", ":", "# Prepare output path", "self", ".", "output_file", "=", "QFile", "(", "self", ".", "output_path", ")", "if", "not", "self", ".", "output_file", ".", "open", "(", "QFile", ".", "WriteOnly", ")", ":", "raise", "I...
Downloading the file. :returns: True if success, otherwise returns a tuple with format like this (QNetworkReply.NetworkError, error_message) :raises: IOError - when cannot create output_path
[ "Downloading", "the", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/file_downloader.py#L67-L179
train
27,154
inasafe/inasafe
safe/utilities/file_downloader.py
FileDownloader.get_buffer
def get_buffer(self): """Get buffer from self.reply and store it to our buffer container.""" buffer_size = self.reply.size() data = self.reply.read(buffer_size) self.downloaded_file_buffer.append(data)
python
def get_buffer(self): """Get buffer from self.reply and store it to our buffer container.""" buffer_size = self.reply.size() data = self.reply.read(buffer_size) self.downloaded_file_buffer.append(data)
[ "def", "get_buffer", "(", "self", ")", ":", "buffer_size", "=", "self", ".", "reply", ".", "size", "(", ")", "data", "=", "self", ".", "reply", ".", "read", "(", "buffer_size", ")", "self", ".", "downloaded_file_buffer", ".", "append", "(", "data", ")"...
Get buffer from self.reply and store it to our buffer container.
[ "Get", "buffer", "from", "self", ".", "reply", "and", "store", "it", "to", "our", "buffer", "container", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/file_downloader.py#L181-L185
train
27,155
inasafe/inasafe
safe/gui/tools/wizard/step_kw60_title.py
StepKwTitle.on_leTitle_textChanged
def on_leTitle_textChanged(self): """Unlock the Next button .. note:: This is an automatic Qt slot executed when the title value changes. """ self.parent.pbnNext.setEnabled(bool(self.leTitle.text()))
python
def on_leTitle_textChanged(self): """Unlock the Next button .. note:: This is an automatic Qt slot executed when the title value changes. """ self.parent.pbnNext.setEnabled(bool(self.leTitle.text()))
[ "def", "on_leTitle_textChanged", "(", "self", ")", ":", "self", ".", "parent", ".", "pbnNext", ".", "setEnabled", "(", "bool", "(", "self", ".", "leTitle", ".", "text", "(", ")", ")", ")" ]
Unlock the Next button .. note:: This is an automatic Qt slot executed when the title value changes.
[ "Unlock", "the", "Next", "button" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw60_title.py#L52-L58
train
27,156
inasafe/inasafe
safe/gui/tools/wizard/step_kw60_title.py
StepKwTitle.set_widgets
def set_widgets(self): """Set widgets on the Title tab.""" # Set title from keyword first, if not found use layer name if self.parent.layer: if self.parent.get_existing_keyword('title'): title = self.parent.get_existing_keyword('title') else: ...
python
def set_widgets(self): """Set widgets on the Title tab.""" # Set title from keyword first, if not found use layer name if self.parent.layer: if self.parent.get_existing_keyword('title'): title = self.parent.get_existing_keyword('title') else: ...
[ "def", "set_widgets", "(", "self", ")", ":", "# Set title from keyword first, if not found use layer name", "if", "self", ".", "parent", ".", "layer", ":", "if", "self", ".", "parent", ".", "get_existing_keyword", "(", "'title'", ")", ":", "title", "=", "self", ...
Set widgets on the Title tab.
[ "Set", "widgets", "on", "the", "Title", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw60_title.py#L60-L68
train
27,157
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.start_capture
def start_capture(self): """Start capturing the rectangle.""" previous_map_tool = self.canvas.mapTool() if previous_map_tool != self.tool: self.previous_map_tool = previous_map_tool self.canvas.setMapTool(self.tool) self.hide()
python
def start_capture(self): """Start capturing the rectangle.""" previous_map_tool = self.canvas.mapTool() if previous_map_tool != self.tool: self.previous_map_tool = previous_map_tool self.canvas.setMapTool(self.tool) self.hide()
[ "def", "start_capture", "(", "self", ")", ":", "previous_map_tool", "=", "self", ".", "canvas", ".", "mapTool", "(", ")", "if", "previous_map_tool", "!=", "self", ".", "tool", ":", "self", ".", "previous_map_tool", "=", "previous_map_tool", "self", ".", "can...
Start capturing the rectangle.
[ "Start", "capturing", "the", "rectangle", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L205-L211
train
27,158
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.stop_capture
def stop_capture(self): """Stop capturing the rectangle and reshow the dialog.""" self._populate_coordinates() self.canvas.setMapTool(self.previous_map_tool) self.show()
python
def stop_capture(self): """Stop capturing the rectangle and reshow the dialog.""" self._populate_coordinates() self.canvas.setMapTool(self.previous_map_tool) self.show()
[ "def", "stop_capture", "(", "self", ")", ":", "self", ".", "_populate_coordinates", "(", ")", "self", ".", "canvas", ".", "setMapTool", "(", "self", ".", "previous_map_tool", ")", "self", ".", "show", "(", ")" ]
Stop capturing the rectangle and reshow the dialog.
[ "Stop", "capturing", "the", "rectangle", "and", "reshow", "the", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L213-L217
train
27,159
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.clear
def clear(self): """Clear the currently set extent.""" self.tool.reset() self._populate_coordinates() # Revert to using hazard, exposure and view as basis for analysis self.hazard_exposure_view_extent.setChecked(True)
python
def clear(self): """Clear the currently set extent.""" self.tool.reset() self._populate_coordinates() # Revert to using hazard, exposure and view as basis for analysis self.hazard_exposure_view_extent.setChecked(True)
[ "def", "clear", "(", "self", ")", ":", "self", ".", "tool", ".", "reset", "(", ")", "self", ".", "_populate_coordinates", "(", ")", "# Revert to using hazard, exposure and view as basis for analysis", "self", ".", "hazard_exposure_view_extent", ".", "setChecked", "(",...
Clear the currently set extent.
[ "Clear", "the", "currently", "set", "extent", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L219-L224
train
27,160
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.reject
def reject(self): """User rejected the rectangle.""" self.canvas.unsetMapTool(self.tool) if self.previous_map_tool != self.tool: self.canvas.setMapTool(self.previous_map_tool) self.tool.reset() self.extent_selector_closed.emit() super(ExtentSelectorDialog, sel...
python
def reject(self): """User rejected the rectangle.""" self.canvas.unsetMapTool(self.tool) if self.previous_map_tool != self.tool: self.canvas.setMapTool(self.previous_map_tool) self.tool.reset() self.extent_selector_closed.emit() super(ExtentSelectorDialog, sel...
[ "def", "reject", "(", "self", ")", ":", "self", ".", "canvas", ".", "unsetMapTool", "(", "self", ".", "tool", ")", "if", "self", ".", "previous_map_tool", "!=", "self", ".", "tool", ":", "self", ".", "canvas", ".", "setMapTool", "(", "self", ".", "pr...
User rejected the rectangle.
[ "User", "rejected", "the", "rectangle", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L226-L233
train
27,161
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.accept
def accept(self): """User accepted the rectangle.""" mode = None if self.hazard_exposure_view_extent.isChecked(): mode = HAZARD_EXPOSURE_VIEW elif self.exposure_only.isChecked(): mode = EXPOSURE elif self.hazard_exposure_only.isChecked(): mode ...
python
def accept(self): """User accepted the rectangle.""" mode = None if self.hazard_exposure_view_extent.isChecked(): mode = HAZARD_EXPOSURE_VIEW elif self.exposure_only.isChecked(): mode = EXPOSURE elif self.hazard_exposure_only.isChecked(): mode ...
[ "def", "accept", "(", "self", ")", ":", "mode", "=", "None", "if", "self", ".", "hazard_exposure_view_extent", ".", "isChecked", "(", ")", ":", "mode", "=", "HAZARD_EXPOSURE_VIEW", "elif", "self", ".", "exposure_only", ".", "isChecked", "(", ")", ":", "mod...
User accepted the rectangle.
[ "User", "accepted", "the", "rectangle", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L235-L272
train
27,162
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog._are_coordinates_valid
def _are_coordinates_valid(self): """Check if the coordinates are valid. :return: True if coordinates are valid otherwise False. :type: bool """ try: QgsPointXY( self.x_minimum.value(), self.y_maximum.value()) QgsPointXY( ...
python
def _are_coordinates_valid(self): """Check if the coordinates are valid. :return: True if coordinates are valid otherwise False. :type: bool """ try: QgsPointXY( self.x_minimum.value(), self.y_maximum.value()) QgsPointXY( ...
[ "def", "_are_coordinates_valid", "(", "self", ")", ":", "try", ":", "QgsPointXY", "(", "self", ".", "x_minimum", ".", "value", "(", ")", ",", "self", ".", "y_maximum", ".", "value", "(", ")", ")", "QgsPointXY", "(", "self", ".", "x_maximum", ".", "valu...
Check if the coordinates are valid. :return: True if coordinates are valid otherwise False. :type: bool
[ "Check", "if", "the", "coordinates", "are", "valid", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L274-L290
train
27,163
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog._coordinates_changed
def _coordinates_changed(self): """Handle a change in the coordinate input boxes.""" if self._are_coordinates_valid(): point1 = QgsPointXY( self.x_minimum.value(), self.y_maximum.value()) point2 = QgsPointXY( self.x_maximum.value(),...
python
def _coordinates_changed(self): """Handle a change in the coordinate input boxes.""" if self._are_coordinates_valid(): point1 = QgsPointXY( self.x_minimum.value(), self.y_maximum.value()) point2 = QgsPointXY( self.x_maximum.value(),...
[ "def", "_coordinates_changed", "(", "self", ")", ":", "if", "self", ".", "_are_coordinates_valid", "(", ")", ":", "point1", "=", "QgsPointXY", "(", "self", ".", "x_minimum", ".", "value", "(", ")", ",", "self", ".", "y_maximum", ".", "value", "(", ")", ...
Handle a change in the coordinate input boxes.
[ "Handle", "a", "change", "in", "the", "coordinate", "input", "boxes", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L292-L303
train
27,164
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog._populate_coordinates
def _populate_coordinates(self): """Update the UI with the current active coordinates.""" rect = self.tool.rectangle() self.blockSignals(True) if not rect.isEmpty(): self.x_minimum.setValue(rect.xMinimum()) self.y_minimum.setValue(rect.yMinimum()) self...
python
def _populate_coordinates(self): """Update the UI with the current active coordinates.""" rect = self.tool.rectangle() self.blockSignals(True) if not rect.isEmpty(): self.x_minimum.setValue(rect.xMinimum()) self.y_minimum.setValue(rect.yMinimum()) self...
[ "def", "_populate_coordinates", "(", "self", ")", ":", "rect", "=", "self", ".", "tool", ".", "rectangle", "(", ")", "self", ".", "blockSignals", "(", "True", ")", "if", "not", "rect", ".", "isEmpty", "(", ")", ":", "self", ".", "x_minimum", ".", "se...
Update the UI with the current active coordinates.
[ "Update", "the", "UI", "with", "the", "current", "active", "coordinates", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L305-L319
train
27,165
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.bookmarks_index_changed
def bookmarks_index_changed(self): """Update the UI when the bookmarks combobox has changed.""" index = self.bookmarks_list.currentIndex() if index >= 0: self.tool.reset() rectangle = self.bookmarks_list.itemData(index) self.tool.set_rectangle(rectangle) ...
python
def bookmarks_index_changed(self): """Update the UI when the bookmarks combobox has changed.""" index = self.bookmarks_list.currentIndex() if index >= 0: self.tool.reset() rectangle = self.bookmarks_list.itemData(index) self.tool.set_rectangle(rectangle) ...
[ "def", "bookmarks_index_changed", "(", "self", ")", ":", "index", "=", "self", ".", "bookmarks_list", ".", "currentIndex", "(", ")", "if", "index", ">=", "0", ":", "self", ".", "tool", ".", "reset", "(", ")", "rectangle", "=", "self", ".", "bookmarks_lis...
Update the UI when the bookmarks combobox has changed.
[ "Update", "the", "UI", "when", "the", "bookmarks", "combobox", "has", "changed", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L321-L331
train
27,166
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog.on_hazard_exposure_bookmark_toggled
def on_hazard_exposure_bookmark_toggled(self, enabled): """Update the UI when the user toggles the bookmarks radiobutton. :param enabled: The status of the radiobutton. :type enabled: bool """ if enabled: self.bookmarks_index_changed() else: self....
python
def on_hazard_exposure_bookmark_toggled(self, enabled): """Update the UI when the user toggles the bookmarks radiobutton. :param enabled: The status of the radiobutton. :type enabled: bool """ if enabled: self.bookmarks_index_changed() else: self....
[ "def", "on_hazard_exposure_bookmark_toggled", "(", "self", ",", "enabled", ")", ":", "if", "enabled", ":", "self", ".", "bookmarks_index_changed", "(", ")", "else", ":", "self", ".", "ok_button", ".", "setEnabled", "(", "True", ")", "self", ".", "_populate_coo...
Update the UI when the user toggles the bookmarks radiobutton. :param enabled: The status of the radiobutton. :type enabled: bool
[ "Update", "the", "UI", "when", "the", "user", "toggles", "the", "bookmarks", "radiobutton", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L353-L363
train
27,167
inasafe/inasafe
safe/gui/tools/extent_selector_dialog.py
ExtentSelectorDialog._populate_bookmarks_list
def _populate_bookmarks_list(self): """Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are re...
python
def _populate_bookmarks_list(self): """Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are re...
[ "def", "_populate_bookmarks_list", "(", "self", ")", ":", "# Connect to the QGIS sqlite database and check if the table exists.", "# noinspection PyArgumentList", "db_file_path", "=", "QgsApplication", ".", "qgisUserDatabaseFilePath", "(", ")", "db", "=", "sqlite3", ".", "conne...
Read the sqlite database and populate the bookmarks list. If no bookmarks are found, the bookmarks radio button will be disabled and the label will be shown indicating that the user should add bookmarks in QGIS first. Every bookmark are reprojected to mapcanvas crs.
[ "Read", "the", "sqlite", "database", "and", "populate", "the", "bookmarks", "list", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/extent_selector_dialog.py#L365-L420
train
27,168
inasafe/inasafe
safe/utilities/utilities.py
basestring_to_message
def basestring_to_message(text): """Convert a basestring to a Message object if needed. Avoid using this function, better to create the Message object yourself. This one is very generic. This function exists ust in case we get a basestring and we really need a Message object. :param text: The...
python
def basestring_to_message(text): """Convert a basestring to a Message object if needed. Avoid using this function, better to create the Message object yourself. This one is very generic. This function exists ust in case we get a basestring and we really need a Message object. :param text: The...
[ "def", "basestring_to_message", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "Message", ")", ":", "return", "text", "elif", "text", "is", "None", ":", "return", "''", "else", ":", "report", "=", "m", ".", "Message", "(", ")", "report", ...
Convert a basestring to a Message object if needed. Avoid using this function, better to create the Message object yourself. This one is very generic. This function exists ust in case we get a basestring and we really need a Message object. :param text: The text. :type text: basestring, Messa...
[ "Convert", "a", "basestring", "to", "a", "Message", "object", "if", "needed", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L40-L62
train
27,169
inasafe/inasafe
safe/utilities/utilities.py
get_error_message
def get_error_message(exception, context=None, suggestion=None): """Convert exception into an ErrorMessage containing a stack trace. :param exception: Exception object. :type exception: Exception :param context: Optional context message. :type context: str :param suggestion: Optional suggesti...
python
def get_error_message(exception, context=None, suggestion=None): """Convert exception into an ErrorMessage containing a stack trace. :param exception: Exception object. :type exception: Exception :param context: Optional context message. :type context: str :param suggestion: Optional suggesti...
[ "def", "get_error_message", "(", "exception", ",", "context", "=", "None", ",", "suggestion", "=", "None", ")", ":", "name", ",", "trace", "=", "humanise_exception", "(", "exception", ")", "problem", "=", "m", ".", "Message", "(", "name", ")", "if", "exc...
Convert exception into an ErrorMessage containing a stack trace. :param exception: Exception object. :type exception: Exception :param context: Optional context message. :type context: str :param suggestion: Optional suggestion. :type suggestion: str .. see also:: https://github.com/inas...
[ "Convert", "exception", "into", "an", "ErrorMessage", "containing", "a", "stack", "trace", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L65-L111
train
27,170
inasafe/inasafe
safe/utilities/utilities.py
humanise_exception
def humanise_exception(exception): """Humanise a python exception by giving the class name and traceback. The function will return a tuple with the exception name and the traceback. :param exception: Exception object. :type exception: Exception :return: A tuple with the exception name and the tra...
python
def humanise_exception(exception): """Humanise a python exception by giving the class name and traceback. The function will return a tuple with the exception name and the traceback. :param exception: Exception object. :type exception: Exception :return: A tuple with the exception name and the tra...
[ "def", "humanise_exception", "(", "exception", ")", ":", "trace", "=", "''", ".", "join", "(", "traceback", ".", "format_tb", "(", "sys", ".", "exc_info", "(", ")", "[", "2", "]", ")", ")", "name", "=", "exception", ".", "__class__", ".", "__name__", ...
Humanise a python exception by giving the class name and traceback. The function will return a tuple with the exception name and the traceback. :param exception: Exception object. :type exception: Exception :return: A tuple with the exception name and the traceback. :rtype: (str, str)
[ "Humanise", "a", "python", "exception", "by", "giving", "the", "class", "name", "and", "traceback", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L114-L127
train
27,171
inasafe/inasafe
safe/utilities/utilities.py
html_to_file
def html_to_file(html, file_path=None, open_browser=False): """Save the html to an html file adapting the paths to the filesystem. if a file_path is passed, it is used, if not a unique_filename is generated. :param html: the html for the output file. :type html: str :param file_path: the path...
python
def html_to_file(html, file_path=None, open_browser=False): """Save the html to an html file adapting the paths to the filesystem. if a file_path is passed, it is used, if not a unique_filename is generated. :param html: the html for the output file. :type html: str :param file_path: the path...
[ "def", "html_to_file", "(", "html", ",", "file_path", "=", "None", ",", "open_browser", "=", "False", ")", ":", "if", "file_path", "is", "None", ":", "file_path", "=", "unique_filename", "(", "suffix", "=", "'.html'", ")", "# Ensure html is in unicode for codecs...
Save the html to an html file adapting the paths to the filesystem. if a file_path is passed, it is used, if not a unique_filename is generated. :param html: the html for the output file. :type html: str :param file_path: the path for the html output file. :type file_path: str :param ope...
[ "Save", "the", "html", "to", "an", "html", "file", "adapting", "the", "paths", "to", "the", "filesystem", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L226-L250
train
27,172
inasafe/inasafe
safe/utilities/utilities.py
is_keyword_version_supported
def is_keyword_version_supported( keyword_version, inasafe_version=inasafe_keyword_version): """Check if the keyword version is supported by this InaSAFE version. .. versionadded: 3.3 :param keyword_version: String representation of the keyword version. :type keyword_version: str :param i...
python
def is_keyword_version_supported( keyword_version, inasafe_version=inasafe_keyword_version): """Check if the keyword version is supported by this InaSAFE version. .. versionadded: 3.3 :param keyword_version: String representation of the keyword version. :type keyword_version: str :param i...
[ "def", "is_keyword_version_supported", "(", "keyword_version", ",", "inasafe_version", "=", "inasafe_keyword_version", ")", ":", "def", "minor_version", "(", "version", ")", ":", "\"\"\"Obtain minor version of a version (x.y)\n :param version: Version string.\n :type ve...
Check if the keyword version is supported by this InaSAFE version. .. versionadded: 3.3 :param keyword_version: String representation of the keyword version. :type keyword_version: str :param inasafe_version: String representation of InaSAFE's version. :type inasafe_version: str :returns: Tr...
[ "Check", "if", "the", "keyword", "version", "is", "supported", "by", "this", "InaSAFE", "version", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L267-L306
train
27,173
inasafe/inasafe
safe/utilities/utilities.py
write_json
def write_json(data, filename): """Custom handler for writing json file in InaSAFE. Criteria: - use indent = 2 - Handle NULL from QGIS :param data: The data that will be written. :type data: dict :param filename: The file name. :type filename: str """ def custom_default(obj):...
python
def write_json(data, filename): """Custom handler for writing json file in InaSAFE. Criteria: - use indent = 2 - Handle NULL from QGIS :param data: The data that will be written. :type data: dict :param filename: The file name. :type filename: str """ def custom_default(obj):...
[ "def", "write_json", "(", "data", ",", "filename", ")", ":", "def", "custom_default", "(", "obj", ")", ":", "if", "obj", "is", "None", "or", "(", "hasattr", "(", "obj", ",", "'isNull'", ")", "and", "obj", ".", "isNull", "(", ")", ")", ":", "return"...
Custom handler for writing json file in InaSAFE. Criteria: - use indent = 2 - Handle NULL from QGIS :param data: The data that will be written. :type data: dict :param filename: The file name. :type filename: str
[ "Custom", "handler", "for", "writing", "json", "file", "in", "InaSAFE", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L309-L329
train
27,174
inasafe/inasafe
safe/utilities/utilities.py
monkey_patch_keywords
def monkey_patch_keywords(layer): """In InaSAFE V4, we do monkey patching for keywords. :param layer: The layer to monkey patch keywords. :type layer: QgsMapLayer """ keyword_io = KeywordIO() try: layer.keywords = keyword_io.read_keywords(layer) except (NoKeywordsFoundError, Metadat...
python
def monkey_patch_keywords(layer): """In InaSAFE V4, we do monkey patching for keywords. :param layer: The layer to monkey patch keywords. :type layer: QgsMapLayer """ keyword_io = KeywordIO() try: layer.keywords = keyword_io.read_keywords(layer) except (NoKeywordsFoundError, Metadat...
[ "def", "monkey_patch_keywords", "(", "layer", ")", ":", "keyword_io", "=", "KeywordIO", "(", ")", "try", ":", "layer", ".", "keywords", "=", "keyword_io", ".", "read_keywords", "(", "layer", ")", "except", "(", "NoKeywordsFoundError", ",", "MetadataReadError", ...
In InaSAFE V4, we do monkey patching for keywords. :param layer: The layer to monkey patch keywords. :type layer: QgsMapLayer
[ "In", "InaSAFE", "V4", "we", "do", "monkey", "patching", "for", "keywords", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L360-L375
train
27,175
inasafe/inasafe
safe/utilities/utilities.py
readable_os_version
def readable_os_version(): """Give a proper name for OS version :return: Proper OS version :rtype: str """ if platform.system() == 'Linux': return _linux_os_release() elif platform.system() == 'Darwin': return ' {version}'.format(version=platform.mac_ver()[0]) elif platform....
python
def readable_os_version(): """Give a proper name for OS version :return: Proper OS version :rtype: str """ if platform.system() == 'Linux': return _linux_os_release() elif platform.system() == 'Darwin': return ' {version}'.format(version=platform.mac_ver()[0]) elif platform....
[ "def", "readable_os_version", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Linux'", ":", "return", "_linux_os_release", "(", ")", "elif", "platform", ".", "system", "(", ")", "==", "'Darwin'", ":", "return", "' {version}'", ".", "forma...
Give a proper name for OS version :return: Proper OS version :rtype: str
[ "Give", "a", "proper", "name", "for", "OS", "version" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L405-L416
train
27,176
inasafe/inasafe
safe/utilities/utilities.py
is_plugin_installed
def is_plugin_installed(name): """Check if a plugin is installed, even if it's not enabled. :param name: Name of the plugin to check. :type name: string :return: If the plugin is installed. :rtype: bool """ for directory in plugin_paths: if isdir(join(directory, name)): ...
python
def is_plugin_installed(name): """Check if a plugin is installed, even if it's not enabled. :param name: Name of the plugin to check. :type name: string :return: If the plugin is installed. :rtype: bool """ for directory in plugin_paths: if isdir(join(directory, name)): ...
[ "def", "is_plugin_installed", "(", "name", ")", ":", "for", "directory", "in", "plugin_paths", ":", "if", "isdir", "(", "join", "(", "directory", ",", "name", ")", ")", ":", "return", "True", "return", "False" ]
Check if a plugin is installed, even if it's not enabled. :param name: Name of the plugin to check. :type name: string :return: If the plugin is installed. :rtype: bool
[ "Check", "if", "a", "plugin", "is", "installed", "even", "if", "it", "s", "not", "enabled", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L419-L431
train
27,177
inasafe/inasafe
safe/utilities/utilities.py
reload_inasafe_modules
def reload_inasafe_modules(module_name=None): """Reload python modules. :param module_name: Specific module name. :type module_name: str """ if not module_name: module_name = 'safe' list_modules = list(sys.modules.keys()) for module in list_modules: if not sys.modules[modul...
python
def reload_inasafe_modules(module_name=None): """Reload python modules. :param module_name: Specific module name. :type module_name: str """ if not module_name: module_name = 'safe' list_modules = list(sys.modules.keys()) for module in list_modules: if not sys.modules[modul...
[ "def", "reload_inasafe_modules", "(", "module_name", "=", "None", ")", ":", "if", "not", "module_name", ":", "module_name", "=", "'safe'", "list_modules", "=", "list", "(", "sys", ".", "modules", ".", "keys", "(", ")", ")", "for", "module", "in", "list_mod...
Reload python modules. :param module_name: Specific module name. :type module_name: str
[ "Reload", "python", "modules", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/utilities.py#L434-L448
train
27,178
inasafe/inasafe
safe/gui/widgets/field_mapping_tab.py
FieldMappingTab.populate_field_list
def populate_field_list(self, excluded_fields=None): """Helper to add field of the layer to the list. :param excluded_fields: List of field that want to be excluded. :type excluded_fields: list """ # Populate fields list if excluded_fields is None: excluded_f...
python
def populate_field_list(self, excluded_fields=None): """Helper to add field of the layer to the list. :param excluded_fields: List of field that want to be excluded. :type excluded_fields: list """ # Populate fields list if excluded_fields is None: excluded_f...
[ "def", "populate_field_list", "(", "self", ",", "excluded_fields", "=", "None", ")", ":", "# Populate fields list", "if", "excluded_fields", "is", "None", ":", "excluded_fields", "=", "[", "]", "self", ".", "field_list", ".", "clear", "(", ")", "for", "field",...
Helper to add field of the layer to the list. :param excluded_fields: List of field that want to be excluded. :type excluded_fields: list
[ "Helper", "to", "add", "field", "of", "the", "layer", "to", "the", "list", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/field_mapping_tab.py#L148-L172
train
27,179
inasafe/inasafe
safe/gui/widgets/field_mapping_tab.py
FieldMappingTab.get_parameter_value
def get_parameter_value(self): """Get parameter of the tab. :returns: Dictionary of parameters by type in this format: {'fields': {}, 'values': {}}. :rtype: dict """ parameters = self.parameter_container.get_parameters(True) field_parameters = {} valu...
python
def get_parameter_value(self): """Get parameter of the tab. :returns: Dictionary of parameters by type in this format: {'fields': {}, 'values': {}}. :rtype: dict """ parameters = self.parameter_container.get_parameters(True) field_parameters = {} valu...
[ "def", "get_parameter_value", "(", "self", ")", ":", "parameters", "=", "self", ".", "parameter_container", ".", "get_parameters", "(", "True", ")", "field_parameters", "=", "{", "}", "value_parameters", "=", "{", "}", "for", "parameter", "in", "parameters", "...
Get parameter of the tab. :returns: Dictionary of parameters by type in this format: {'fields': {}, 'values': {}}. :rtype: dict
[ "Get", "parameter", "of", "the", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/field_mapping_tab.py#L311-L329
train
27,180
inasafe/inasafe
safe/gui/widgets/field_mapping_tab.py
FieldMappingTab.update_footer
def update_footer(self): """Update footer when the field list change.""" field_item = self.field_list.currentItem() if not field_item: self.footer_label.setText('') return field_name = field_item.data(Qt.UserRole) field = self.layer.fields().field(field_...
python
def update_footer(self): """Update footer when the field list change.""" field_item = self.field_list.currentItem() if not field_item: self.footer_label.setText('') return field_name = field_item.data(Qt.UserRole) field = self.layer.fields().field(field_...
[ "def", "update_footer", "(", "self", ")", ":", "field_item", "=", "self", ".", "field_list", ".", "currentItem", "(", ")", "if", "not", "field_item", ":", "self", ".", "footer_label", ".", "setText", "(", "''", ")", "return", "field_name", "=", "field_item...
Update footer when the field list change.
[ "Update", "footer", "when", "the", "field", "list", "change", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/field_mapping_tab.py#L331-L348
train
27,181
inasafe/inasafe
safe/gui/widgets/field_mapping_tab.py
FieldMappingTab.drop_remove
def drop_remove(*args, **kwargs): """Action when we need to remove dropped item. :param *args: Position arguments. :type *args: list :param kwargs: Keywords arguments. :type kwargs: dict """ dropped_item = args[0] field_list = kwargs['field_list'] ...
python
def drop_remove(*args, **kwargs): """Action when we need to remove dropped item. :param *args: Position arguments. :type *args: list :param kwargs: Keywords arguments. :type kwargs: dict """ dropped_item = args[0] field_list = kwargs['field_list'] ...
[ "def", "drop_remove", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dropped_item", "=", "args", "[", "0", "]", "field_list", "=", "kwargs", "[", "'field_list'", "]", "num_duplicate", "=", "0", "for", "i", "in", "range", "(", "field_list", ".", ...
Action when we need to remove dropped item. :param *args: Position arguments. :type *args: list :param kwargs: Keywords arguments. :type kwargs: dict
[ "Action", "when", "we", "need", "to", "remove", "dropped", "item", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/field_mapping_tab.py#L358-L375
train
27,182
inasafe/inasafe
safe/gis/vector/smart_clip.py
smart_clip
def smart_clip(layer_to_clip, mask_layer): """Smart clip a vector layer with another. Issue https://github.com/inasafe/inasafe/issues/3186 :param layer_to_clip: The vector layer to clip. :type layer_to_clip: QgsVectorLayer :param mask_layer: The vector layer to use for clipping. :type mask_la...
python
def smart_clip(layer_to_clip, mask_layer): """Smart clip a vector layer with another. Issue https://github.com/inasafe/inasafe/issues/3186 :param layer_to_clip: The vector layer to clip. :type layer_to_clip: QgsVectorLayer :param mask_layer: The vector layer to use for clipping. :type mask_la...
[ "def", "smart_clip", "(", "layer_to_clip", ",", "mask_layer", ")", ":", "output_layer_name", "=", "smart_clip_steps", "[", "'output_layer_name'", "]", "writer", "=", "create_memory_layer", "(", "output_layer_name", ",", "layer_to_clip", ".", "geometryType", "(", ")", ...
Smart clip a vector layer with another. Issue https://github.com/inasafe/inasafe/issues/3186 :param layer_to_clip: The vector layer to clip. :type layer_to_clip: QgsVectorLayer :param mask_layer: The vector layer to use for clipping. :type mask_layer: QgsVectorLayer :return: The clip vector ...
[ "Smart", "clip", "a", "vector", "layer", "with", "another", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/smart_clip.py#L29-L81
train
27,183
inasafe/inasafe
safe/gui/widgets/message.py
missing_keyword_message
def missing_keyword_message(sender, missing_keyword_exception): """Display an error when there is missing keyword. :param sender: The sender. :type sender: object :param missing_keyword_exception: A KeywordNotFoundError exception. :type missing_keyword_exception: KeywordNotFoundError """ w...
python
def missing_keyword_message(sender, missing_keyword_exception): """Display an error when there is missing keyword. :param sender: The sender. :type sender: object :param missing_keyword_exception: A KeywordNotFoundError exception. :type missing_keyword_exception: KeywordNotFoundError """ w...
[ "def", "missing_keyword_message", "(", "sender", ",", "missing_keyword_exception", ")", ":", "warning_heading", "=", "m", ".", "Heading", "(", "tr", "(", "'Missing Keyword'", ")", ",", "*", "*", "WARNING_STYLE", ")", "warning_message", "=", "tr", "(", "'There is...
Display an error when there is missing keyword. :param sender: The sender. :type sender: object :param missing_keyword_exception: A KeywordNotFoundError exception. :type missing_keyword_exception: KeywordNotFoundError
[ "Display", "an", "error", "when", "there", "is", "missing", "keyword", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L40-L80
train
27,184
inasafe/inasafe
safe/gui/widgets/message.py
conflicting_plugin_message
def conflicting_plugin_message(): """Unfortunately, one plugin is conflicting with InaSAFE. We are displaying a message about this conflict. :returns: Information for the user on how to get started. :rtype: safe.messaging.Message """ message = m.Message() message.add(LOGO_ELEMENT) mess...
python
def conflicting_plugin_message(): """Unfortunately, one plugin is conflicting with InaSAFE. We are displaying a message about this conflict. :returns: Information for the user on how to get started. :rtype: safe.messaging.Message """ message = m.Message() message.add(LOGO_ELEMENT) mess...
[ "def", "conflicting_plugin_message", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "LOGO_ELEMENT", ")", "message", ".", "add", "(", "m", ".", "Heading", "(", "tr", "(", "'Conflicting plugin detected'", ")", ",", ...
Unfortunately, one plugin is conflicting with InaSAFE. We are displaying a message about this conflict. :returns: Information for the user on how to get started. :rtype: safe.messaging.Message
[ "Unfortunately", "one", "plugin", "is", "conflicting", "with", "InaSAFE", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L97-L110
train
27,185
inasafe/inasafe
safe/gui/widgets/message.py
getting_started_message
def getting_started_message(): """Generate a message for initial application state. :returns: Information for the user on how to get started. :rtype: safe.messaging.Message """ message = m.Message() message.add(LOGO_ELEMENT) message.add(m.Heading(tr('Getting started'), **INFO_STYLE)) no...
python
def getting_started_message(): """Generate a message for initial application state. :returns: Information for the user on how to get started. :rtype: safe.messaging.Message """ message = m.Message() message.add(LOGO_ELEMENT) message.add(m.Heading(tr('Getting started'), **INFO_STYLE)) no...
[ "def", "getting_started_message", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "LOGO_ELEMENT", ")", "message", ".", "add", "(", "m", ".", "Heading", "(", "tr", "(", "'Getting started'", ")", ",", "*", "*", ...
Generate a message for initial application state. :returns: Information for the user on how to get started. :rtype: safe.messaging.Message
[ "Generate", "a", "message", "for", "initial", "application", "state", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L113-L160
train
27,186
inasafe/inasafe
safe/gui/widgets/message.py
ready_message
def ready_message(): """Helper to create a message indicating inasafe is ready. :returns Message: A localised message indicating we are ready to run. """ title = m.Heading(tr('Ready'), **PROGRESS_UPDATE_STYLE) notes = m.Paragraph( tr('You can now proceed to run your analysis by clicking the...
python
def ready_message(): """Helper to create a message indicating inasafe is ready. :returns Message: A localised message indicating we are ready to run. """ title = m.Heading(tr('Ready'), **PROGRESS_UPDATE_STYLE) notes = m.Paragraph( tr('You can now proceed to run your analysis by clicking the...
[ "def", "ready_message", "(", ")", ":", "title", "=", "m", ".", "Heading", "(", "tr", "(", "'Ready'", ")", ",", "*", "*", "PROGRESS_UPDATE_STYLE", ")", "notes", "=", "m", ".", "Paragraph", "(", "tr", "(", "'You can now proceed to run your analysis by clicking t...
Helper to create a message indicating inasafe is ready. :returns Message: A localised message indicating we are ready to run.
[ "Helper", "to", "create", "a", "message", "indicating", "inasafe", "is", "ready", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L173-L184
train
27,187
inasafe/inasafe
safe/gui/widgets/message.py
show_keyword_version_message
def show_keyword_version_message(sender, keyword_version, inasafe_version): """Show a message indicating that the keywords version is mismatch .. versionadded: 3.2 :param sender: Sender of the message signal. Default to Any object. :type sender: object :param keyword_version: The version of the l...
python
def show_keyword_version_message(sender, keyword_version, inasafe_version): """Show a message indicating that the keywords version is mismatch .. versionadded: 3.2 :param sender: Sender of the message signal. Default to Any object. :type sender: object :param keyword_version: The version of the l...
[ "def", "show_keyword_version_message", "(", "sender", ",", "keyword_version", ",", "inasafe_version", ")", ":", "LOGGER", ".", "debug", "(", "'Showing Mismatch Version Message'", ")", "message", "=", "generate_input_error_message", "(", "tr", "(", "'Layer Keyword\\'s Vers...
Show a message indicating that the keywords version is mismatch .. versionadded: 3.2 :param sender: Sender of the message signal. Default to Any object. :type sender: object :param keyword_version: The version of the layer's keywords :type keyword_version: str :param inasafe_version: The ver...
[ "Show", "a", "message", "indicating", "that", "the", "keywords", "version", "is", "mismatch" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L187-L223
train
27,188
inasafe/inasafe
safe/gui/widgets/message.py
show_keywords_need_review_message
def show_keywords_need_review_message(sender, message=None): """Show a message keywords are not adequate to run an analysis. .. versionadded: 4.0 :param sender: Sender of the message signal. Default to Any object. :type sender: object :param message: Additional message to display. :type messa...
python
def show_keywords_need_review_message(sender, message=None): """Show a message keywords are not adequate to run an analysis. .. versionadded: 4.0 :param sender: Sender of the message signal. Default to Any object. :type sender: object :param message: Additional message to display. :type messa...
[ "def", "show_keywords_need_review_message", "(", "sender", ",", "message", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "'Showing incorrect keywords for v4 message'", ")", "message", "=", "generate_input_error_message", "(", "tr", "(", "'Layer Keywords Outdated:'",...
Show a message keywords are not adequate to run an analysis. .. versionadded: 4.0 :param sender: Sender of the message signal. Default to Any object. :type sender: object :param message: Additional message to display. :type message: str .. note:: The print button will be disabled if this met...
[ "Show", "a", "message", "keywords", "are", "not", "adequate", "to", "run", "an", "analysis", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L227-L255
train
27,189
inasafe/inasafe
safe/gui/widgets/message.py
generate_input_error_message
def generate_input_error_message(header, text): """Generate an error message with a header and a text. :param header: The header of the message. :type header: basestring :param text: The text of the message. :type text: m.Paragraph :return: The error message ready to be displayed in the dock....
python
def generate_input_error_message(header, text): """Generate an error message with a header and a text. :param header: The header of the message. :type header: basestring :param text: The text of the message. :type text: m.Paragraph :return: The error message ready to be displayed in the dock....
[ "def", "generate_input_error_message", "(", "header", ",", "text", ")", ":", "report", "=", "m", ".", "Message", "(", ")", "report", ".", "add", "(", "LOGO_ELEMENT", ")", "report", ".", "add", "(", "m", ".", "Heading", "(", "header", ",", "*", "*", "...
Generate an error message with a header and a text. :param header: The header of the message. :type header: basestring :param text: The text of the message. :type text: m.Paragraph :return: The error message ready to be displayed in the dock. :rtype: m.Message
[ "Generate", "an", "error", "message", "with", "a", "header", "and", "a", "text", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L284-L300
train
27,190
inasafe/inasafe
safe/gui/widgets/message.py
enable_messaging
def enable_messaging(message_viewer, sender=dispatcher.Any): """Set up the dispatcher for messaging. :param message_viewer: A message viewer to show the message. :type message_viewer: MessageViewer :param sender: Sender of the message signal. Default to Any object. :type sender: object """ ...
python
def enable_messaging(message_viewer, sender=dispatcher.Any): """Set up the dispatcher for messaging. :param message_viewer: A message viewer to show the message. :type message_viewer: MessageViewer :param sender: Sender of the message signal. Default to Any object. :type sender: object """ ...
[ "def", "enable_messaging", "(", "message_viewer", ",", "sender", "=", "dispatcher", ".", "Any", ")", ":", "# Set up dispatcher for dynamic messages", "# Dynamic messages will not clear the message queue so will be appended", "# to existing user messages", "LOGGER", ".", "debug", ...
Set up the dispatcher for messaging. :param message_viewer: A message viewer to show the message. :type message_viewer: MessageViewer :param sender: Sender of the message signal. Default to Any object. :type sender: object
[ "Set", "up", "the", "dispatcher", "for", "messaging", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message.py#L303-L334
train
27,191
inasafe/inasafe
safe/gui/tools/help/options_help.py
options_help
def options_help(): """Help message for options dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content()) return me...
python
def options_help(): """Help message for options dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content()) return me...
[ "def", "options_help", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "heading", "(", ")", ")", "message", ".", "add", "(", "content", "(", ...
Help message for options dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message
[ "Help", "message", "for", "options", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/options_help.py#L19-L32
train
27,192
inasafe/inasafe
safe/report/extractors/minimum_needs.py
minimum_needs_extractor
def minimum_needs_extractor(impact_report, component_metadata): """Extracting minimum needs of the impact layer. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param component...
python
def minimum_needs_extractor(impact_report, component_metadata): """Extracting minimum needs of the impact layer. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param component...
[ "def", "minimum_needs_extractor", "(", "impact_report", ",", "component_metadata", ")", ":", "context", "=", "{", "}", "extra_args", "=", "component_metadata", ".", "extra_args", "analysis_layer", "=", "impact_report", ".", "analysis", "analysis_keywords", "=", "analy...
Extracting minimum needs of the impact layer. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param component_metadata: the component metadata. Used to obtain information a...
[ "Extracting", "minimum", "needs", "of", "the", "impact", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/minimum_needs.py#L20-L149
train
27,193
inasafe/inasafe
safe/messaging/item/bulleted_list.py
BulletedList.to_text
def to_text(self): """Render a Text MessageElement as plain text. :returns: The plain text representation of the Text MessageElement. :rtype: basestring """ if self.items is None: return else: text = '' for item in self.items: ...
python
def to_text(self): """Render a Text MessageElement as plain text. :returns: The plain text representation of the Text MessageElement. :rtype: basestring """ if self.items is None: return else: text = '' for item in self.items: ...
[ "def", "to_text", "(", "self", ")", ":", "if", "self", ".", "items", "is", "None", ":", "return", "else", ":", "text", "=", "''", "for", "item", "in", "self", ".", "items", ":", "text", "+=", "' - %s\\n'", "%", "item", ".", "to_text", "(", ")", "...
Render a Text MessageElement as plain text. :returns: The plain text representation of the Text MessageElement. :rtype: basestring
[ "Render", "a", "Text", "MessageElement", "as", "plain", "text", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/bulleted_list.py#L63-L76
train
27,194
inasafe/inasafe
safe/utilities/settings.py
deep_convert_dict
def deep_convert_dict(value): """Converts any OrderedDict elements in a value to ordinary dictionaries, safe for storage in QSettings :param value: value to convert :type value: Union[dict,OrderedDict] :return: dict """ to_ret = value if isinstance(value, OrderedDict): to_ret =...
python
def deep_convert_dict(value): """Converts any OrderedDict elements in a value to ordinary dictionaries, safe for storage in QSettings :param value: value to convert :type value: Union[dict,OrderedDict] :return: dict """ to_ret = value if isinstance(value, OrderedDict): to_ret =...
[ "def", "deep_convert_dict", "(", "value", ")", ":", "to_ret", "=", "value", "if", "isinstance", "(", "value", ",", "OrderedDict", ")", ":", "to_ret", "=", "dict", "(", "value", ")", "try", ":", "for", "k", ",", "v", "in", "to_ret", ".", "items", "(",...
Converts any OrderedDict elements in a value to ordinary dictionaries, safe for storage in QSettings :param value: value to convert :type value: Union[dict,OrderedDict] :return: dict
[ "Converts", "any", "OrderedDict", "elements", "in", "a", "value", "to", "ordinary", "dictionaries", "safe", "for", "storage", "in", "QSettings" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L20-L39
train
27,195
inasafe/inasafe
safe/utilities/settings.py
set_general_setting
def set_general_setting(key, value, qsettings=None): """Set value to QSettings based on key. :param key: Unique key for setting. :type key: basestring :param value: Value to be saved. :type value: QVariant :param qsettings: A custom QSettings to use. If it's not defined, it will use t...
python
def set_general_setting(key, value, qsettings=None): """Set value to QSettings based on key. :param key: Unique key for setting. :type key: basestring :param value: Value to be saved. :type value: QVariant :param qsettings: A custom QSettings to use. If it's not defined, it will use t...
[ "def", "set_general_setting", "(", "key", ",", "value", ",", "qsettings", "=", "None", ")", ":", "if", "not", "qsettings", ":", "qsettings", "=", "QSettings", "(", ")", "qsettings", ".", "setValue", "(", "key", ",", "deep_convert_dict", "(", "value", ")", ...
Set value to QSettings based on key. :param key: Unique key for setting. :type key: basestring :param value: Value to be saved. :type value: QVariant :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis.PyQt.QtCore.QSetti...
[ "Set", "value", "to", "QSettings", "based", "on", "key", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L42-L58
train
27,196
inasafe/inasafe
safe/utilities/settings.py
general_setting
def general_setting(key, default=None, expected_type=None, qsettings=None): """Helper function to get a value from settings. :param key: Unique key for setting. :type key: basestring :param default: The default value in case of the key is not found or there is an error. :type default: base...
python
def general_setting(key, default=None, expected_type=None, qsettings=None): """Helper function to get a value from settings. :param key: Unique key for setting. :type key: basestring :param default: The default value in case of the key is not found or there is an error. :type default: base...
[ "def", "general_setting", "(", "key", ",", "default", "=", "None", ",", "expected_type", "=", "None", ",", "qsettings", "=", "None", ")", ":", "if", "qsettings", "is", "None", ":", "qsettings", "=", "QSettings", "(", ")", "try", ":", "if", "isinstance", ...
Helper function to get a value from settings. :param key: Unique key for setting. :type key: basestring :param default: The default value in case of the key is not found or there is an error. :type default: basestring, None, boolean, int, float :param expected_type: The type of object exp...
[ "Helper", "function", "to", "get", "a", "value", "from", "settings", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L61-L97
train
27,197
inasafe/inasafe
safe/utilities/settings.py
set_setting
def set_setting(key, value, qsettings=None): """Set value to QSettings based on key in InaSAFE scope. :param key: Unique key for setting. :type key: basestring :param value: Value to be saved. :type value: QVariant :param qsettings: A custom QSettings to use. If it's not defined, it will ...
python
def set_setting(key, value, qsettings=None): """Set value to QSettings based on key in InaSAFE scope. :param key: Unique key for setting. :type key: basestring :param value: Value to be saved. :type value: QVariant :param qsettings: A custom QSettings to use. If it's not defined, it will ...
[ "def", "set_setting", "(", "key", ",", "value", ",", "qsettings", "=", "None", ")", ":", "full_key", "=", "'%s/%s'", "%", "(", "APPLICATION_NAME", ",", "key", ")", "set_general_setting", "(", "full_key", ",", "value", ",", "qsettings", ")" ]
Set value to QSettings based on key in InaSAFE scope. :param key: Unique key for setting. :type key: basestring :param value: Value to be saved. :type value: QVariant :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis.P...
[ "Set", "value", "to", "QSettings", "based", "on", "key", "in", "InaSAFE", "scope", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L116-L130
train
27,198
inasafe/inasafe
safe/utilities/settings.py
setting
def setting(key, default=None, expected_type=None, qsettings=None): """Helper function to get a value from settings under InaSAFE scope. :param key: Unique key for setting. :type key: basestring :param default: The default value in case of the key is not found or there is an error. :type d...
python
def setting(key, default=None, expected_type=None, qsettings=None): """Helper function to get a value from settings under InaSAFE scope. :param key: Unique key for setting. :type key: basestring :param default: The default value in case of the key is not found or there is an error. :type d...
[ "def", "setting", "(", "key", ",", "default", "=", "None", ",", "expected_type", "=", "None", ",", "qsettings", "=", "None", ")", ":", "if", "default", "is", "None", ":", "default", "=", "inasafe_default_settings", ".", "get", "(", "key", ",", "None", ...
Helper function to get a value from settings under InaSAFE scope. :param key: Unique key for setting. :type key: basestring :param default: The default value in case of the key is not found or there is an error. :type default: basestring, None, boolean, int, float :param expected_type: Th...
[ "Helper", "function", "to", "get", "a", "value", "from", "settings", "under", "InaSAFE", "scope", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L133-L156
train
27,199