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/messaging/message.py
Message.to_html
def to_html( self, suppress_newlines=False, in_div_flag=False): # pylint: disable=W0221 """Render a MessageElement as html. :param suppress_newlines: Whether to suppress any newlines in the output. If this option is enabled, the entire html output will b...
python
def to_html( self, suppress_newlines=False, in_div_flag=False): # pylint: disable=W0221 """Render a MessageElement as html. :param suppress_newlines: Whether to suppress any newlines in the output. If this option is enabled, the entire html output will b...
[ "def", "to_html", "(", "self", ",", "suppress_newlines", "=", "False", ",", "in_div_flag", "=", "False", ")", ":", "# pylint: disable=W0221", "if", "in_div_flag", "or", "self", ".", "in_div_flag", ":", "message", "=", "'<div %s>'", "%", "self", ".", "html_attr...
Render a MessageElement as html. :param suppress_newlines: Whether to suppress any newlines in the output. If this option is enabled, the entire html output will be rendered on a single line. :type suppress_newlines: bool :param in_div_flag: Whether the message should b...
[ "Render", "a", "MessageElement", "as", "html", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/message.py#L134-L176
train
26,900
inasafe/inasafe
safe/common/parameters/validators.py
validate_sum
def validate_sum(parameter_container, validation_message, **kwargs): """Validate the sum of parameter value's. :param parameter_container: The container that use this validator. :type parameter_container: ParameterContainer :param validation_message: The message if there is validation error. :type...
python
def validate_sum(parameter_container, validation_message, **kwargs): """Validate the sum of parameter value's. :param parameter_container: The container that use this validator. :type parameter_container: ParameterContainer :param validation_message: The message if there is validation error. :type...
[ "def", "validate_sum", "(", "parameter_container", ",", "validation_message", ",", "*", "*", "kwargs", ")", ":", "parameters", "=", "parameter_container", ".", "get_parameters", "(", "False", ")", "values", "=", "[", "]", "for", "parameter", "in", "parameters", ...
Validate the sum of parameter value's. :param parameter_container: The container that use this validator. :type parameter_container: ParameterContainer :param validation_message: The message if there is validation error. :type validation_message: str :param kwargs: Keywords Argument. :type kw...
[ "Validate", "the", "sum", "of", "parameter", "value", "s", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/validators.py#L16-L62
train
26,901
inasafe/inasafe
safe/gui/tools/wizard/step_kw15_layermode.py
StepKwLayerMode.on_lstLayerModes_itemSelectionChanged
def on_lstLayerModes_itemSelectionChanged(self): """Update layer mode description label and unit widgets. .. note:: This is an automatic Qt slot executed when the subcategory selection changes. """ self.clear_further_steps() # Set widgets layer_mode = self.sel...
python
def on_lstLayerModes_itemSelectionChanged(self): """Update layer mode description label and unit widgets. .. note:: This is an automatic Qt slot executed when the subcategory selection changes. """ self.clear_further_steps() # Set widgets layer_mode = self.sel...
[ "def", "on_lstLayerModes_itemSelectionChanged", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "# Set widgets", "layer_mode", "=", "self", ".", "selected_layermode", "(", ")", "# Exit if no selection", "if", "not", "layer_mode", ":", "self", "....
Update layer mode description label and unit widgets. .. note:: This is an automatic Qt slot executed when the subcategory selection changes.
[ "Update", "layer", "mode", "description", "label", "and", "unit", "widgets", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw15_layermode.py#L71-L87
train
26,902
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_calculator_dialog.py
NeedsCalculatorDialog.update_button_status
def update_button_status(self): """Function to enable or disable the Ok button. """ # enable/disable ok button if len(self.displaced.currentField()) > 0: self.button_box.button( QtWidgets.QDialogButtonBox.Ok).setEnabled(True) else: self.but...
python
def update_button_status(self): """Function to enable or disable the Ok button. """ # enable/disable ok button if len(self.displaced.currentField()) > 0: self.button_box.button( QtWidgets.QDialogButtonBox.Ok).setEnabled(True) else: self.but...
[ "def", "update_button_status", "(", "self", ")", ":", "# enable/disable ok button", "if", "len", "(", "self", ".", "displaced", ".", "currentField", "(", ")", ")", ">", "0", ":", "self", ".", "button_box", ".", "button", "(", "QtWidgets", ".", "QDialogButton...
Function to enable or disable the Ok button.
[ "Function", "to", "enable", "or", "disable", "the", "Ok", "button", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_calculator_dialog.py#L103-L112
train
26,903
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_calculator_dialog.py
NeedsCalculatorDialog.minimum_needs
def minimum_needs(self, input_layer): """Compute minimum needs given a layer and a column containing pop. :param input_layer: Vector layer assumed to contain population counts. :type input_layer: QgsVectorLayer :returns: A tuple containing True and the vector layer if ...
python
def minimum_needs(self, input_layer): """Compute minimum needs given a layer and a column containing pop. :param input_layer: Vector layer assumed to contain population counts. :type input_layer: QgsVectorLayer :returns: A tuple containing True and the vector layer if ...
[ "def", "minimum_needs", "(", "self", ",", "input_layer", ")", ":", "# Create a new layer for output layer", "output_layer", "=", "self", ".", "prepare_new_layer", "(", "input_layer", ")", "# count each minimum needs for every features", "for", "needs", "in", "minimum_needs_...
Compute minimum needs given a layer and a column containing pop. :param input_layer: Vector layer assumed to contain population counts. :type input_layer: QgsVectorLayer :returns: A tuple containing True and the vector layer if post processor success. Or False and...
[ "Compute", "minimum", "needs", "given", "a", "layer", "and", "a", "column", "containing", "pop", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_calculator_dialog.py#L114-L142
train
26,904
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_calculator_dialog.py
NeedsCalculatorDialog.prepare_new_layer
def prepare_new_layer(self, input_layer): """Prepare new layer for the output layer. :param input_layer: Vector layer. :type input_layer: QgsVectorLayer :return: New memory layer duplicated from input_layer. :rtype: QgsVectorLayer """ # create memory layer ...
python
def prepare_new_layer(self, input_layer): """Prepare new layer for the output layer. :param input_layer: Vector layer. :type input_layer: QgsVectorLayer :return: New memory layer duplicated from input_layer. :rtype: QgsVectorLayer """ # create memory layer ...
[ "def", "prepare_new_layer", "(", "self", ",", "input_layer", ")", ":", "# create memory layer", "output_layer_name", "=", "os", ".", "path", ".", "splitext", "(", "input_layer", ".", "name", "(", ")", ")", "[", "0", "]", "output_layer_name", "=", "unique_filen...
Prepare new layer for the output layer. :param input_layer: Vector layer. :type input_layer: QgsVectorLayer :return: New memory layer duplicated from input_layer. :rtype: QgsVectorLayer
[ "Prepare", "new", "layer", "for", "the", "output", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_calculator_dialog.py#L144-L188
train
26,905
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_calculator_dialog.py
NeedsCalculatorDialog.accept
def accept(self): """Process the layer and field and generate a new layer. .. note:: This is called on OK click. """ # run minimum needs calculator try: success, self.result_layer = ( self.minimum_needs(self.layer.currentLayer())) if not ...
python
def accept(self): """Process the layer and field and generate a new layer. .. note:: This is called on OK click. """ # run minimum needs calculator try: success, self.result_layer = ( self.minimum_needs(self.layer.currentLayer())) if not ...
[ "def", "accept", "(", "self", ")", ":", "# run minimum needs calculator", "try", ":", "success", ",", "self", ".", "result_layer", "=", "(", "self", ".", "minimum_needs", "(", "self", ".", "layer", ".", "currentLayer", "(", ")", ")", ")", "if", "not", "s...
Process the layer and field and generate a new layer. .. note:: This is called on OK click.
[ "Process", "the", "layer", "and", "field", "and", "generate", "a", "new", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_calculator_dialog.py#L190-L245
train
26,906
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.setup_and_run_analysis
def setup_and_run_analysis(self): """Execute analysis after the tab is displayed. Please check the code in dock.py accept(). It should follow approximately the same code. """ self.show_busy() # Read user's settings self.read_settings() # Prepare impact fu...
python
def setup_and_run_analysis(self): """Execute analysis after the tab is displayed. Please check the code in dock.py accept(). It should follow approximately the same code. """ self.show_busy() # Read user's settings self.read_settings() # Prepare impact fu...
[ "def", "setup_and_run_analysis", "(", "self", ")", ":", "self", ".", "show_busy", "(", ")", "# Read user's settings", "self", ".", "read_settings", "(", ")", "# Prepare impact function from wizard dialog user input", "self", ".", "impact_function", "=", "self", ".", "...
Execute analysis after the tab is displayed. Please check the code in dock.py accept(). It should follow approximately the same code.
[ "Execute", "analysis", "after", "the", "tab", "is", "displayed", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L125-L217
train
26,907
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.set_widgets
def set_widgets(self): """Set widgets on the Progress tab.""" self.progress_bar.setValue(0) self.results_webview.setHtml('') self.pbnReportWeb.hide() self.pbnReportPDF.hide() self.pbnReportComposer.hide() self.lblAnalysisStatus.setText(tr('Running analysis...'))
python
def set_widgets(self): """Set widgets on the Progress tab.""" self.progress_bar.setValue(0) self.results_webview.setHtml('') self.pbnReportWeb.hide() self.pbnReportPDF.hide() self.pbnReportComposer.hide() self.lblAnalysisStatus.setText(tr('Running analysis...'))
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "progress_bar", ".", "setValue", "(", "0", ")", "self", ".", "results_webview", ".", "setHtml", "(", "''", ")", "self", ".", "pbnReportWeb", ".", "hide", "(", ")", "self", ".", "pbnReportPDF", "...
Set widgets on the Progress tab.
[ "Set", "widgets", "on", "the", "Progress", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L219-L226
train
26,908
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.read_settings
def read_settings(self): """Set the IF state from QSettings.""" extent = setting('user_extent', None, str) if extent: extent = QgsGeometry.fromWkt(extent) if not extent.isGeosValid(): extent = None crs = setting('user_extent_crs', None, str) ...
python
def read_settings(self): """Set the IF state from QSettings.""" extent = setting('user_extent', None, str) if extent: extent = QgsGeometry.fromWkt(extent) if not extent.isGeosValid(): extent = None crs = setting('user_extent_crs', None, str) ...
[ "def", "read_settings", "(", "self", ")", ":", "extent", "=", "setting", "(", "'user_extent'", ",", "None", ",", "str", ")", "if", "extent", ":", "extent", "=", "QgsGeometry", ".", "fromWkt", "(", "extent", ")", "if", "not", "extent", ".", "isGeosValid",...
Set the IF state from QSettings.
[ "Set", "the", "IF", "state", "from", "QSettings", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L228-L252
train
26,909
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.prepare_impact_function
def prepare_impact_function(self): """Create analysis as a representation of current situation of IFCW.""" # Impact Functions impact_function = ImpactFunction() impact_function.callback = self.progress_callback # Layers impact_function.hazard = self.parent.hazard_layer ...
python
def prepare_impact_function(self): """Create analysis as a representation of current situation of IFCW.""" # Impact Functions impact_function = ImpactFunction() impact_function.callback = self.progress_callback # Layers impact_function.hazard = self.parent.hazard_layer ...
[ "def", "prepare_impact_function", "(", "self", ")", ":", "# Impact Functions", "impact_function", "=", "ImpactFunction", "(", ")", "impact_function", ".", "callback", "=", "self", ".", "progress_callback", "# Layers", "impact_function", ".", "hazard", "=", "self", "...
Create analysis as a representation of current situation of IFCW.
[ "Create", "analysis", "as", "a", "representation", "of", "current", "situation", "of", "IFCW", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L254-L291
train
26,910
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.setup_gui_analysis_done
def setup_gui_analysis_done(self): """Helper method to setup gui if analysis is done.""" self.progress_bar.hide() self.lblAnalysisStatus.setText(tr('Analysis done.')) self.pbnReportWeb.show() self.pbnReportPDF.show() # self.pbnReportComposer.show() # Hide until it works ...
python
def setup_gui_analysis_done(self): """Helper method to setup gui if analysis is done.""" self.progress_bar.hide() self.lblAnalysisStatus.setText(tr('Analysis done.')) self.pbnReportWeb.show() self.pbnReportPDF.show() # self.pbnReportComposer.show() # Hide until it works ...
[ "def", "setup_gui_analysis_done", "(", "self", ")", ":", "self", ".", "progress_bar", ".", "hide", "(", ")", "self", ".", "lblAnalysisStatus", ".", "setText", "(", "tr", "(", "'Analysis done.'", ")", ")", "self", ".", "pbnReportWeb", ".", "show", "(", ")",...
Helper method to setup gui if analysis is done.
[ "Helper", "method", "to", "setup", "gui", "if", "analysis", "is", "done", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L293-L300
train
26,911
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.show_busy
def show_busy(self): """Lock buttons and enable the busy cursor.""" self.progress_bar.show() self.parent.pbnNext.setEnabled(False) self.parent.pbnBack.setEnabled(False) self.parent.pbnCancel.setEnabled(False) self.parent.repaint() enable_busy_cursor() QgsA...
python
def show_busy(self): """Lock buttons and enable the busy cursor.""" self.progress_bar.show() self.parent.pbnNext.setEnabled(False) self.parent.pbnBack.setEnabled(False) self.parent.pbnCancel.setEnabled(False) self.parent.repaint() enable_busy_cursor() QgsA...
[ "def", "show_busy", "(", "self", ")", ":", "self", ".", "progress_bar", ".", "show", "(", ")", "self", ".", "parent", ".", "pbnNext", ".", "setEnabled", "(", "False", ")", "self", ".", "parent", ".", "pbnBack", ".", "setEnabled", "(", "False", ")", "...
Lock buttons and enable the busy cursor.
[ "Lock", "buttons", "and", "enable", "the", "busy", "cursor", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L302-L310
train
26,912
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.hide_busy
def hide_busy(self): """Unlock buttons A helper function to indicate processing is done.""" self.progress_bar.hide() self.parent.pbnNext.setEnabled(True) self.parent.pbnBack.setEnabled(True) self.parent.pbnCancel.setEnabled(True) self.parent.repaint() disable_busy...
python
def hide_busy(self): """Unlock buttons A helper function to indicate processing is done.""" self.progress_bar.hide() self.parent.pbnNext.setEnabled(True) self.parent.pbnBack.setEnabled(True) self.parent.pbnCancel.setEnabled(True) self.parent.repaint() disable_busy...
[ "def", "hide_busy", "(", "self", ")", ":", "self", ".", "progress_bar", ".", "hide", "(", ")", "self", ".", "parent", ".", "pbnNext", ".", "setEnabled", "(", "True", ")", "self", ".", "parent", ".", "pbnBack", ".", "setEnabled", "(", "True", ")", "se...
Unlock buttons A helper function to indicate processing is done.
[ "Unlock", "buttons", "A", "helper", "function", "to", "indicate", "processing", "is", "done", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L312-L319
train
26,913
inasafe/inasafe
safe/gui/tools/wizard/step_fc90_analysis.py
StepFcAnalysis.progress_callback
def progress_callback(self, current_value, maximum_value, message=None): """GUI based callback implementation for showing progress. :param current_value: Current progress. :type current_value: int :param maximum_value: Maximum range (point at which task is complete. :type maxim...
python
def progress_callback(self, current_value, maximum_value, message=None): """GUI based callback implementation for showing progress. :param current_value: Current progress. :type current_value: int :param maximum_value: Maximum range (point at which task is complete. :type maxim...
[ "def", "progress_callback", "(", "self", ",", "current_value", ",", "maximum_value", ",", "message", "=", "None", ")", ":", "report", "=", "m", ".", "Message", "(", ")", "report", ".", "add", "(", "LOGO_ELEMENT", ")", "report", ".", "add", "(", "m", "....
GUI based callback implementation for showing progress. :param current_value: Current progress. :type current_value: int :param maximum_value: Maximum range (point at which task is complete. :type maximum_value: int :param message: Optional message dictionary to containing con...
[ "GUI", "based", "callback", "implementation", "for", "showing", "progress", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc90_analysis.py#L321-L346
train
26,914
inasafe/inasafe
extras/swap_gml_coords.py
swap_pairs
def swap_pairs(line, starttag=position_tag): """Swap coordinate pairs Inputs line: gml line assumed to contain pairs of coordinates ordered as latitude, longitude starttag: tag marking the start of the coordinate pairs. """ endtag = starttag.replace('<', '</') index ...
python
def swap_pairs(line, starttag=position_tag): """Swap coordinate pairs Inputs line: gml line assumed to contain pairs of coordinates ordered as latitude, longitude starttag: tag marking the start of the coordinate pairs. """ endtag = starttag.replace('<', '</') index ...
[ "def", "swap_pairs", "(", "line", ",", "starttag", "=", "position_tag", ")", ":", "endtag", "=", "starttag", ".", "replace", "(", "'<'", ",", "'</'", ")", "index", "=", "line", ".", "find", "(", "starttag", ")", "if", "index", "<", "0", ":", "msg", ...
Swap coordinate pairs Inputs line: gml line assumed to contain pairs of coordinates ordered as latitude, longitude starttag: tag marking the start of the coordinate pairs.
[ "Swap", "coordinate", "pairs" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/swap_gml_coords.py#L20-L70
train
26,915
inasafe/inasafe
extras/swap_gml_coords.py
swap_coords
def swap_coords(filename): """Swap lat and lon in filename """ # Read from input file fid = open(filename, 'r') lines = fid.readlines() fid.close() # Open output file basename, ext = os.path.splitext(filename) fid = open(basename + '_converted' + ext, 'w') # Report N = len...
python
def swap_coords(filename): """Swap lat and lon in filename """ # Read from input file fid = open(filename, 'r') lines = fid.readlines() fid.close() # Open output file basename, ext = os.path.splitext(filename) fid = open(basename + '_converted' + ext, 'w') # Report N = len...
[ "def", "swap_coords", "(", "filename", ")", ":", "# Read from input file", "fid", "=", "open", "(", "filename", ",", "'r'", ")", "lines", "=", "fid", ".", "readlines", "(", ")", "fid", ".", "close", "(", ")", "# Open output file", "basename", ",", "ext", ...
Swap lat and lon in filename
[ "Swap", "lat", "and", "lon", "in", "filename" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/swap_gml_coords.py#L73-L107
train
26,916
inasafe/inasafe
safe/gui/tools/wizard/step_kw25_classification.py
StepKwClassification.classifications_for_layer
def classifications_for_layer(self): """Return a list of valid classifications for a layer. :returns: A list where each value represents a valid classification. :rtype: list """ subcategory_key = self.parent.step_kw_subcategory.\ selected_subcategory()['key'] ...
python
def classifications_for_layer(self): """Return a list of valid classifications for a layer. :returns: A list where each value represents a valid classification. :rtype: list """ subcategory_key = self.parent.step_kw_subcategory.\ selected_subcategory()['key'] ...
[ "def", "classifications_for_layer", "(", "self", ")", ":", "subcategory_key", "=", "self", ".", "parent", ".", "step_kw_subcategory", ".", "selected_subcategory", "(", ")", "[", "'key'", "]", "layer_purpose", "=", "self", ".", "parent", ".", "step_kw_purpose", "...
Return a list of valid classifications for a layer. :returns: A list where each value represents a valid classification. :rtype: list
[ "Return", "a", "list", "of", "valid", "classifications", "for", "a", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw25_classification.py#L58-L87
train
26,917
inasafe/inasafe
safe/gui/tools/wizard/step_kw25_classification.py
StepKwClassification.on_lstClassifications_itemSelectionChanged
def on_lstClassifications_itemSelectionChanged(self): """Update classification description label and unlock the Next button. .. note:: This is an automatic Qt slot executed when the field selection changes. """ self.clear_further_steps() classification = self.selected...
python
def on_lstClassifications_itemSelectionChanged(self): """Update classification description label and unlock the Next button. .. note:: This is an automatic Qt slot executed when the field selection changes. """ self.clear_further_steps() classification = self.selected...
[ "def", "on_lstClassifications_itemSelectionChanged", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "classification", "=", "self", ".", "selected_classification", "(", ")", "# Exit if no selection", "if", "not", "classification", ":", "return", "...
Update classification description label and unlock the Next button. .. note:: This is an automatic Qt slot executed when the field selection changes.
[ "Update", "classification", "description", "label", "and", "unlock", "the", "Next", "button", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw25_classification.py#L89-L103
train
26,918
inasafe/inasafe
safe/gui/tools/wizard/step_kw25_classification.py
StepKwClassification.selected_classification
def selected_classification(self): """Obtain the classification selected by user. :returns: Metadata of the selected classification. :rtype: dict, None """ item = self.lstClassifications.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) ...
python
def selected_classification(self): """Obtain the classification selected by user. :returns: Metadata of the selected classification. :rtype: dict, None """ item = self.lstClassifications.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) ...
[ "def", "selected_classification", "(", "self", ")", ":", "item", "=", "self", ".", "lstClassifications", ".", "currentItem", "(", ")", "try", ":", "return", "definition", "(", "item", ".", "data", "(", "QtCore", ".", "Qt", ".", "UserRole", ")", ")", "exc...
Obtain the classification selected by user. :returns: Metadata of the selected classification. :rtype: dict, None
[ "Obtain", "the", "classification", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw25_classification.py#L105-L115
train
26,919
inasafe/inasafe
safe/gui/tools/wizard/step_kw25_classification.py
StepKwClassification.set_widgets
def set_widgets(self): """Set widgets on the Classification tab.""" self.clear_further_steps() purpose = self.parent.step_kw_purpose.selected_purpose()['name'] subcategory = self.parent.step_kw_subcategory.\ selected_subcategory()['name'] self.lstClassifications.clear...
python
def set_widgets(self): """Set widgets on the Classification tab.""" self.clear_further_steps() purpose = self.parent.step_kw_purpose.selected_purpose()['name'] subcategory = self.parent.step_kw_subcategory.\ selected_subcategory()['name'] self.lstClassifications.clear...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "purpose", "=", "self", ".", "parent", ".", "step_kw_purpose", ".", "selected_purpose", "(", ")", "[", "'name'", "]", "subcategory", "=", "self", ".", "parent", ".",...
Set widgets on the Classification tab.
[ "Set", "widgets", "on", "the", "Classification", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw25_classification.py#L122-L154
train
26,920
inasafe/inasafe
safe/utilities/geonode/upload_layer_requests.py
siblings_files
def siblings_files(path): """Return a list of sibling files available.""" file_basename, extension = splitext(path) main_extension = extension.lower() files = {} if extension.lower() in list(extension_siblings.keys()): for text_extension in list(extension_siblings[main_extension].keys()): ...
python
def siblings_files(path): """Return a list of sibling files available.""" file_basename, extension = splitext(path) main_extension = extension.lower() files = {} if extension.lower() in list(extension_siblings.keys()): for text_extension in list(extension_siblings[main_extension].keys()): ...
[ "def", "siblings_files", "(", "path", ")", ":", "file_basename", ",", "extension", "=", "splitext", "(", "path", ")", "main_extension", "=", "extension", ".", "lower", "(", ")", "files", "=", "{", "}", "if", "extension", ".", "lower", "(", ")", "in", "...
Return a list of sibling files available.
[ "Return", "a", "list", "of", "sibling", "files", "available", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/geonode/upload_layer_requests.py#L66-L81
train
26,921
inasafe/inasafe
safe/utilities/geonode/upload_layer_requests.py
pretty_print_post
def pretty_print_post(req): """Helper to print a "prepared" query. Useful to debug a POST query. However pay attention at the formatting used in this function because it is programmed to be pretty printed and may differ from the actual request. """ print(('{}\n{}\n{}\n\n{}'.format( '---...
python
def pretty_print_post(req): """Helper to print a "prepared" query. Useful to debug a POST query. However pay attention at the formatting used in this function because it is programmed to be pretty printed and may differ from the actual request. """ print(('{}\n{}\n{}\n\n{}'.format( '---...
[ "def", "pretty_print_post", "(", "req", ")", ":", "print", "(", "(", "'{}\\n{}\\n{}\\n\\n{}'", ".", "format", "(", "'-----------START-----------'", ",", "req", ".", "method", "+", "' '", "+", "req", ".", "url", ",", "'\\n'", ".", "join", "(", "'{}: {}'", "...
Helper to print a "prepared" query. Useful to debug a POST query. However pay attention at the formatting used in this function because it is programmed to be pretty printed and may differ from the actual request.
[ "Helper", "to", "print", "a", "prepared", "query", ".", "Useful", "to", "debug", "a", "POST", "query", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/geonode/upload_layer_requests.py#L84-L96
train
26,922
inasafe/inasafe
safe/utilities/geonode/upload_layer_requests.py
login_user
def login_user(server, login, password): """Get the login session. :param server: The Geonode server URL. :type server: basestring :param login: The login to use on Geonode. :type login: basestring :param password: The password to use on Geonode. :type password: basestring """ log...
python
def login_user(server, login, password): """Get the login session. :param server: The Geonode server URL. :type server: basestring :param login: The login to use on Geonode. :type login: basestring :param password: The password to use on Geonode. :type password: basestring """ log...
[ "def", "login_user", "(", "server", ",", "login", ",", "password", ")", ":", "login_url", "=", "urljoin", "(", "server", ",", "login_url_prefix", ")", "# Start the web session", "session", "=", "requests", ".", "session", "(", ")", "result", "=", "session", ...
Get the login session. :param server: The Geonode server URL. :type server: basestring :param login: The login to use on Geonode. :type login: basestring :param password: The password to use on Geonode. :type password: basestring
[ "Get", "the", "login", "session", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/geonode/upload_layer_requests.py#L99-L150
train
26,923
inasafe/inasafe
safe/utilities/geonode/upload_layer_requests.py
upload
def upload(server, session, base_file, charset='UTF-8'): """Push a layer to a Geonode instance. :param server: The Geonode server URL. :type server: basestring :param base_file: The base file layer to upload such as a shp, geojson, ... :type base_file: basestring :param charset: The encoding ...
python
def upload(server, session, base_file, charset='UTF-8'): """Push a layer to a Geonode instance. :param server: The Geonode server URL. :type server: basestring :param base_file: The base file layer to upload such as a shp, geojson, ... :type base_file: basestring :param charset: The encoding ...
[ "def", "upload", "(", "server", ",", "session", ",", "base_file", ",", "charset", "=", "'UTF-8'", ")", ":", "file_ext", "=", "os", ".", "path", ".", "splitext", "(", "base_file", ")", "[", "1", "]", "is_geojson", "=", "file_ext", "in", "[", "'.geojson'...
Push a layer to a Geonode instance. :param server: The Geonode server URL. :type server: basestring :param base_file: The base file layer to upload such as a shp, geojson, ... :type base_file: basestring :param charset: The encoding to use. Default to UTF-8. :type charset: basestring
[ "Push", "a", "layer", "to", "a", "Geonode", "instance", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/geonode/upload_layer_requests.py#L153-L243
train
26,924
inasafe/inasafe
safe/common/custom_logging.py
add_logging_handler_once
def add_logging_handler_once(logger, handler): """A helper to add a handler to a logger, ensuring there are no duplicates. :param logger: Logger that should have a handler added. :type logger: logging.logger :param handler: Handler instance to be added. It will not be added if an instance of t...
python
def add_logging_handler_once(logger, handler): """A helper to add a handler to a logger, ensuring there are no duplicates. :param logger: Logger that should have a handler added. :type logger: logging.logger :param handler: Handler instance to be added. It will not be added if an instance of t...
[ "def", "add_logging_handler_once", "(", "logger", ",", "handler", ")", ":", "class_name", "=", "handler", ".", "__class__", ".", "__name__", "for", "logger_handler", "in", "logger", ".", "handlers", ":", "if", "logger_handler", ".", "__class__", ".", "__name__",...
A helper to add a handler to a logger, ensuring there are no duplicates. :param logger: Logger that should have a handler added. :type logger: logging.logger :param handler: Handler instance to be added. It will not be added if an instance of that Handler subclass already exists. :type handler...
[ "A", "helper", "to", "add", "a", "handler", "to", "a", "logger", "ensuring", "there", "are", "no", "duplicates", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/custom_logging.py#L80-L99
train
26,925
inasafe/inasafe
safe/common/custom_logging.py
setup_logger
def setup_logger(logger_name, log_file=None, sentry_url=None): """Run once when the module is loaded and enable logging. :param logger_name: The logger name that we want to set up. :type logger_name: str :param log_file: Optional full path to a file to write logs to. :type log_file: str :para...
python
def setup_logger(logger_name, log_file=None, sentry_url=None): """Run once when the module is loaded and enable logging. :param logger_name: The logger name that we want to set up. :type logger_name: str :param log_file: Optional full path to a file to write logs to. :type log_file: str :para...
[ "def", "setup_logger", "(", "logger_name", ",", "log_file", "=", "None", ",", "sentry_url", "=", "None", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "logger_name", ")", "logging_level", "=", "int", "(", "os", ".", "environ", ".", "get", "(...
Run once when the module is loaded and enable logging. :param logger_name: The logger name that we want to set up. :type logger_name: str :param log_file: Optional full path to a file to write logs to. :type log_file: str :param sentry_url: Optional url to sentry api for remote logging. D...
[ "Run", "once", "when", "the", "module", "is", "loaded", "and", "enable", "logging", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/custom_logging.py#L102-L197
train
26,926
inasafe/inasafe
safe/common/custom_logging.py
QgsLogHandler.emit
def emit(self, record): """Try to log the message to QGIS if available, otherwise do nothing. :param record: logging record containing whatever info needs to be logged. """ try: # Check logging.LogRecord properties for lots of other goodies # like...
python
def emit(self, record): """Try to log the message to QGIS if available, otherwise do nothing. :param record: logging record containing whatever info needs to be logged. """ try: # Check logging.LogRecord properties for lots of other goodies # like...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "# Check logging.LogRecord properties for lots of other goodies", "# like line number etc. you can get from the log message.", "QgsMessageLog", ".", "logMessage", "(", "record", ".", "getMessage", "(", ")", ",...
Try to log the message to QGIS if available, otherwise do nothing. :param record: logging record containing whatever info needs to be logged.
[ "Try", "to", "log", "the", "message", "to", "QGIS", "if", "available", "otherwise", "do", "nothing", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/custom_logging.py#L62-L77
train
26,927
inasafe/inasafe
safe/gis/processing_tools.py
initialize_processing
def initialize_processing(): """ Initializes processing, if it's not already been done """ need_initialize = False needed_algorithms = [ 'native:clip', 'gdal:cliprasterbyextent', 'native:union', 'native:intersection' ] if not QgsApplication.processingRegist...
python
def initialize_processing(): """ Initializes processing, if it's not already been done """ need_initialize = False needed_algorithms = [ 'native:clip', 'gdal:cliprasterbyextent', 'native:union', 'native:intersection' ] if not QgsApplication.processingRegist...
[ "def", "initialize_processing", "(", ")", ":", "need_initialize", "=", "False", "needed_algorithms", "=", "[", "'native:clip'", ",", "'gdal:cliprasterbyextent'", ",", "'native:union'", ",", "'native:intersection'", "]", "if", "not", "QgsApplication", ".", "processingReg...
Initializes processing, if it's not already been done
[ "Initializes", "processing", "if", "it", "s", "not", "already", "been", "done" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/processing_tools.py#L21-L47
train
26,928
inasafe/inasafe
safe/gis/processing_tools.py
create_processing_context
def create_processing_context(feedback): """ Creates a default processing context :param feedback: Linked processing feedback object :type feedback: QgsProcessingFeedback :return: Processing context :rtype: QgsProcessingContext """ context = QgsProcessingContext() context.setFeedba...
python
def create_processing_context(feedback): """ Creates a default processing context :param feedback: Linked processing feedback object :type feedback: QgsProcessingFeedback :return: Processing context :rtype: QgsProcessingContext """ context = QgsProcessingContext() context.setFeedba...
[ "def", "create_processing_context", "(", "feedback", ")", ":", "context", "=", "QgsProcessingContext", "(", ")", "context", ".", "setFeedback", "(", "feedback", ")", "context", ".", "setProject", "(", "QgsProject", ".", "instance", "(", ")", ")", "# skip Process...
Creates a default processing context :param feedback: Linked processing feedback object :type feedback: QgsProcessingFeedback :return: Processing context :rtype: QgsProcessingContext
[ "Creates", "a", "default", "processing", "context" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/processing_tools.py#L50-L67
train
26,929
inasafe/inasafe
safe/datastore/datastore.py
DataStore.add_layer
def add_layer(self, layer, layer_name, save_style=False): """Add a layer to the datastore. :param layer: The layer to add. :type layer: QgsMapLayer :param layer_name: The name of the layer in the datastore. :type layer_name: str :param save_style: If we have to save a ...
python
def add_layer(self, layer, layer_name, save_style=False): """Add a layer to the datastore. :param layer: The layer to add. :type layer: QgsMapLayer :param layer_name: The name of the layer in the datastore. :type layer_name: str :param save_style: If we have to save a ...
[ "def", "add_layer", "(", "self", ",", "layer", ",", "layer_name", ",", "save_style", "=", "False", ")", ":", "if", "self", ".", "_use_index", ":", "layer_name", "=", "'%s-%s'", "%", "(", "self", ".", "_index", ",", "layer_name", ")", "self", ".", "_ind...
Add a layer to the datastore. :param layer: The layer to add. :type layer: QgsMapLayer :param layer_name: The name of the layer in the datastore. :type layer_name: str :param save_style: If we have to save a QML too. Default to False. :type save_style: bool :r...
[ "Add", "a", "layer", "to", "the", "datastore", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/datastore.py#L91-L141
train
26,930
inasafe/inasafe
safe/datastore/datastore.py
DataStore.layer
def layer(self, layer_name): """Get QGIS layer. :param layer_name: The name of the layer to fetch. :type layer_name: str :return: The QGIS layer. :rtype: QgsMapLayer .. versionadded:: 4.0 """ uri = self.layer_uri(layer_name) layer = QgsVectorLay...
python
def layer(self, layer_name): """Get QGIS layer. :param layer_name: The name of the layer to fetch. :type layer_name: str :return: The QGIS layer. :rtype: QgsMapLayer .. versionadded:: 4.0 """ uri = self.layer_uri(layer_name) layer = QgsVectorLay...
[ "def", "layer", "(", "self", ",", "layer_name", ")", ":", "uri", "=", "self", ".", "layer_uri", "(", "layer_name", ")", "layer", "=", "QgsVectorLayer", "(", "uri", ",", "layer_name", ",", "'ogr'", ")", "if", "not", "layer", ".", "isValid", "(", ")", ...
Get QGIS layer. :param layer_name: The name of the layer to fetch. :type layer_name: str :return: The QGIS layer. :rtype: QgsMapLayer .. versionadded:: 4.0
[ "Get", "QGIS", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/datastore.py#L143-L163
train
26,931
inasafe/inasafe
safe/datastore/datastore.py
DataStore.layer_keyword
def layer_keyword(self, keyword, value): """Get a layer according to a keyword and its value. :param keyword: The keyword to check. :type keyword: basestring :param value: The value to check for the specific keyword. :type value: basestring :return: The QGIS layer. ...
python
def layer_keyword(self, keyword, value): """Get a layer according to a keyword and its value. :param keyword: The keyword to check. :type keyword: basestring :param value: The value to check for the specific keyword. :type value: basestring :return: The QGIS layer. ...
[ "def", "layer_keyword", "(", "self", ",", "keyword", ",", "value", ")", ":", "for", "layer", "in", "sorted", "(", "self", ".", "layers", "(", ")", ",", "reverse", "=", "True", ")", ":", "qgis_layer", "=", "self", ".", "layer", "(", "layer", ")", "i...
Get a layer according to a keyword and its value. :param keyword: The keyword to check. :type keyword: basestring :param value: The value to check for the specific keyword. :type value: basestring :return: The QGIS layer. :rtype: QgsMapLayer .. versionadded:: ...
[ "Get", "a", "layer", "according", "to", "a", "keyword", "and", "its", "value", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/datastore.py#L212-L230
train
26,932
inasafe/inasafe
safe/definitions/utilities.py
purposes_for_layer
def purposes_for_layer(layer_geometry_key): """Get purposes of a layer geometry id. :param layer_geometry_key: The geometry id :type layer_geometry_key: str :returns: List of suitable layer purpose. :rtype: list """ return_value = [] for layer_purpose in layer_purposes: layer_g...
python
def purposes_for_layer(layer_geometry_key): """Get purposes of a layer geometry id. :param layer_geometry_key: The geometry id :type layer_geometry_key: str :returns: List of suitable layer purpose. :rtype: list """ return_value = [] for layer_purpose in layer_purposes: layer_g...
[ "def", "purposes_for_layer", "(", "layer_geometry_key", ")", ":", "return_value", "=", "[", "]", "for", "layer_purpose", "in", "layer_purposes", ":", "layer_geometry_keys", "=", "[", "i", "[", "'key'", "]", "for", "i", "in", "layer_purpose", "[", "'allowed_geome...
Get purposes of a layer geometry id. :param layer_geometry_key: The geometry id :type layer_geometry_key: str :returns: List of suitable layer purpose. :rtype: list
[ "Get", "purposes", "of", "a", "layer", "geometry", "id", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L44-L60
train
26,933
inasafe/inasafe
safe/definitions/utilities.py
hazards_for_layer
def hazards_for_layer(layer_geometry_key): """Get hazard categories form layer_geometry_key. :param layer_geometry_key: The geometry id :type layer_geometry_key: str :returns: List of hazard :rtype: list """ result = [] for hazard in hazard_all: if layer_geometry_key in hazard....
python
def hazards_for_layer(layer_geometry_key): """Get hazard categories form layer_geometry_key. :param layer_geometry_key: The geometry id :type layer_geometry_key: str :returns: List of hazard :rtype: list """ result = [] for hazard in hazard_all: if layer_geometry_key in hazard....
[ "def", "hazards_for_layer", "(", "layer_geometry_key", ")", ":", "result", "=", "[", "]", "for", "hazard", "in", "hazard_all", ":", "if", "layer_geometry_key", "in", "hazard", ".", "get", "(", "'allowed_geometries'", ")", ":", "result", ".", "append", "(", "...
Get hazard categories form layer_geometry_key. :param layer_geometry_key: The geometry id :type layer_geometry_key: str :returns: List of hazard :rtype: list
[ "Get", "hazard", "categories", "form", "layer_geometry_key", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L63-L77
train
26,934
inasafe/inasafe
safe/definitions/utilities.py
exposures_for_layer
def exposures_for_layer(layer_geometry_key): """Get hazard categories form layer_geometry_key :param layer_geometry_key: The geometry key :type layer_geometry_key: str :returns: List of hazard :rtype: list """ result = [] for exposure in exposure_all: if layer_geometry_key in e...
python
def exposures_for_layer(layer_geometry_key): """Get hazard categories form layer_geometry_key :param layer_geometry_key: The geometry key :type layer_geometry_key: str :returns: List of hazard :rtype: list """ result = [] for exposure in exposure_all: if layer_geometry_key in e...
[ "def", "exposures_for_layer", "(", "layer_geometry_key", ")", ":", "result", "=", "[", "]", "for", "exposure", "in", "exposure_all", ":", "if", "layer_geometry_key", "in", "exposure", ".", "get", "(", "'allowed_geometries'", ")", ":", "result", ".", "append", ...
Get hazard categories form layer_geometry_key :param layer_geometry_key: The geometry key :type layer_geometry_key: str :returns: List of hazard :rtype: list
[ "Get", "hazard", "categories", "form", "layer_geometry_key" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L80-L94
train
26,935
inasafe/inasafe
safe/definitions/utilities.py
get_layer_modes
def get_layer_modes(subcategory): """Return all sorted layer modes from exposure or hazard. :param subcategory: Hazard or Exposure key. :type subcategory: str :returns: List of layer modes definition. :rtype: list """ layer_modes = definition(subcategory)['layer_modes'] return sorted(l...
python
def get_layer_modes(subcategory): """Return all sorted layer modes from exposure or hazard. :param subcategory: Hazard or Exposure key. :type subcategory: str :returns: List of layer modes definition. :rtype: list """ layer_modes = definition(subcategory)['layer_modes'] return sorted(l...
[ "def", "get_layer_modes", "(", "subcategory", ")", ":", "layer_modes", "=", "definition", "(", "subcategory", ")", "[", "'layer_modes'", "]", "return", "sorted", "(", "layer_modes", ",", "key", "=", "lambda", "k", ":", "k", "[", "'key'", "]", ")" ]
Return all sorted layer modes from exposure or hazard. :param subcategory: Hazard or Exposure key. :type subcategory: str :returns: List of layer modes definition. :rtype: list
[ "Return", "all", "sorted", "layer", "modes", "from", "exposure", "or", "hazard", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L106-L116
train
26,936
inasafe/inasafe
safe/definitions/utilities.py
hazard_units
def hazard_units(hazard): """Helper to get unit of a hazard. :param hazard: Hazard type. :type hazard: str :returns: List of hazard units. :rtype: list """ units = definition(hazard)['continuous_hazard_units'] return sorted(units, key=lambda k: k['key'])
python
def hazard_units(hazard): """Helper to get unit of a hazard. :param hazard: Hazard type. :type hazard: str :returns: List of hazard units. :rtype: list """ units = definition(hazard)['continuous_hazard_units'] return sorted(units, key=lambda k: k['key'])
[ "def", "hazard_units", "(", "hazard", ")", ":", "units", "=", "definition", "(", "hazard", ")", "[", "'continuous_hazard_units'", "]", "return", "sorted", "(", "units", ",", "key", "=", "lambda", "k", ":", "k", "[", "'key'", "]", ")" ]
Helper to get unit of a hazard. :param hazard: Hazard type. :type hazard: str :returns: List of hazard units. :rtype: list
[ "Helper", "to", "get", "unit", "of", "a", "hazard", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L119-L129
train
26,937
inasafe/inasafe
safe/definitions/utilities.py
exposure_units
def exposure_units(exposure): """Helper to get unit of an exposure. :param exposure: Exposure type. :type exposure: str :returns: List of exposure units. :rtype: list """ units = definition(exposure)['units'] return sorted(units, key=lambda k: k['key'])
python
def exposure_units(exposure): """Helper to get unit of an exposure. :param exposure: Exposure type. :type exposure: str :returns: List of exposure units. :rtype: list """ units = definition(exposure)['units'] return sorted(units, key=lambda k: k['key'])
[ "def", "exposure_units", "(", "exposure", ")", ":", "units", "=", "definition", "(", "exposure", ")", "[", "'units'", "]", "return", "sorted", "(", "units", ",", "key", "=", "lambda", "k", ":", "k", "[", "'key'", "]", ")" ]
Helper to get unit of an exposure. :param exposure: Exposure type. :type exposure: str :returns: List of exposure units. :rtype: list
[ "Helper", "to", "get", "unit", "of", "an", "exposure", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L132-L142
train
26,938
inasafe/inasafe
safe/definitions/utilities.py
get_classifications
def get_classifications(subcategory_key): """Get hazard or exposure classifications. :param subcategory_key: The hazard or exposure key :type subcategory_key: str :returns: List of hazard or exposure classifications :rtype: list """ classifications = definition(subcategory_key)['classifica...
python
def get_classifications(subcategory_key): """Get hazard or exposure classifications. :param subcategory_key: The hazard or exposure key :type subcategory_key: str :returns: List of hazard or exposure classifications :rtype: list """ classifications = definition(subcategory_key)['classifica...
[ "def", "get_classifications", "(", "subcategory_key", ")", ":", "classifications", "=", "definition", "(", "subcategory_key", ")", "[", "'classifications'", "]", "return", "sorted", "(", "classifications", ",", "key", "=", "lambda", "k", ":", "k", "[", "'key'", ...
Get hazard or exposure classifications. :param subcategory_key: The hazard or exposure key :type subcategory_key: str :returns: List of hazard or exposure classifications :rtype: list
[ "Get", "hazard", "or", "exposure", "classifications", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L145-L155
train
26,939
inasafe/inasafe
safe/definitions/utilities.py
get_fields
def get_fields( layer_purpose, layer_subcategory=None, replace_null=None, in_group=True): """Get all field based on the layer purpose. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str ...
python
def get_fields( layer_purpose, layer_subcategory=None, replace_null=None, in_group=True): """Get all field based on the layer purpose. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str ...
[ "def", "get_fields", "(", "layer_purpose", ",", "layer_subcategory", "=", "None", ",", "replace_null", "=", "None", ",", "in_group", "=", "True", ")", ":", "fields_for_purpose", "=", "[", "]", "if", "layer_purpose", "==", "layer_purpose_exposure", "[", "'key'", ...
Get all field based on the layer purpose. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :param replace_null: If None all fields are returned, if True only if it's True, if False only if it...
[ "Get", "all", "field", "based", "on", "the", "layer", "purpose", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L158-L211
train
26,940
inasafe/inasafe
safe/definitions/utilities.py
get_compulsory_fields
def get_compulsory_fields(layer_purpose, layer_subcategory=None): """Get compulsory field based on layer_purpose and layer_subcategory :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: C...
python
def get_compulsory_fields(layer_purpose, layer_subcategory=None): """Get compulsory field based on layer_purpose and layer_subcategory :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: C...
[ "def", "get_compulsory_fields", "(", "layer_purpose", ",", "layer_subcategory", "=", "None", ")", ":", "if", "not", "layer_subcategory", ":", "if", "layer_purpose", "==", "'hazard'", ":", "return", "hazard_value_field", "elif", "layer_purpose", "==", "'exposure'", "...
Get compulsory field based on layer_purpose and layer_subcategory :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: Compulsory field :rtype: dict
[ "Get", "compulsory", "field", "based", "on", "layer_purpose", "and", "layer_subcategory" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L214-L236
train
26,941
inasafe/inasafe
safe/definitions/utilities.py
get_non_compulsory_fields
def get_non_compulsory_fields(layer_purpose, layer_subcategory=None): """Get non compulsory field based on layer_purpose and layer_subcategory. Used for get field in InaSAFE Fields step in wizard. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure...
python
def get_non_compulsory_fields(layer_purpose, layer_subcategory=None): """Get non compulsory field based on layer_purpose and layer_subcategory. Used for get field in InaSAFE Fields step in wizard. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure...
[ "def", "get_non_compulsory_fields", "(", "layer_purpose", ",", "layer_subcategory", "=", "None", ")", ":", "all_fields", "=", "get_fields", "(", "layer_purpose", ",", "layer_subcategory", ",", "replace_null", "=", "False", ")", "compulsory_field", "=", "get_compulsory...
Get non compulsory field based on layer_purpose and layer_subcategory. Used for get field in InaSAFE Fields step in wizard. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: Compulsory ...
[ "Get", "non", "compulsory", "field", "based", "on", "layer_purpose", "and", "layer_subcategory", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L239-L259
train
26,942
inasafe/inasafe
safe/definitions/utilities.py
get_name
def get_name(key): """Given a keyword, try to get the name of it. .. versionadded:: 4.2 Definition dicts are defined in keywords.py. We try to return the name if present, otherwise we return none. keyword = 'layer_purpose' kio = safe.utilities.keyword_io.Keyword_IO() name = kio.get_name(k...
python
def get_name(key): """Given a keyword, try to get the name of it. .. versionadded:: 4.2 Definition dicts are defined in keywords.py. We try to return the name if present, otherwise we return none. keyword = 'layer_purpose' kio = safe.utilities.keyword_io.Keyword_IO() name = kio.get_name(k...
[ "def", "get_name", "(", "key", ")", ":", "definition_dict", "=", "definition", "(", "key", ")", "if", "definition_dict", ":", "return", "definition_dict", ".", "get", "(", "'name'", ",", "key", ")", "# Else, return the keyword", "return", "key" ]
Given a keyword, try to get the name of it. .. versionadded:: 4.2 Definition dicts are defined in keywords.py. We try to return the name if present, otherwise we return none. keyword = 'layer_purpose' kio = safe.utilities.keyword_io.Keyword_IO() name = kio.get_name(keyword) print name ...
[ "Given", "a", "keyword", "try", "to", "get", "the", "name", "of", "it", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L297-L320
train
26,943
inasafe/inasafe
safe/definitions/utilities.py
get_class_name
def get_class_name(class_key, classification_key): """Helper to get class name from a class_key of a classification. :param class_key: The key of the class. :type class_key: str :type classification_key: The key of a classification. :param classification_key: str :returns: The name of the cla...
python
def get_class_name(class_key, classification_key): """Helper to get class name from a class_key of a classification. :param class_key: The key of the class. :type class_key: str :type classification_key: The key of a classification. :param classification_key: str :returns: The name of the cla...
[ "def", "get_class_name", "(", "class_key", ",", "classification_key", ")", ":", "classification", "=", "definition", "(", "classification_key", ")", "for", "the_class", "in", "classification", "[", "'classes'", "]", ":", "if", "the_class", ".", "get", "(", "'key...
Helper to get class name from a class_key of a classification. :param class_key: The key of the class. :type class_key: str :type classification_key: The key of a classification. :param classification_key: str :returns: The name of the class. :rtype: str
[ "Helper", "to", "get", "class", "name", "from", "a", "class_key", "of", "a", "classification", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L323-L339
train
26,944
inasafe/inasafe
safe/definitions/utilities.py
get_allowed_geometries
def get_allowed_geometries(layer_purpose_key): """Helper function to get all possible geometry :param layer_purpose_key: A layer purpose key. :type layer_purpose_key: str :returns: List of all allowed geometries. :rtype: list """ preferred_order = [ 'point', 'line', ...
python
def get_allowed_geometries(layer_purpose_key): """Helper function to get all possible geometry :param layer_purpose_key: A layer purpose key. :type layer_purpose_key: str :returns: List of all allowed geometries. :rtype: list """ preferred_order = [ 'point', 'line', ...
[ "def", "get_allowed_geometries", "(", "layer_purpose_key", ")", ":", "preferred_order", "=", "[", "'point'", ",", "'line'", ",", "'polygon'", ",", "'raster'", "]", "allowed_geometries", "=", "set", "(", ")", "all_layer_type", "=", "[", "]", "if", "layer_purpose_...
Helper function to get all possible geometry :param layer_purpose_key: A layer purpose key. :type layer_purpose_key: str :returns: List of all allowed geometries. :rtype: list
[ "Helper", "function", "to", "get", "all", "possible", "geometry" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L342-L377
train
26,945
inasafe/inasafe
safe/definitions/utilities.py
all_default_fields
def all_default_fields(): """Helper to retrieve all fields which has default value. :returns: List of default fields. :rtype: list """ default_fields = [] for item in dir(fields): if not item.startswith("__"): var = getattr(definitions, item) if isinstance(var, d...
python
def all_default_fields(): """Helper to retrieve all fields which has default value. :returns: List of default fields. :rtype: list """ default_fields = [] for item in dir(fields): if not item.startswith("__"): var = getattr(definitions, item) if isinstance(var, d...
[ "def", "all_default_fields", "(", ")", ":", "default_fields", "=", "[", "]", "for", "item", "in", "dir", "(", "fields", ")", ":", "if", "not", "item", ".", "startswith", "(", "\"__\"", ")", ":", "var", "=", "getattr", "(", "definitions", ",", "item", ...
Helper to retrieve all fields which has default value. :returns: List of default fields. :rtype: list
[ "Helper", "to", "retrieve", "all", "fields", "which", "has", "default", "value", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L380-L393
train
26,946
inasafe/inasafe
safe/definitions/utilities.py
default_classification_thresholds
def default_classification_thresholds(classification, unit=None): """Helper to get default thresholds from classification and unit. :param classification: Classification definition. :type classification: dict :param unit: Unit key definition. :type unit: basestring :returns: Dictionary with k...
python
def default_classification_thresholds(classification, unit=None): """Helper to get default thresholds from classification and unit. :param classification: Classification definition. :type classification: dict :param unit: Unit key definition. :type unit: basestring :returns: Dictionary with k...
[ "def", "default_classification_thresholds", "(", "classification", ",", "unit", "=", "None", ")", ":", "thresholds", "=", "{", "}", "for", "hazard_class", "in", "classification", "[", "'classes'", "]", ":", "if", "isinstance", "(", "hazard_class", "[", "'numeric...
Helper to get default thresholds from classification and unit. :param classification: Classification definition. :type classification: dict :param unit: Unit key definition. :type unit: basestring :returns: Dictionary with key = the class key and value = list of default numeric minimum an...
[ "Helper", "to", "get", "default", "thresholds", "from", "classification", "and", "unit", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L408-L433
train
26,947
inasafe/inasafe
safe/definitions/utilities.py
default_classification_value_maps
def default_classification_value_maps(classification): """Helper to get default value maps from classification. :param classification: Classification definition. :type classification: dict :returns: Dictionary with key = the class key and value = default strings. :rtype: dict """ value_map...
python
def default_classification_value_maps(classification): """Helper to get default value maps from classification. :param classification: Classification definition. :type classification: dict :returns: Dictionary with key = the class key and value = default strings. :rtype: dict """ value_map...
[ "def", "default_classification_value_maps", "(", "classification", ")", ":", "value_maps", "=", "{", "}", "for", "hazard_class", "in", "classification", "[", "'classes'", "]", ":", "value_maps", "[", "hazard_class", "[", "'key'", "]", "]", "=", "hazard_class", "...
Helper to get default value maps from classification. :param classification: Classification definition. :type classification: dict :returns: Dictionary with key = the class key and value = default strings. :rtype: dict
[ "Helper", "to", "get", "default", "value", "maps", "from", "classification", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L436-L450
train
26,948
inasafe/inasafe
safe/definitions/utilities.py
get_field_groups
def get_field_groups(layer_purpose, layer_subcategory=None): """Obtain list of field groups from layer purpose and subcategory. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: List of ...
python
def get_field_groups(layer_purpose, layer_subcategory=None): """Obtain list of field groups from layer purpose and subcategory. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: List of ...
[ "def", "get_field_groups", "(", "layer_purpose", ",", "layer_subcategory", "=", "None", ")", ":", "layer_purpose_dict", "=", "definition", "(", "layer_purpose", ")", "if", "not", "layer_purpose_dict", ":", "return", "[", "]", "field_groups", "=", "deepcopy", "(", ...
Obtain list of field groups from layer purpose and subcategory. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: List of layer groups. :rtype: list
[ "Obtain", "list", "of", "field", "groups", "from", "layer", "purpose", "and", "subcategory", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L468-L490
train
26,949
inasafe/inasafe
safe/definitions/utilities.py
override_component_template
def override_component_template(component, template_path): """Override a default component with a new component with given template. :param component: Component as dictionary. :type component: dict :param template_path: Custom template path that will be used. :type template_path: str :returns...
python
def override_component_template(component, template_path): """Override a default component with a new component with given template. :param component: Component as dictionary. :type component: dict :param template_path: Custom template path that will be used. :type template_path: str :returns...
[ "def", "override_component_template", "(", "component", ",", "template_path", ")", ":", "copy_component", "=", "deepcopy", "(", "component", ")", "template_directory", ",", "template_filename", "=", "split", "(", "template_path", ")", "file_name", ",", "file_format", ...
Override a default component with a new component with given template. :param component: Component as dictionary. :type component: dict :param template_path: Custom template path that will be used. :type template_path: str :returns: New report component. :rtype: dict
[ "Override", "a", "default", "component", "with", "a", "new", "component", "with", "given", "template", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L493-L565
train
26,950
inasafe/inasafe
safe/definitions/utilities.py
update_template_component
def update_template_component( component, custom_template_dir=None, hazard=None, exposure=None): """Get a component based on custom qpt if exists :param component: Component as dictionary. :type component: dict :param custom_template_dir: The directory where the custom template stored. :ty...
python
def update_template_component( component, custom_template_dir=None, hazard=None, exposure=None): """Get a component based on custom qpt if exists :param component: Component as dictionary. :type component: dict :param custom_template_dir: The directory where the custom template stored. :ty...
[ "def", "update_template_component", "(", "component", ",", "custom_template_dir", "=", "None", ",", "hazard", "=", "None", ",", "exposure", "=", "None", ")", ":", "copy_component", "=", "deepcopy", "(", "component", ")", "# get the default template component from the ...
Get a component based on custom qpt if exists :param component: Component as dictionary. :type component: dict :param custom_template_dir: The directory where the custom template stored. :type custom_template_dir: basestring :param hazard: The hazard definition. :type hazard: dict :param...
[ "Get", "a", "component", "based", "on", "custom", "qpt", "if", "exists" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L568-L652
train
26,951
inasafe/inasafe
safe/definitions/utilities.py
get_displacement_rate
def get_displacement_rate( hazard, classification, hazard_class, qsettings=None): """Get displacement rate for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring ...
python
def get_displacement_rate( hazard, classification, hazard_class, qsettings=None): """Get displacement rate for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring ...
[ "def", "get_displacement_rate", "(", "hazard", ",", "classification", ",", "hazard_class", ",", "qsettings", "=", "None", ")", ":", "is_affected_value", "=", "is_affected", "(", "hazard", ",", "classification", ",", "hazard_class", ",", "qsettings", ")", "if", "...
Get displacement rate for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring :param hazard_class: The hazard class key. :type hazard_class: basestring :param qse...
[ "Get", "displacement", "rate", "for", "hazard", "in", "classification", "in", "hazard", "class", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L728-L767
train
26,952
inasafe/inasafe
safe/definitions/utilities.py
is_affected
def is_affected(hazard, classification, hazard_class, qsettings=None): """Get affected flag for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring :param hazard_class...
python
def is_affected(hazard, classification, hazard_class, qsettings=None): """Get affected flag for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring :param hazard_class...
[ "def", "is_affected", "(", "hazard", ",", "classification", ",", "hazard_class", ",", "qsettings", "=", "None", ")", ":", "preference_data", "=", "setting", "(", "'population_preference'", ",", "default", "=", "generate_default_profile", "(", ")", ",", "qsettings"...
Get affected flag for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring :param hazard_class: The hazard class key. :type hazard_class: basestring :param qsettin...
[ "Get", "affected", "flag", "for", "hazard", "in", "classification", "in", "hazard", "class", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/utilities.py#L770-L801
train
26,953
inasafe/inasafe
safe/common/utilities.py
safe_dir
def safe_dir(sub_dir=None): """Absolute path from safe package directory. :param sub_dir: Sub directory relative to safe package directory. :type sub_dir: str :return: The Absolute path. :rtype: str """ safe_relative_path = os.path.join( os.path.dirname(__file__), '../') return...
python
def safe_dir(sub_dir=None): """Absolute path from safe package directory. :param sub_dir: Sub directory relative to safe package directory. :type sub_dir: str :return: The Absolute path. :rtype: str """ safe_relative_path = os.path.join( os.path.dirname(__file__), '../') return...
[ "def", "safe_dir", "(", "sub_dir", "=", "None", ")", ":", "safe_relative_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'../'", ")", "return", "os", ".", "path", ".", "abspath", "(", ...
Absolute path from safe package directory. :param sub_dir: Sub directory relative to safe package directory. :type sub_dir: str :return: The Absolute path. :rtype: str
[ "Absolute", "path", "from", "safe", "package", "directory", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L91-L103
train
26,954
inasafe/inasafe
safe/common/utilities.py
temp_dir
def temp_dir(sub_dir='work'): """Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a tem...
python
def temp_dir(sub_dir='work'): """Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a tem...
[ "def", "temp_dir", "(", "sub_dir", "=", "'work'", ")", ":", "user", "=", "getpass", ".", "getuser", "(", ")", ".", "replace", "(", "' '", ",", "'_'", ")", "current_date", "=", "date", ".", "today", "(", ")", "date_string", "=", "current_date", ".", "...
Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a temporary directory under the inasafe wo...
[ "Obtain", "the", "temporary", "working", "directory", "for", "the", "operating", "system", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L106-L154
train
26,955
inasafe/inasafe
safe/common/utilities.py
unique_filename
def unique_filename(**kwargs): """Create new filename guaranteed not to exist previously Use mkstemp to create the file, then remove it and return the name If dir is specified, the tempfile will be created in the path specified otherwise the file will be created in a directory following this scheme: ...
python
def unique_filename(**kwargs): """Create new filename guaranteed not to exist previously Use mkstemp to create the file, then remove it and return the name If dir is specified, the tempfile will be created in the path specified otherwise the file will be created in a directory following this scheme: ...
[ "def", "unique_filename", "(", "*", "*", "kwargs", ")", ":", "if", "'dir'", "not", "in", "kwargs", ":", "path", "=", "temp_dir", "(", "'impacts'", ")", "kwargs", "[", "'dir'", "]", "=", "path", "else", ":", "path", "=", "temp_dir", "(", "kwargs", "["...
Create new filename guaranteed not to exist previously Use mkstemp to create the file, then remove it and return the name If dir is specified, the tempfile will be created in the path specified otherwise the file will be created in a directory following this scheme: :file:'/tmp/inasafe/<dd-mm-yyyy>/<...
[ "Create", "new", "filename", "guaranteed", "not", "to", "exist", "previously" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L157-L206
train
26,956
inasafe/inasafe
safe/common/utilities.py
get_free_memory
def get_free_memory(): """Return current free memory on the machine. Currently supported for Windows, Linux, MacOS. :returns: Free memory in MB unit :rtype: int """ if 'win32' in sys.platform: # windows return get_free_memory_win() elif 'linux' in sys.platform: # li...
python
def get_free_memory(): """Return current free memory on the machine. Currently supported for Windows, Linux, MacOS. :returns: Free memory in MB unit :rtype: int """ if 'win32' in sys.platform: # windows return get_free_memory_win() elif 'linux' in sys.platform: # li...
[ "def", "get_free_memory", "(", ")", ":", "if", "'win32'", "in", "sys", ".", "platform", ":", "# windows", "return", "get_free_memory_win", "(", ")", "elif", "'linux'", "in", "sys", ".", "platform", ":", "# linux", "return", "get_free_memory_linux", "(", ")", ...
Return current free memory on the machine. Currently supported for Windows, Linux, MacOS. :returns: Free memory in MB unit :rtype: int
[ "Return", "current", "free", "memory", "on", "the", "machine", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L209-L225
train
26,957
inasafe/inasafe
safe/common/utilities.py
get_free_memory_win
def get_free_memory_win(): """Return current free memory on the machine for windows. Warning : this script is really not robust Return in MB unit """ stat = MEMORYSTATUSEX() ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) return int(stat.ullAvailPhys / 1024 / 1024)
python
def get_free_memory_win(): """Return current free memory on the machine for windows. Warning : this script is really not robust Return in MB unit """ stat = MEMORYSTATUSEX() ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) return int(stat.ullAvailPhys / 1024 / 1024)
[ "def", "get_free_memory_win", "(", ")", ":", "stat", "=", "MEMORYSTATUSEX", "(", ")", "ctypes", ".", "windll", ".", "kernel32", ".", "GlobalMemoryStatusEx", "(", "ctypes", ".", "byref", "(", "stat", ")", ")", "return", "int", "(", "stat", ".", "ullAvailPhy...
Return current free memory on the machine for windows. Warning : this script is really not robust Return in MB unit
[ "Return", "current", "free", "memory", "on", "the", "machine", "for", "windows", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L228-L236
train
26,958
inasafe/inasafe
safe/common/utilities.py
get_free_memory_linux
def get_free_memory_linux(): """Return current free memory on the machine for linux. Warning : this script is really not robust Return in MB unit """ try: p = Popen('free -m', shell=True, stdout=PIPE, encoding='utf8') stdout_string = p.communicate()[0].split('\n')[2] except OSEr...
python
def get_free_memory_linux(): """Return current free memory on the machine for linux. Warning : this script is really not robust Return in MB unit """ try: p = Popen('free -m', shell=True, stdout=PIPE, encoding='utf8') stdout_string = p.communicate()[0].split('\n')[2] except OSEr...
[ "def", "get_free_memory_linux", "(", ")", ":", "try", ":", "p", "=", "Popen", "(", "'free -m'", ",", "shell", "=", "True", ",", "stdout", "=", "PIPE", ",", "encoding", "=", "'utf8'", ")", "stdout_string", "=", "p", ".", "communicate", "(", ")", "[", ...
Return current free memory on the machine for linux. Warning : this script is really not robust Return in MB unit
[ "Return", "current", "free", "memory", "on", "the", "machine", "for", "linux", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L239-L252
train
26,959
inasafe/inasafe
safe/common/utilities.py
get_free_memory_osx
def get_free_memory_osx(): """Return current free memory on the machine for mac os. Warning : this script is really not robust Return in MB unit """ try: p = Popen('echo -e "\n$(top -l 1 | awk \'/PhysMem/\';)\n"', shell=True, stdout=PIPE, encoding='utf8') stdout_st...
python
def get_free_memory_osx(): """Return current free memory on the machine for mac os. Warning : this script is really not robust Return in MB unit """ try: p = Popen('echo -e "\n$(top -l 1 | awk \'/PhysMem/\';)\n"', shell=True, stdout=PIPE, encoding='utf8') stdout_st...
[ "def", "get_free_memory_osx", "(", ")", ":", "try", ":", "p", "=", "Popen", "(", "'echo -e \"\\n$(top -l 1 | awk \\'/PhysMem/\\';)\\n\"'", ",", "shell", "=", "True", ",", "stdout", "=", "PIPE", ",", "encoding", "=", "'utf8'", ")", "stdout_string", "=", "p", "....
Return current free memory on the machine for mac os. Warning : this script is really not robust Return in MB unit
[ "Return", "current", "free", "memory", "on", "the", "machine", "for", "mac", "os", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L255-L291
train
26,960
inasafe/inasafe
safe/common/utilities.py
humanize_min_max
def humanize_min_max(min_value, max_value, interval): """Return humanize value format for max and min. If the range between the max and min is less than one, the original value will be returned. :param min_value: Minimum value :type min_value: int, float :param max_value: Maximim value :t...
python
def humanize_min_max(min_value, max_value, interval): """Return humanize value format for max and min. If the range between the max and min is less than one, the original value will be returned. :param min_value: Minimum value :type min_value: int, float :param max_value: Maximim value :t...
[ "def", "humanize_min_max", "(", "min_value", ",", "max_value", ",", "interval", ")", ":", "current_interval", "=", "max_value", "-", "min_value", "if", "interval", ">", "1", ":", "# print 'case 1. Current interval : ', current_interval", "humanize_min_value", "=", "add_...
Return humanize value format for max and min. If the range between the max and min is less than one, the original value will be returned. :param min_value: Minimum value :type min_value: int, float :param max_value: Maximim value :type max_value: int, float :param interval: The interval ...
[ "Return", "humanize", "value", "format", "for", "max", "and", "min", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L294-L324
train
26,961
inasafe/inasafe
safe/common/utilities.py
format_decimal
def format_decimal(interval, value): """Return formatted decimal according to interval decimal place For example: interval = 0.33 (two decimal places) my_float = 1.1215454 Return 1.12 (return only two decimal places as string) If interval is an integer return integer part of my_number If my...
python
def format_decimal(interval, value): """Return formatted decimal according to interval decimal place For example: interval = 0.33 (two decimal places) my_float = 1.1215454 Return 1.12 (return only two decimal places as string) If interval is an integer return integer part of my_number If my...
[ "def", "format_decimal", "(", "interval", ",", "value", ")", ":", "interval", "=", "get_significant_decimal", "(", "interval", ")", "if", "isinstance", "(", "interval", ",", "Integral", ")", "or", "isinstance", "(", "value", ",", "Integral", ")", ":", "retur...
Return formatted decimal according to interval decimal place For example: interval = 0.33 (two decimal places) my_float = 1.1215454 Return 1.12 (return only two decimal places as string) If interval is an integer return integer part of my_number If my_number is an integer return as is
[ "Return", "formatted", "decimal", "according", "to", "interval", "decimal", "place" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L327-L354
train
26,962
inasafe/inasafe
safe/common/utilities.py
get_significant_decimal
def get_significant_decimal(my_decimal): """Return a truncated decimal by last three digit after leading zero.""" if isinstance(my_decimal, Integral): return my_decimal if my_decimal != my_decimal: # nan return my_decimal my_int_part = str(my_decimal).split('.')[0] my_decima...
python
def get_significant_decimal(my_decimal): """Return a truncated decimal by last three digit after leading zero.""" if isinstance(my_decimal, Integral): return my_decimal if my_decimal != my_decimal: # nan return my_decimal my_int_part = str(my_decimal).split('.')[0] my_decima...
[ "def", "get_significant_decimal", "(", "my_decimal", ")", ":", "if", "isinstance", "(", "my_decimal", ",", "Integral", ")", ":", "return", "my_decimal", "if", "my_decimal", "!=", "my_decimal", ":", "# nan", "return", "my_decimal", "my_int_part", "=", "str", "(",...
Return a truncated decimal by last three digit after leading zero.
[ "Return", "a", "truncated", "decimal", "by", "last", "three", "digit", "after", "leading", "zero", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L357-L385
train
26,963
inasafe/inasafe
safe/common/utilities.py
humanize_class
def humanize_class(my_classes): """Return humanize interval of an array. For example:: Original Array: Result: 1.1 - 5754.1 0 - 1 5754.1 - 11507.1 1 - 5,754 5,754 - 11,507 ...
python
def humanize_class(my_classes): """Return humanize interval of an array. For example:: Original Array: Result: 1.1 - 5754.1 0 - 1 5754.1 - 11507.1 1 - 5,754 5,754 - 11,507 ...
[ "def", "humanize_class", "(", "my_classes", ")", ":", "min_value", "=", "0", "if", "min_value", "-", "my_classes", "[", "0", "]", "==", "0", ":", "if", "len", "(", "my_classes", ")", "==", "1", ":", "return", "[", "(", "'0'", ",", "'0'", ")", "]", ...
Return humanize interval of an array. For example:: Original Array: Result: 1.1 - 5754.1 0 - 1 5754.1 - 11507.1 1 - 5,754 5,754 - 11,507 Original Array: ...
[ "Return", "humanize", "interval", "of", "an", "array", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L388-L431
train
26,964
inasafe/inasafe
safe/common/utilities.py
unhumanize_class
def unhumanize_class(my_classes): """Return class as interval without formatting.""" result = [] interval = my_classes[-1] - my_classes[-2] min_value = 0 for max_value in my_classes: result.append((format_decimal(interval, min_value), format_decimal(interval, max_value...
python
def unhumanize_class(my_classes): """Return class as interval without formatting.""" result = [] interval = my_classes[-1] - my_classes[-2] min_value = 0 for max_value in my_classes: result.append((format_decimal(interval, min_value), format_decimal(interval, max_value...
[ "def", "unhumanize_class", "(", "my_classes", ")", ":", "result", "=", "[", "]", "interval", "=", "my_classes", "[", "-", "1", "]", "-", "my_classes", "[", "-", "2", "]", "min_value", "=", "0", "for", "max_value", "in", "my_classes", ":", "result", "."...
Return class as interval without formatting.
[ "Return", "class", "as", "interval", "without", "formatting", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L434-L443
train
26,965
inasafe/inasafe
safe/common/utilities.py
unhumanize_number
def unhumanize_number(number): """Return number without formatting. If something goes wrong in the conversion just return the passed number We catch AttributeError in case the number has no replace method which means it is not a string but already an int or float We catch ValueError if number is a ...
python
def unhumanize_number(number): """Return number without formatting. If something goes wrong in the conversion just return the passed number We catch AttributeError in case the number has no replace method which means it is not a string but already an int or float We catch ValueError if number is a ...
[ "def", "unhumanize_number", "(", "number", ")", ":", "try", ":", "number", "=", "number", ".", "replace", "(", "thousand_separator", "(", ")", ",", "''", ")", "number", "=", "int", "(", "float", "(", "number", ")", ")", "except", "(", "AttributeError", ...
Return number without formatting. If something goes wrong in the conversion just return the passed number We catch AttributeError in case the number has no replace method which means it is not a string but already an int or float We catch ValueError if number is a sting but not parseable to a number ...
[ "Return", "number", "without", "formatting", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L446-L463
train
26,966
inasafe/inasafe
safe/common/utilities.py
get_utm_zone
def get_utm_zone(longitude): """Return utm zone.""" zone = int((math.floor((longitude + 180.0) / 6.0) + 1) % 60) if zone == 0: zone = 60 return zone
python
def get_utm_zone(longitude): """Return utm zone.""" zone = int((math.floor((longitude + 180.0) / 6.0) + 1) % 60) if zone == 0: zone = 60 return zone
[ "def", "get_utm_zone", "(", "longitude", ")", ":", "zone", "=", "int", "(", "(", "math", ".", "floor", "(", "(", "longitude", "+", "180.0", ")", "/", "6.0", ")", "+", "1", ")", "%", "60", ")", "if", "zone", "==", "0", ":", "zone", "=", "60", ...
Return utm zone.
[ "Return", "utm", "zone", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L480-L485
train
26,967
inasafe/inasafe
safe/common/utilities.py
get_utm_epsg
def get_utm_epsg(longitude, latitude, crs=None): """Return epsg code of the utm zone according to X, Y coordinates. By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will be reprojected from the input CRS to WGS84. The code is based on the code: http://gis.stackexchange.com/quest...
python
def get_utm_epsg(longitude, latitude, crs=None): """Return epsg code of the utm zone according to X, Y coordinates. By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will be reprojected from the input CRS to WGS84. The code is based on the code: http://gis.stackexchange.com/quest...
[ "def", "get_utm_epsg", "(", "longitude", ",", "latitude", ",", "crs", "=", "None", ")", ":", "if", "crs", "is", "None", "or", "crs", ".", "authid", "(", ")", "==", "'EPSG:4326'", ":", "epsg", "=", "32600", "if", "latitude", "<", "0.0", ":", "epsg", ...
Return epsg code of the utm zone according to X, Y coordinates. By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will be reprojected from the input CRS to WGS84. The code is based on the code: http://gis.stackexchange.com/questions/34401 :param longitude: The longitude. :ty...
[ "Return", "epsg", "code", "of", "the", "utm", "zone", "according", "to", "X", "Y", "coordinates", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L488-L520
train
26,968
inasafe/inasafe
safe/common/utilities.py
color_ramp
def color_ramp(number_of_colour): """Generate list of color in hexadecimal. This will generate colors using hsl model by playing around with the hue see: https://coderwall.com/p/dvsxwg/smoothly-transition-from-green-to-red :param number_of_colour: The number of intervals between R and G spectrum. ...
python
def color_ramp(number_of_colour): """Generate list of color in hexadecimal. This will generate colors using hsl model by playing around with the hue see: https://coderwall.com/p/dvsxwg/smoothly-transition-from-green-to-red :param number_of_colour: The number of intervals between R and G spectrum. ...
[ "def", "color_ramp", "(", "number_of_colour", ")", ":", "if", "number_of_colour", "<", "1", ":", "raise", "Exception", "(", "'The number of colours should be > 0'", ")", "colors", "=", "[", "]", "if", "number_of_colour", "==", "1", ":", "hue_interval", "=", "1",...
Generate list of color in hexadecimal. This will generate colors using hsl model by playing around with the hue see: https://coderwall.com/p/dvsxwg/smoothly-transition-from-green-to-red :param number_of_colour: The number of intervals between R and G spectrum. :type number_of_colour: int :returns...
[ "Generate", "list", "of", "color", "in", "hexadecimal", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L584-L611
train
26,969
inasafe/inasafe
safe/common/utilities.py
romanise
def romanise(number): """Return the roman numeral for a number. Note that this only works for number in interval range [0, 12] since at the moment we only use it on realtime earthquake to conver MMI value. :param number: The number that will be romanised :type number: float :return Roman nume...
python
def romanise(number): """Return the roman numeral for a number. Note that this only works for number in interval range [0, 12] since at the moment we only use it on realtime earthquake to conver MMI value. :param number: The number that will be romanised :type number: float :return Roman nume...
[ "def", "romanise", "(", "number", ")", ":", "if", "number", "is", "None", ":", "return", "''", "roman_list", "=", "[", "'0'", ",", "'I'", ",", "'II'", ",", "'III'", ",", "'IV'", ",", "'V'", ",", "'VI'", ",", "'VII'", ",", "'VIII'", ",", "'IX'", "...
Return the roman numeral for a number. Note that this only works for number in interval range [0, 12] since at the moment we only use it on realtime earthquake to conver MMI value. :param number: The number that will be romanised :type number: float :return Roman numeral equivalent of the value ...
[ "Return", "the", "roman", "numeral", "for", "a", "number", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L625-L646
train
26,970
inasafe/inasafe
safe/common/utilities.py
add_to_list
def add_to_list(my_list, my_element): """Helper function to add new my_element to my_list based on its type. Add as new element if it's not a list, otherwise extend to the list if it's a list. It's also guarantee that all elements are unique :param my_list: A list :type my_list: list :par...
python
def add_to_list(my_list, my_element): """Helper function to add new my_element to my_list based on its type. Add as new element if it's not a list, otherwise extend to the list if it's a list. It's also guarantee that all elements are unique :param my_list: A list :type my_list: list :par...
[ "def", "add_to_list", "(", "my_list", ",", "my_element", ")", ":", "if", "isinstance", "(", "my_element", ",", "list", ")", ":", "for", "element", "in", "my_element", ":", "my_list", "=", "add_to_list", "(", "my_list", ",", "element", ")", "else", ":", "...
Helper function to add new my_element to my_list based on its type. Add as new element if it's not a list, otherwise extend to the list if it's a list. It's also guarantee that all elements are unique :param my_list: A list :type my_list: list :param my_element: A new element :type my_ele...
[ "Helper", "function", "to", "add", "new", "my_element", "to", "my_list", "based", "on", "its", "type", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/utilities.py#L664-L688
train
26,971
inasafe/inasafe
safe/report/extractors/action_notes.py
action_checklist_extractor
def action_checklist_extractor(impact_report, component_metadata): """Extracting action checklist of the exposure 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 c...
python
def action_checklist_extractor(impact_report, component_metadata): """Extracting action checklist of the exposure 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 c...
[ "def", "action_checklist_extractor", "(", "impact_report", ",", "component_metadata", ")", ":", "context", "=", "{", "}", "provenance", "=", "impact_report", ".", "impact_function", ".", "provenance", "extra_args", "=", "component_metadata", ".", "extra_args", "contex...
Extracting action checklist of the exposure 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 informat...
[ "Extracting", "action", "checklist", "of", "the", "exposure", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/action_notes.py#L26-L51
train
26,972
inasafe/inasafe
safe/gui/tools/wizard/layer_browser_proxy_model.py
LayerBrowserProxyModel.filterAcceptsRow
def filterAcceptsRow(self, source_row, source_parent): """The filter method .. note:: This filter hides top-level items of unsupported branches and also leaf items containing xml files. Enabled root items: QgsDirectoryItem, QgsFavouritesItem, QgsPGRootItem. ...
python
def filterAcceptsRow(self, source_row, source_parent): """The filter method .. note:: This filter hides top-level items of unsupported branches and also leaf items containing xml files. Enabled root items: QgsDirectoryItem, QgsFavouritesItem, QgsPGRootItem. ...
[ "def", "filterAcceptsRow", "(", "self", ",", "source_row", ",", "source_parent", ")", ":", "source_index", "=", "self", ".", "sourceModel", "(", ")", ".", "index", "(", "source_row", ",", "0", ",", "source_parent", ")", "item", "=", "self", ".", "sourceMod...
The filter method .. note:: This filter hides top-level items of unsupported branches and also leaf items containing xml files. Enabled root items: QgsDirectoryItem, QgsFavouritesItem, QgsPGRootItem. Disabled root items: QgsMssqlRootItem, QgsSLRootItem, ...
[ "The", "filter", "method" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/layer_browser_proxy_model.py#L31-L73
train
26,973
inasafe/inasafe
safe/gui/tools/field_mapping_dialog.py
FieldMappingDialog.save_metadata
def save_metadata(self): """Save metadata based on the field mapping state.""" metadata = self.field_mapping_widget.get_field_mapping() for key, value in list(metadata['fields'].items()): # Delete the key if it's set to None if key in self.metadata['inasafe_default_values...
python
def save_metadata(self): """Save metadata based on the field mapping state.""" metadata = self.field_mapping_widget.get_field_mapping() for key, value in list(metadata['fields'].items()): # Delete the key if it's set to None if key in self.metadata['inasafe_default_values...
[ "def", "save_metadata", "(", "self", ")", ":", "metadata", "=", "self", ".", "field_mapping_widget", ".", "get_field_mapping", "(", ")", "for", "key", ",", "value", "in", "list", "(", "metadata", "[", "'fields'", "]", ".", "items", "(", ")", ")", ":", ...
Save metadata based on the field mapping state.
[ "Save", "metadata", "based", "on", "the", "field", "mapping", "state", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/field_mapping_dialog.py#L243-L284
train
26,974
inasafe/inasafe
safe/gui/analysis_utilities.py
add_impact_layers_to_canvas
def add_impact_layers_to_canvas(impact_function, group=None, iface=None): """Helper method to add impact layer to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction :param group: An existing group as a parent, optional. :type group: Q...
python
def add_impact_layers_to_canvas(impact_function, group=None, iface=None): """Helper method to add impact layer to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction :param group: An existing group as a parent, optional. :type group: Q...
[ "def", "add_impact_layers_to_canvas", "(", "impact_function", ",", "group", "=", "None", ",", "iface", "=", "None", ")", ":", "layers", "=", "impact_function", ".", "outputs", "name", "=", "impact_function", ".", "name", "if", "group", ":", "group_analysis", "...
Helper method to add impact layer to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction :param group: An existing group as a parent, optional. :type group: QgsLayerTreeGroup :param iface: QGIS QgisAppInterface instance. :type ifa...
[ "Helper", "method", "to", "add", "impact", "layer", "to", "QGIS", "from", "impact", "function", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/analysis_utilities.py#L25-L79
train
26,975
inasafe/inasafe
safe/gui/analysis_utilities.py
add_debug_layers_to_canvas
def add_debug_layers_to_canvas(impact_function): """Helper method to add debug layers to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction """ name = 'DEBUG %s' % impact_function.name root = QgsProject.instance().layerTreeRoot() ...
python
def add_debug_layers_to_canvas(impact_function): """Helper method to add debug layers to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction """ name = 'DEBUG %s' % impact_function.name root = QgsProject.instance().layerTreeRoot() ...
[ "def", "add_debug_layers_to_canvas", "(", "impact_function", ")", ":", "name", "=", "'DEBUG %s'", "%", "impact_function", ".", "name", "root", "=", "QgsProject", ".", "instance", "(", ")", ".", "layerTreeRoot", "(", ")", "group_debug", "=", "root", ".", "inser...
Helper method to add debug layers to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction
[ "Helper", "method", "to", "add", "debug", "layers", "to", "QGIS", "from", "impact", "function", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/analysis_utilities.py#L82-L131
train
26,976
inasafe/inasafe
safe/gui/analysis_utilities.py
add_layers_to_canvas_with_custom_orders
def add_layers_to_canvas_with_custom_orders( order, impact_function, iface=None): """Helper to add layers to the map canvas following a specific order. From top to bottom in the legend: [ ('FromCanvas', layer name, full layer URI, QML), ('FromAnalysis', layer purpose, la...
python
def add_layers_to_canvas_with_custom_orders( order, impact_function, iface=None): """Helper to add layers to the map canvas following a specific order. From top to bottom in the legend: [ ('FromCanvas', layer name, full layer URI, QML), ('FromAnalysis', layer purpose, la...
[ "def", "add_layers_to_canvas_with_custom_orders", "(", "order", ",", "impact_function", ",", "iface", "=", "None", ")", ":", "root", "=", "QgsProject", ".", "instance", "(", ")", ".", "layerTreeRoot", "(", ")", "# Make all layers hidden.", "for", "child", "in", ...
Helper to add layers to the map canvas following a specific order. From top to bottom in the legend: [ ('FromCanvas', layer name, full layer URI, QML), ('FromAnalysis', layer purpose, layer group, None), ... ] The full layer URI is coming from our helper...
[ "Helper", "to", "add", "layers", "to", "the", "map", "canvas", "following", "a", "specific", "order", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/analysis_utilities.py#L134-L216
train
26,977
inasafe/inasafe
safe/gui/analysis_utilities.py
add_layer_to_canvas
def add_layer_to_canvas(layer, name): """Helper method to add layer to QGIS. :param layer: The layer. :type layer: QgsMapLayer :param name: Layer name. :type name: str """ if qgis_version() >= 21800: layer.setName(name) else: layer.setLayerName(name) QgsProject.in...
python
def add_layer_to_canvas(layer, name): """Helper method to add layer to QGIS. :param layer: The layer. :type layer: QgsMapLayer :param name: Layer name. :type name: str """ if qgis_version() >= 21800: layer.setName(name) else: layer.setLayerName(name) QgsProject.in...
[ "def", "add_layer_to_canvas", "(", "layer", ",", "name", ")", ":", "if", "qgis_version", "(", ")", ">=", "21800", ":", "layer", ".", "setName", "(", "name", ")", "else", ":", "layer", ".", "setLayerName", "(", "name", ")", "QgsProject", ".", "instance", ...
Helper method to add layer to QGIS. :param layer: The layer. :type layer: QgsMapLayer :param name: Layer name. :type name: str
[ "Helper", "method", "to", "add", "layer", "to", "QGIS", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/analysis_utilities.py#L219-L234
train
26,978
inasafe/inasafe
safe/gis/vector/summary_4_exposure_summary_table.py
summarize_result
def summarize_result(exposure_summary): """Extract result based on summarizer field value and sum by exposure type. :param exposure_summary: The layer impact layer. :type exposure_summary: QgsVectorLayer :return: Dictionary of attributes per exposure per summarizer field. :rtype: dict .. vers...
python
def summarize_result(exposure_summary): """Extract result based on summarizer field value and sum by exposure type. :param exposure_summary: The layer impact layer. :type exposure_summary: QgsVectorLayer :return: Dictionary of attributes per exposure per summarizer field. :rtype: dict .. vers...
[ "def", "summarize_result", "(", "exposure_summary", ")", ":", "summarization_dicts", "=", "{", "}", "summarizer_flags", "=", "{", "}", "# for summarizer_field in summarizer_fields:", "for", "key", ",", "summary_rule", "in", "list", "(", "summary_rules", ".", "items", ...
Extract result based on summarizer field value and sum by exposure type. :param exposure_summary: The layer impact layer. :type exposure_summary: QgsVectorLayer :return: Dictionary of attributes per exposure per summarizer field. :rtype: dict .. versionadded:: 4.2
[ "Extract", "result", "based", "on", "summarizer", "field", "value", "and", "sum", "by", "exposure", "type", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/summary_4_exposure_summary_table.py#L279-L321
train
26,979
inasafe/inasafe
safe/metadata/utilities.py
prettify_xml
def prettify_xml(xml_str): """ returns prettified XML without blank lines based on http://stackoverflow.com/questions/14479656/ :param xml_str: the XML to be prettified :type xml_str: str :return: the prettified XML :rtype: str """ parsed_xml = parseString(get_string(xml_str)) p...
python
def prettify_xml(xml_str): """ returns prettified XML without blank lines based on http://stackoverflow.com/questions/14479656/ :param xml_str: the XML to be prettified :type xml_str: str :return: the prettified XML :rtype: str """ parsed_xml = parseString(get_string(xml_str)) p...
[ "def", "prettify_xml", "(", "xml_str", ")", ":", "parsed_xml", "=", "parseString", "(", "get_string", "(", "xml_str", ")", ")", "pretty_xml", "=", "'\\n'", ".", "join", "(", "[", "line", "for", "line", "in", "parsed_xml", ".", "toprettyxml", "(", "indent",...
returns prettified XML without blank lines based on http://stackoverflow.com/questions/14479656/ :param xml_str: the XML to be prettified :type xml_str: str :return: the prettified XML :rtype: str
[ "returns", "prettified", "XML", "without", "blank", "lines" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/utilities.py#L106-L122
train
26,980
inasafe/inasafe
safe/metadata/utilities.py
serialize_dictionary
def serialize_dictionary(dictionary): """Function to stringify a dictionary recursively. :param dictionary: The dictionary. :type dictionary: dict :return: The string. :rtype: basestring """ string_value = {} for k, v in list(dictionary.items()): if isinstance(v, QUrl): ...
python
def serialize_dictionary(dictionary): """Function to stringify a dictionary recursively. :param dictionary: The dictionary. :type dictionary: dict :return: The string. :rtype: basestring """ string_value = {} for k, v in list(dictionary.items()): if isinstance(v, QUrl): ...
[ "def", "serialize_dictionary", "(", "dictionary", ")", ":", "string_value", "=", "{", "}", "for", "k", ",", "v", "in", "list", "(", "dictionary", ".", "items", "(", ")", ")", ":", "if", "isinstance", "(", "v", ",", "QUrl", ")", ":", "string_value", "...
Function to stringify a dictionary recursively. :param dictionary: The dictionary. :type dictionary: dict :return: The string. :rtype: basestring
[ "Function", "to", "stringify", "a", "dictionary", "recursively", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/utilities.py#L125-L149
train
26,981
inasafe/inasafe
safe/impact_function/create_extra_layers.py
create_virtual_aggregation
def create_virtual_aggregation(geometry, crs): """Function to create aggregation layer based on extent. :param geometry: The geometry to use as an extent. :type geometry: QgsGeometry :param crs: The Coordinate Reference System to use for the layer. :type crs: QgsCoordinateReferenceSystem :ret...
python
def create_virtual_aggregation(geometry, crs): """Function to create aggregation layer based on extent. :param geometry: The geometry to use as an extent. :type geometry: QgsGeometry :param crs: The Coordinate Reference System to use for the layer. :type crs: QgsCoordinateReferenceSystem :ret...
[ "def", "create_virtual_aggregation", "(", "geometry", ",", "crs", ")", ":", "fields", "=", "[", "create_field_from_definition", "(", "aggregation_id_field", ")", ",", "create_field_from_definition", "(", "aggregation_name_field", ")", "]", "aggregation_layer", "=", "cre...
Function to create aggregation layer based on extent. :param geometry: The geometry to use as an extent. :type geometry: QgsGeometry :param crs: The Coordinate Reference System to use for the layer. :type crs: QgsCoordinateReferenceSystem :returns: A polygon layer with exposure's crs. :rtype:...
[ "Function", "to", "create", "aggregation", "layer", "based", "on", "extent", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/create_extra_layers.py#L43-L83
train
26,982
inasafe/inasafe
safe/impact_function/create_extra_layers.py
create_analysis_layer
def create_analysis_layer(analysis_extent, crs, name): """Create the analysis layer. :param analysis_extent: The analysis extent. :type analysis_extent: QgsGeometry :param crs: The CRS to use. :type crs: QgsCoordinateReferenceSystem :param name: The name of the analysis. :type name: bases...
python
def create_analysis_layer(analysis_extent, crs, name): """Create the analysis layer. :param analysis_extent: The analysis extent. :type analysis_extent: QgsGeometry :param crs: The CRS to use. :type crs: QgsCoordinateReferenceSystem :param name: The name of the analysis. :type name: bases...
[ "def", "create_analysis_layer", "(", "analysis_extent", ",", "crs", ",", "name", ")", ":", "fields", "=", "[", "create_field_from_definition", "(", "analysis_name_field", ")", "]", "analysis_layer", "=", "create_memory_layer", "(", "'analysis'", ",", "QgsWkbTypes", ...
Create the analysis layer. :param analysis_extent: The analysis extent. :type analysis_extent: QgsGeometry :param crs: The CRS to use. :type crs: QgsCoordinateReferenceSystem :param name: The name of the analysis. :type name: basestring :returns: A polygon layer with exposure's crs. ...
[ "Create", "the", "analysis", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/create_extra_layers.py#L87-L127
train
26,983
inasafe/inasafe
safe/impact_function/create_extra_layers.py
create_profile_layer
def create_profile_layer(profiling): """Create a tabular layer with the profiling. :param profiling: A dict containing benchmarking data. :type profiling: safe.messaging.message.Message :return: A tabular layer. :rtype: QgsVectorLayer """ fields = [ create_field_from_definition(pro...
python
def create_profile_layer(profiling): """Create a tabular layer with the profiling. :param profiling: A dict containing benchmarking data. :type profiling: safe.messaging.message.Message :return: A tabular layer. :rtype: QgsVectorLayer """ fields = [ create_field_from_definition(pro...
[ "def", "create_profile_layer", "(", "profiling", ")", ":", "fields", "=", "[", "create_field_from_definition", "(", "profiling_function_field", ")", ",", "create_field_from_definition", "(", "profiling_time_field", ")", "]", "if", "setting", "(", "key", "=", "'memory_...
Create a tabular layer with the profiling. :param profiling: A dict containing benchmarking data. :type profiling: safe.messaging.message.Message :return: A tabular layer. :rtype: QgsVectorLayer
[ "Create", "a", "tabular", "layer", "with", "the", "profiling", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/create_extra_layers.py#L130-L184
train
26,984
inasafe/inasafe
safe/impact_function/create_extra_layers.py
create_valid_aggregation
def create_valid_aggregation(layer): """Create a local copy of the aggregation layer and try to make it valid. We need to make the layer valid if we can. We got some issues with DKI Jakarta dataset : Districts and Subdistricts layers. See issue : https://github.com/inasafe/inasafe/issues/3713 :par...
python
def create_valid_aggregation(layer): """Create a local copy of the aggregation layer and try to make it valid. We need to make the layer valid if we can. We got some issues with DKI Jakarta dataset : Districts and Subdistricts layers. See issue : https://github.com/inasafe/inasafe/issues/3713 :par...
[ "def", "create_valid_aggregation", "(", "layer", ")", ":", "cleaned", "=", "create_memory_layer", "(", "'aggregation'", ",", "layer", ".", "geometryType", "(", ")", ",", "layer", ".", "crs", "(", ")", ",", "layer", ".", "fields", "(", ")", ")", "# We trans...
Create a local copy of the aggregation layer and try to make it valid. We need to make the layer valid if we can. We got some issues with DKI Jakarta dataset : Districts and Subdistricts layers. See issue : https://github.com/inasafe/inasafe/issues/3713 :param layer: The aggregation layer. :type l...
[ "Create", "a", "local", "copy", "of", "the", "aggregation", "layer", "and", "try", "to", "make", "it", "valid", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/create_extra_layers.py#L187-L214
train
26,985
inasafe/inasafe
safe/gui/tools/wizard/step_fc70_extent.py
StepFcExtent.stop_capture_coordinates
def stop_capture_coordinates(self): """Exit the coordinate capture mode.""" self.extent_dialog._populate_coordinates() self.extent_dialog.canvas.setMapTool( self.extent_dialog.previous_map_tool) self.parent.show()
python
def stop_capture_coordinates(self): """Exit the coordinate capture mode.""" self.extent_dialog._populate_coordinates() self.extent_dialog.canvas.setMapTool( self.extent_dialog.previous_map_tool) self.parent.show()
[ "def", "stop_capture_coordinates", "(", "self", ")", ":", "self", ".", "extent_dialog", ".", "_populate_coordinates", "(", ")", "self", ".", "extent_dialog", ".", "canvas", ".", "setMapTool", "(", "self", ".", "extent_dialog", ".", "previous_map_tool", ")", "sel...
Exit the coordinate capture mode.
[ "Exit", "the", "coordinate", "capture", "mode", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc70_extent.py#L72-L77
train
26,986
inasafe/inasafe
safe/gui/tools/wizard/step_fc70_extent.py
StepFcExtent.write_extent
def write_extent(self): """After the extent selection, save the extent and disconnect signals. """ self.extent_dialog.accept() self.extent_dialog.clear_extent.disconnect( self.parent.dock.extent.clear_user_analysis_extent) self.extent_dialog.extent_defined.disconnect(...
python
def write_extent(self): """After the extent selection, save the extent and disconnect signals. """ self.extent_dialog.accept() self.extent_dialog.clear_extent.disconnect( self.parent.dock.extent.clear_user_analysis_extent) self.extent_dialog.extent_defined.disconnect(...
[ "def", "write_extent", "(", "self", ")", ":", "self", ".", "extent_dialog", ".", "accept", "(", ")", "self", ".", "extent_dialog", ".", "clear_extent", ".", "disconnect", "(", "self", ".", "parent", ".", "dock", ".", "extent", ".", "clear_user_analysis_exten...
After the extent selection, save the extent and disconnect signals.
[ "After", "the", "extent", "selection", "save", "the", "extent", "and", "disconnect", "signals", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc70_extent.py#L79-L90
train
26,987
inasafe/inasafe
safe/gui/tools/wizard/step_fc70_extent.py
StepFcExtent.set_widgets
def set_widgets(self): """Set widgets on the Extent tab.""" self.extent_dialog = ExtentSelectorDialog( self.parent.iface, self.parent.iface.mainWindow(), extent=self.parent.dock.extent.user_extent, crs=self.parent.dock.extent.crs) self.extent_dialo...
python
def set_widgets(self): """Set widgets on the Extent tab.""" self.extent_dialog = ExtentSelectorDialog( self.parent.iface, self.parent.iface.mainWindow(), extent=self.parent.dock.extent.user_extent, crs=self.parent.dock.extent.crs) self.extent_dialo...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "extent_dialog", "=", "ExtentSelectorDialog", "(", "self", ".", "parent", ".", "iface", ",", "self", ".", "parent", ".", "iface", ".", "mainWindow", "(", ")", ",", "extent", "=", "self", ".", "p...
Set widgets on the Extent tab.
[ "Set", "widgets", "on", "the", "Extent", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc70_extent.py#L92-L117
train
26,988
inasafe/inasafe
safe/gis/raster/clip_bounding_box.py
clip_by_extent
def clip_by_extent(layer, extent): """Clip a raster using a bounding box using processing. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to clip. :type layer: QgsRasterLayer :param extent: The extent. :type extent: QgsRectangle :return: Clipped layer. :...
python
def clip_by_extent(layer, extent): """Clip a raster using a bounding box using processing. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to clip. :type layer: QgsRasterLayer :param extent: The extent. :type extent: QgsRectangle :return: Clipped layer. :...
[ "def", "clip_by_extent", "(", "layer", ",", "extent", ")", ":", "parameters", "=", "dict", "(", ")", "# noinspection PyBroadException", "try", ":", "output_layer_name", "=", "quick_clip_steps", "[", "'output_layer_name'", "]", "output_layer_name", "=", "output_layer_n...
Clip a raster using a bounding box using processing. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to clip. :type layer: QgsRasterLayer :param extent: The extent. :type extent: QgsRectangle :return: Clipped layer. :rtype: QgsRasterLayer .. versionadded...
[ "Clip", "a", "raster", "using", "a", "bounding", "box", "using", "processing", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/clip_bounding_box.py#L31-L135
train
26,989
inasafe/inasafe
extras/xml_tools.py
get_elements
def get_elements(nodelist): """Return list of nodes that are ELEMENT_NODE """ element_list = [] for node in nodelist: if node.nodeType == Node.ELEMENT_NODE: element_list.append(node) return element_list
python
def get_elements(nodelist): """Return list of nodes that are ELEMENT_NODE """ element_list = [] for node in nodelist: if node.nodeType == Node.ELEMENT_NODE: element_list.append(node) return element_list
[ "def", "get_elements", "(", "nodelist", ")", ":", "element_list", "=", "[", "]", "for", "node", "in", "nodelist", ":", "if", "node", ".", "nodeType", "==", "Node", ".", "ELEMENT_NODE", ":", "element_list", ".", "append", "(", "node", ")", "return", "elem...
Return list of nodes that are ELEMENT_NODE
[ "Return", "list", "of", "nodes", "that", "are", "ELEMENT_NODE" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/xml_tools.py#L40-L49
train
26,990
inasafe/inasafe
extras/xml_tools.py
get_text
def get_text(nodelist): """Return a concatenation of text fields from list of nodes """ s = '' for node in nodelist: if node.nodeType == Node.TEXT_NODE: s += node.nodeValue + ', ' if len(s)>0: s = s[:-2] return s
python
def get_text(nodelist): """Return a concatenation of text fields from list of nodes """ s = '' for node in nodelist: if node.nodeType == Node.TEXT_NODE: s += node.nodeValue + ', ' if len(s)>0: s = s[:-2] return s
[ "def", "get_text", "(", "nodelist", ")", ":", "s", "=", "''", "for", "node", "in", "nodelist", ":", "if", "node", ".", "nodeType", "==", "Node", ".", "TEXT_NODE", ":", "s", "+=", "node", ".", "nodeValue", "+", "', '", "if", "len", "(", "s", ")", ...
Return a concatenation of text fields from list of nodes
[ "Return", "a", "concatenation", "of", "text", "fields", "from", "list", "of", "nodes" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/xml_tools.py#L52-L62
train
26,991
inasafe/inasafe
extras/xml_tools.py
xml2object
def xml2object(xml, verbose=False): """Generate XML object model from XML file or XML text This is the inverse operation to the __str__ representation (up to whitespace). Input xml can be either an * xml file * open xml file object Return XML_document instance. """ # FIXME - can ...
python
def xml2object(xml, verbose=False): """Generate XML object model from XML file or XML text This is the inverse operation to the __str__ representation (up to whitespace). Input xml can be either an * xml file * open xml file object Return XML_document instance. """ # FIXME - can ...
[ "def", "xml2object", "(", "xml", ",", "verbose", "=", "False", ")", ":", "# FIXME - can we allow xml to be string?", "# This would depend on minidom's parse function", "# Input tests", "if", "isinstance", "(", "xml", ",", "basestring", ")", ":", "fid", "=", "open", "(...
Generate XML object model from XML file or XML text This is the inverse operation to the __str__ representation (up to whitespace). Input xml can be either an * xml file * open xml file object Return XML_document instance.
[ "Generate", "XML", "object", "model", "from", "XML", "file", "or", "XML", "text" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/xml_tools.py#L219-L256
train
26,992
inasafe/inasafe
extras/xml_tools.py
dom2object
def dom2object(node): """Convert DOM representation to XML_object hierarchy. """ value = [] textnode_encountered = None for n in node.childNodes: if n.nodeType == 3: # Child is a text element - omit the dom tag #text and # go straight to the text value. ...
python
def dom2object(node): """Convert DOM representation to XML_object hierarchy. """ value = [] textnode_encountered = None for n in node.childNodes: if n.nodeType == 3: # Child is a text element - omit the dom tag #text and # go straight to the text value. ...
[ "def", "dom2object", "(", "node", ")", ":", "value", "=", "[", "]", "textnode_encountered", "=", "None", "for", "n", "in", "node", ".", "childNodes", ":", "if", "n", ".", "nodeType", "==", "3", ":", "# Child is a text element - omit the dom tag #text and", "# ...
Convert DOM representation to XML_object hierarchy.
[ "Convert", "DOM", "representation", "to", "XML_object", "hierarchy", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/xml_tools.py#L260-L313
train
26,993
inasafe/inasafe
extras/xml_tools.py
XML_element.pretty_print
def pretty_print(self, indent=0): """Print the document without tags using indentation """ s = tab = ' '*indent s += '%s: ' %self.tag if isinstance(self.value, basestring): s += self.value else: s += '\n' for e in self.value: ...
python
def pretty_print(self, indent=0): """Print the document without tags using indentation """ s = tab = ' '*indent s += '%s: ' %self.tag if isinstance(self.value, basestring): s += self.value else: s += '\n' for e in self.value: ...
[ "def", "pretty_print", "(", "self", ",", "indent", "=", "0", ")", ":", "s", "=", "tab", "=", "' '", "*", "indent", "s", "+=", "'%s: '", "%", "self", ".", "tag", "if", "isinstance", "(", "self", ".", "value", ",", "basestring", ")", ":", "s", "+="...
Print the document without tags using indentation
[ "Print", "the", "document", "without", "tags", "using", "indentation" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/xml_tools.py#L202-L216
train
26,994
inasafe/inasafe
safe/gui/tools/wizard/step_kw10_hazard_category.py
StepKwHazardCategory.on_lstHazardCategories_itemSelectionChanged
def on_lstHazardCategories_itemSelectionChanged(self): """Update hazard category description label. .. note:: This is an automatic Qt slot executed when the category selection changes. """ self.clear_further_steps() # Set widgets hazard_category = self.selecte...
python
def on_lstHazardCategories_itemSelectionChanged(self): """Update hazard category description label. .. note:: This is an automatic Qt slot executed when the category selection changes. """ self.clear_further_steps() # Set widgets hazard_category = self.selecte...
[ "def", "on_lstHazardCategories_itemSelectionChanged", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "# Set widgets", "hazard_category", "=", "self", ".", "selected_hazard_category", "(", ")", "# Exit if no selection", "if", "not", "hazard_category",...
Update hazard category description label. .. note:: This is an automatic Qt slot executed when the category selection changes.
[ "Update", "hazard", "category", "description", "label", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw10_hazard_category.py#L67-L82
train
26,995
inasafe/inasafe
safe/gui/tools/wizard/step_kw10_hazard_category.py
StepKwHazardCategory.selected_hazard_category
def selected_hazard_category(self): """Obtain the hazard category selected by user. :returns: Metadata of the selected hazard category. :rtype: dict, None """ item = self.lstHazardCategories.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) ...
python
def selected_hazard_category(self): """Obtain the hazard category selected by user. :returns: Metadata of the selected hazard category. :rtype: dict, None """ item = self.lstHazardCategories.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) ...
[ "def", "selected_hazard_category", "(", "self", ")", ":", "item", "=", "self", ".", "lstHazardCategories", ".", "currentItem", "(", ")", "try", ":", "return", "definition", "(", "item", ".", "data", "(", "QtCore", ".", "Qt", ".", "UserRole", ")", ")", "e...
Obtain the hazard category selected by user. :returns: Metadata of the selected hazard category. :rtype: dict, None
[ "Obtain", "the", "hazard", "category", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw10_hazard_category.py#L84-L94
train
26,996
inasafe/inasafe
safe/gui/tools/wizard/step_kw10_hazard_category.py
StepKwHazardCategory.set_widgets
def set_widgets(self): """Set widgets on the Hazard Category tab.""" self.clear_further_steps() # Set widgets self.lstHazardCategories.clear() self.lblDescribeHazardCategory.setText('') self.lblSelectHazardCategory.setText( hazard_category_question) ha...
python
def set_widgets(self): """Set widgets on the Hazard Category tab.""" self.clear_further_steps() # Set widgets self.lstHazardCategories.clear() self.lblDescribeHazardCategory.setText('') self.lblSelectHazardCategory.setText( hazard_category_question) ha...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "# Set widgets", "self", ".", "lstHazardCategories", ".", "clear", "(", ")", "self", ".", "lblDescribeHazardCategory", ".", "setText", "(", "''", ")", "self", ".", "lb...
Set widgets on the Hazard Category tab.
[ "Set", "widgets", "on", "the", "Hazard", "Category", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw10_hazard_category.py#L104-L136
train
26,997
inasafe/inasafe
safe/gis/raster/polygonize.py
polygonize
def polygonize(layer): """Polygonize a raster layer into a vector layer using GDAL. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsRasterLayer :return: Reprojected memory layer. :rtype: QgsRasterLayer .. versionadded:: 4.0 "...
python
def polygonize(layer): """Polygonize a raster layer into a vector layer using GDAL. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsRasterLayer :return: Reprojected memory layer. :rtype: QgsRasterLayer .. versionadded:: 4.0 "...
[ "def", "polygonize", "(", "layer", ")", ":", "output_layer_name", "=", "polygonize_steps", "[", "'output_layer_name'", "]", "output_layer_name", "=", "output_layer_name", "%", "layer", ".", "keywords", "[", "'layer_purpose'", "]", "gdal_layer_name", "=", "polygonize_s...
Polygonize a raster layer into a vector layer using GDAL. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsRasterLayer :return: Reprojected memory layer. :rtype: QgsRasterLayer .. versionadded:: 4.0
[ "Polygonize", "a", "raster", "layer", "into", "a", "vector", "layer", "using", "GDAL", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/polygonize.py#L28-L98
train
26,998
inasafe/inasafe
safe/common/parameters/default_value_parameter.py
DefaultValueParameter.value
def value(self, value): """Setter for value. :param value: The value. :type value: object """ # For custom value if value not in self.options: if len(self.labels) == len(self.options): self.options[-1] = value else: ...
python
def value(self, value): """Setter for value. :param value: The value. :type value: object """ # For custom value if value not in self.options: if len(self.labels) == len(self.options): self.options[-1] = value else: ...
[ "def", "value", "(", "self", ",", "value", ")", ":", "# For custom value", "if", "value", "not", "in", "self", ".", "options", ":", "if", "len", "(", "self", ".", "labels", ")", "==", "len", "(", "self", ".", "options", ")", ":", "self", ".", "opti...
Setter for value. :param value: The value. :type value: object
[ "Setter", "for", "value", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_value_parameter.py#L69-L82
train
26,999