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/utilities/settings.py
export_setting
def export_setting(file_path, qsettings=None): """Export InaSAFE's setting to a file. :param file_path: The file to write the exported setting. :type file_path: basestring :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis.P...
python
def export_setting(file_path, qsettings=None): """Export InaSAFE's setting to a file. :param file_path: The file to write the exported setting. :type file_path: basestring :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis.P...
[ "def", "export_setting", "(", "file_path", ",", "qsettings", "=", "None", ")", ":", "inasafe_settings", "=", "{", "}", "if", "not", "qsettings", ":", "qsettings", "=", "QSettings", "(", ")", "qsettings", ".", "beginGroup", "(", "'inasafe'", ")", "all_keys", ...
Export InaSAFE's setting to a file. :param file_path: The file to write the exported setting. :type file_path: basestring :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis.PyQt.QtCore.QSettings :returns: A dictionary of th...
[ "Export", "InaSAFE", "s", "setting", "to", "a", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L173-L207
train
27,200
inasafe/inasafe
safe/utilities/settings.py
import_setting
def import_setting(file_path, qsettings=None): """Import InaSAFE's setting from a file. :param file_path: The file to read the imported setting. :type file_path: basestring :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis....
python
def import_setting(file_path, qsettings=None): """Import InaSAFE's setting from a file. :param file_path: The file to read the imported setting. :type file_path: basestring :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis....
[ "def", "import_setting", "(", "file_path", ",", "qsettings", "=", "None", ")", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "f", ":", "inasafe_settings", "=", "json", ".", "load", "(", "f", ")", "if", "not", "qsettings", ":", "qsetting...
Import InaSAFE's setting from a file. :param file_path: The file to read the imported setting. :type file_path: basestring :param qsettings: A custom QSettings to use. If it's not defined, it will use the default one. :type qsettings: qgis.PyQt.QtCore.QSettings :returns: A dictionary of t...
[ "Import", "InaSAFE", "s", "setting", "from", "a", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/settings.py#L210-L237
train
27,201
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.save_boolean_setting
def save_boolean_setting(self, key, check_box): """Save boolean setting according to check_box state. :param key: Key to retrieve setting value. :type key: str :param check_box: Check box to show and set the setting. :type check_box: PyQt5.QtWidgets.QCheckBox.QCheckBox ...
python
def save_boolean_setting(self, key, check_box): """Save boolean setting according to check_box state. :param key: Key to retrieve setting value. :type key: str :param check_box: Check box to show and set the setting. :type check_box: PyQt5.QtWidgets.QCheckBox.QCheckBox ...
[ "def", "save_boolean_setting", "(", "self", ",", "key", ",", "check_box", ")", ":", "set_setting", "(", "key", ",", "check_box", ".", "isChecked", "(", ")", ",", "qsettings", "=", "self", ".", "settings", ")" ]
Save boolean setting according to check_box state. :param key: Key to retrieve setting value. :type key: str :param check_box: Check box to show and set the setting. :type check_box: PyQt5.QtWidgets.QCheckBox.QCheckBox
[ "Save", "boolean", "setting", "according", "to", "check_box", "state", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L256-L265
train
27,202
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.restore_boolean_setting
def restore_boolean_setting(self, key, check_box): """Set check_box according to setting of key. :param key: Key to retrieve setting value. :type key: str :param check_box: Check box to show and set the setting. :type check_box: PyQt5.QtWidgets.QCheckBox.QCheckBox """ ...
python
def restore_boolean_setting(self, key, check_box): """Set check_box according to setting of key. :param key: Key to retrieve setting value. :type key: str :param check_box: Check box to show and set the setting. :type check_box: PyQt5.QtWidgets.QCheckBox.QCheckBox """ ...
[ "def", "restore_boolean_setting", "(", "self", ",", "key", ",", "check_box", ")", ":", "flag", "=", "setting", "(", "key", ",", "expected_type", "=", "bool", ",", "qsettings", "=", "self", ".", "settings", ")", "check_box", ".", "setChecked", "(", "flag", ...
Set check_box according to setting of key. :param key: Key to retrieve setting value. :type key: str :param check_box: Check box to show and set the setting. :type check_box: PyQt5.QtWidgets.QCheckBox.QCheckBox
[ "Set", "check_box", "according", "to", "setting", "of", "key", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L267-L277
train
27,203
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.save_text_setting
def save_text_setting(self, key, line_edit): """Save text setting according to line_edit value. :param key: Key to retrieve setting value. :type key: str :param line_edit: Line edit for user to edit the setting :type line_edit: PyQt5.QtWidgets.QLineEdit.QLineEdit """ ...
python
def save_text_setting(self, key, line_edit): """Save text setting according to line_edit value. :param key: Key to retrieve setting value. :type key: str :param line_edit: Line edit for user to edit the setting :type line_edit: PyQt5.QtWidgets.QLineEdit.QLineEdit """ ...
[ "def", "save_text_setting", "(", "self", ",", "key", ",", "line_edit", ")", ":", "set_setting", "(", "key", ",", "line_edit", ".", "text", "(", ")", ",", "self", ".", "settings", ")" ]
Save text setting according to line_edit value. :param key: Key to retrieve setting value. :type key: str :param line_edit: Line edit for user to edit the setting :type line_edit: PyQt5.QtWidgets.QLineEdit.QLineEdit
[ "Save", "text", "setting", "according", "to", "line_edit", "value", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L279-L288
train
27,204
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.restore_text_setting
def restore_text_setting(self, key, line_edit): """Set line_edit text according to setting of key. :param key: Key to retrieve setting value. :type key: str :param line_edit: Line edit for user to edit the setting :type line_edit: PyQt5.QtWidgets.QLineEdit.QLineEdit """...
python
def restore_text_setting(self, key, line_edit): """Set line_edit text according to setting of key. :param key: Key to retrieve setting value. :type key: str :param line_edit: Line edit for user to edit the setting :type line_edit: PyQt5.QtWidgets.QLineEdit.QLineEdit """...
[ "def", "restore_text_setting", "(", "self", ",", "key", ",", "line_edit", ")", ":", "value", "=", "setting", "(", "key", ",", "expected_type", "=", "str", ",", "qsettings", "=", "self", ".", "settings", ")", "line_edit", ".", "setText", "(", "value", ")"...
Set line_edit text according to setting of key. :param key: Key to retrieve setting value. :type key: str :param line_edit: Line edit for user to edit the setting :type line_edit: PyQt5.QtWidgets.QLineEdit.QLineEdit
[ "Set", "line_edit", "text", "according", "to", "setting", "of", "key", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L290-L300
train
27,205
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.update_earthquake_info
def update_earthquake_info(self): """Update information about earthquake info.""" self.label_earthquake_model() current_index = self.earthquake_function.currentIndex() model = EARTHQUAKE_FUNCTIONS[current_index] notes = '' for note in model['notes']: notes += ...
python
def update_earthquake_info(self): """Update information about earthquake info.""" self.label_earthquake_model() current_index = self.earthquake_function.currentIndex() model = EARTHQUAKE_FUNCTIONS[current_index] notes = '' for note in model['notes']: notes += ...
[ "def", "update_earthquake_info", "(", "self", ")", ":", "self", ".", "label_earthquake_model", "(", ")", "current_index", "=", "self", ".", "earthquake_function", ".", "currentIndex", "(", ")", "model", "=", "EARTHQUAKE_FUNCTIONS", "[", "current_index", "]", "note...
Update information about earthquake info.
[ "Update", "information", "about", "earthquake", "info", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L457-L478
train
27,206
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.open_keyword_cache_path
def open_keyword_cache_path(self): """Open File dialog to choose the keyword cache path.""" # noinspection PyCallByClass,PyTypeChecker file_name, __ = QFileDialog.getSaveFileName( self, self.tr('Set keyword cache file'), self.leKeywordCachePath.text(), ...
python
def open_keyword_cache_path(self): """Open File dialog to choose the keyword cache path.""" # noinspection PyCallByClass,PyTypeChecker file_name, __ = QFileDialog.getSaveFileName( self, self.tr('Set keyword cache file'), self.leKeywordCachePath.text(), ...
[ "def", "open_keyword_cache_path", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "file_name", ",", "__", "=", "QFileDialog", ".", "getSaveFileName", "(", "self", ",", "self", ".", "tr", "(", "'Set keyword cache file'", ")", ",", "self", ".", ...
Open File dialog to choose the keyword cache path.
[ "Open", "File", "dialog", "to", "choose", "the", "keyword", "cache", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L487-L496
train
27,207
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.open_user_directory_path
def open_user_directory_path(self): """Open File dialog to choose the user directory path.""" # noinspection PyCallByClass,PyTypeChecker directory_name = QFileDialog.getExistingDirectory( self, self.tr('Results directory'), self.leUserDirectoryPath.text(), ...
python
def open_user_directory_path(self): """Open File dialog to choose the user directory path.""" # noinspection PyCallByClass,PyTypeChecker directory_name = QFileDialog.getExistingDirectory( self, self.tr('Results directory'), self.leUserDirectoryPath.text(), ...
[ "def", "open_user_directory_path", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "directory_name", "=", "QFileDialog", ".", "getExistingDirectory", "(", "self", ",", "self", ".", "tr", "(", "'Results directory'", ")", ",", "self", ".", "leUserDi...
Open File dialog to choose the user directory path.
[ "Open", "File", "dialog", "to", "choose", "the", "user", "directory", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L498-L507
train
27,208
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.open_north_arrow_path
def open_north_arrow_path(self): """Open File dialog to choose the north arrow path.""" # noinspection PyCallByClass,PyTypeChecker file_name, __ = QFileDialog.getOpenFileName( self, self.tr('Set north arrow image file'), self.leNorthArrowPath.text(), ...
python
def open_north_arrow_path(self): """Open File dialog to choose the north arrow path.""" # noinspection PyCallByClass,PyTypeChecker file_name, __ = QFileDialog.getOpenFileName( self, self.tr('Set north arrow image file'), self.leNorthArrowPath.text(), ...
[ "def", "open_north_arrow_path", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "file_name", ",", "__", "=", "QFileDialog", ".", "getOpenFileName", "(", "self", ",", "self", ".", "tr", "(", "'Set north arrow image file'", ")", ",", "self", ".", ...
Open File dialog to choose the north arrow path.
[ "Open", "File", "dialog", "to", "choose", "the", "north", "arrow", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L509-L522
train
27,209
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.open_organisation_logo_path
def open_organisation_logo_path(self): """Open File dialog to choose the organisation logo path.""" # noinspection PyCallByClass,PyTypeChecker file_name, __ = QFileDialog.getOpenFileName( self, self.tr('Set organisation logo file'), self.organisation_logo_path...
python
def open_organisation_logo_path(self): """Open File dialog to choose the organisation logo path.""" # noinspection PyCallByClass,PyTypeChecker file_name, __ = QFileDialog.getOpenFileName( self, self.tr('Set organisation logo file'), self.organisation_logo_path...
[ "def", "open_organisation_logo_path", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "file_name", ",", "__", "=", "QFileDialog", ".", "getOpenFileName", "(", "self", ",", "self", ".", "tr", "(", "'Set organisation logo file'", ")", ",", "self", ...
Open File dialog to choose the organisation logo path.
[ "Open", "File", "dialog", "to", "choose", "the", "organisation", "logo", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L524-L537
train
27,210
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.open_report_template_path
def open_report_template_path(self): """Open File dialog to choose the report template path.""" # noinspection PyCallByClass,PyTypeChecker directory_name = QFileDialog.getExistingDirectory( self, self.tr('Templates directory'), self.leReportTemplatePath.text()...
python
def open_report_template_path(self): """Open File dialog to choose the report template path.""" # noinspection PyCallByClass,PyTypeChecker directory_name = QFileDialog.getExistingDirectory( self, self.tr('Templates directory'), self.leReportTemplatePath.text()...
[ "def", "open_report_template_path", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "directory_name", "=", "QFileDialog", ".", "getExistingDirectory", "(", "self", ",", "self", ".", "tr", "(", "'Templates directory'", ")", ",", "self", ".", "leRep...
Open File dialog to choose the report template path.
[ "Open", "File", "dialog", "to", "choose", "the", "report", "template", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L539-L548
train
27,211
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.toggle_logo_path
def toggle_logo_path(self): """Set state of logo path line edit and button.""" is_checked = self.custom_organisation_logo_check_box.isChecked() if is_checked: # Use previous org logo path path = setting( key='organisation_logo_path', defaul...
python
def toggle_logo_path(self): """Set state of logo path line edit and button.""" is_checked = self.custom_organisation_logo_check_box.isChecked() if is_checked: # Use previous org logo path path = setting( key='organisation_logo_path', defaul...
[ "def", "toggle_logo_path", "(", "self", ")", ":", "is_checked", "=", "self", ".", "custom_organisation_logo_check_box", ".", "isChecked", "(", ")", "if", "is_checked", ":", "# Use previous org logo path", "path", "=", "setting", "(", "key", "=", "'organisation_logo_...
Set state of logo path line edit and button.
[ "Set", "state", "of", "logo", "path", "line", "edit", "and", "button", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L550-L566
train
27,212
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.update_logo_preview
def update_logo_preview(self): """Update logo based on the current logo path.""" logo_path = self.organisation_logo_path_line_edit.text() if os.path.exists(logo_path): icon = QPixmap(logo_path) label_size = self.organisation_logo_label.size() label_size.setHei...
python
def update_logo_preview(self): """Update logo based on the current logo path.""" logo_path = self.organisation_logo_path_line_edit.text() if os.path.exists(logo_path): icon = QPixmap(logo_path) label_size = self.organisation_logo_label.size() label_size.setHei...
[ "def", "update_logo_preview", "(", "self", ")", ":", "logo_path", "=", "self", ".", "organisation_logo_path_line_edit", ".", "text", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "logo_path", ")", ":", "icon", "=", "QPixmap", "(", "logo_path", ")"...
Update logo based on the current logo path.
[ "Update", "logo", "based", "on", "the", "current", "logo", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L568-L580
train
27,213
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.set_north_arrow
def set_north_arrow(self): """Auto-connect slot activated when north arrow checkbox is toggled.""" is_checked = self.custom_north_arrow_checkbox.isChecked() if is_checked: # Show previous north arrow path path = setting( key='north_arrow_path', ...
python
def set_north_arrow(self): """Auto-connect slot activated when north arrow checkbox is toggled.""" is_checked = self.custom_north_arrow_checkbox.isChecked() if is_checked: # Show previous north arrow path path = setting( key='north_arrow_path', ...
[ "def", "set_north_arrow", "(", "self", ")", ":", "is_checked", "=", "self", ".", "custom_north_arrow_checkbox", ".", "isChecked", "(", ")", "if", "is_checked", ":", "# Show previous north arrow path", "path", "=", "setting", "(", "key", "=", "'north_arrow_path'", ...
Auto-connect slot activated when north arrow checkbox is toggled.
[ "Auto", "-", "connect", "slot", "activated", "when", "north", "arrow", "checkbox", "is", "toggled", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L582-L597
train
27,214
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.set_user_dir
def set_user_dir(self): """Auto-connect slot activated when user dir checkbox is toggled. """ is_checked = self.custom_UseUserDirectory_checkbox.isChecked() if is_checked: # Show previous templates dir path = setting( key='defaultUserDirectory', ...
python
def set_user_dir(self): """Auto-connect slot activated when user dir checkbox is toggled. """ is_checked = self.custom_UseUserDirectory_checkbox.isChecked() if is_checked: # Show previous templates dir path = setting( key='defaultUserDirectory', ...
[ "def", "set_user_dir", "(", "self", ")", ":", "is_checked", "=", "self", ".", "custom_UseUserDirectory_checkbox", ".", "isChecked", "(", ")", "if", "is_checked", ":", "# Show previous templates dir", "path", "=", "setting", "(", "key", "=", "'defaultUserDirectory'",...
Auto-connect slot activated when user dir checkbox is toggled.
[ "Auto", "-", "connect", "slot", "activated", "when", "user", "dir", "checkbox", "is", "toggled", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L599-L615
train
27,215
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.set_templates_dir
def set_templates_dir(self): """Auto-connect slot activated when templates dir checkbox is toggled. """ is_checked = self.custom_templates_dir_checkbox.isChecked() if is_checked: # Show previous templates dir path = setting( key='reportTemplatePath...
python
def set_templates_dir(self): """Auto-connect slot activated when templates dir checkbox is toggled. """ is_checked = self.custom_templates_dir_checkbox.isChecked() if is_checked: # Show previous templates dir path = setting( key='reportTemplatePath...
[ "def", "set_templates_dir", "(", "self", ")", ":", "is_checked", "=", "self", ".", "custom_templates_dir_checkbox", ".", "isChecked", "(", ")", "if", "is_checked", ":", "# Show previous templates dir", "path", "=", "setting", "(", "key", "=", "'reportTemplatePath'",...
Auto-connect slot activated when templates dir checkbox is toggled.
[ "Auto", "-", "connect", "slot", "activated", "when", "templates", "dir", "checkbox", "is", "toggled", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L617-L633
train
27,216
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.set_org_disclaimer
def set_org_disclaimer(self): """Auto-connect slot activated when org disclaimer checkbox is toggled. """ is_checked = self.custom_org_disclaimer_checkbox.isChecked() if is_checked: # Show previous organisation disclaimer org_disclaimer = setting( ...
python
def set_org_disclaimer(self): """Auto-connect slot activated when org disclaimer checkbox is toggled. """ is_checked = self.custom_org_disclaimer_checkbox.isChecked() if is_checked: # Show previous organisation disclaimer org_disclaimer = setting( ...
[ "def", "set_org_disclaimer", "(", "self", ")", ":", "is_checked", "=", "self", ".", "custom_org_disclaimer_checkbox", ".", "isChecked", "(", ")", "if", "is_checked", ":", "# Show previous organisation disclaimer", "org_disclaimer", "=", "setting", "(", "'reportDisclaime...
Auto-connect slot activated when org disclaimer checkbox is toggled.
[ "Auto", "-", "connect", "slot", "activated", "when", "org", "disclaimer", "checkbox", "is", "toggled", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L635-L651
train
27,217
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.restore_default_values_page
def restore_default_values_page(self): """Setup UI for default values setting.""" # Clear parameters so it doesn't add parameters when # restore from changes. if self.default_value_parameters: self.default_value_parameters = [] if self.default_value_parameter_containe...
python
def restore_default_values_page(self): """Setup UI for default values setting.""" # Clear parameters so it doesn't add parameters when # restore from changes. if self.default_value_parameters: self.default_value_parameters = [] if self.default_value_parameter_containe...
[ "def", "restore_default_values_page", "(", "self", ")", ":", "# Clear parameters so it doesn't add parameters when", "# restore from changes.", "if", "self", ".", "default_value_parameters", ":", "self", ".", "default_value_parameters", "=", "[", "]", "if", "self", ".", "...
Setup UI for default values setting.
[ "Setup", "UI", "for", "default", "values", "setting", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L692-L764
train
27,218
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.restore_population_parameters
def restore_population_parameters(self, global_default=True): """Setup UI for population parameter page from setting. :param global_default: If True, set to original default (from the value in definitions). :type global_default: bool """ if global_default: ...
python
def restore_population_parameters(self, global_default=True): """Setup UI for population parameter page from setting. :param global_default: If True, set to original default (from the value in definitions). :type global_default: bool """ if global_default: ...
[ "def", "restore_population_parameters", "(", "self", ",", "global_default", "=", "True", ")", ":", "if", "global_default", ":", "data", "=", "generate_default_profile", "(", ")", "else", ":", "data", "=", "setting", "(", "'population_preference'", ",", "generate_d...
Setup UI for population parameter page from setting. :param global_default: If True, set to original default (from the value in definitions). :type global_default: bool
[ "Setup", "UI", "for", "population", "parameter", "page", "from", "setting", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L766-L790
train
27,219
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.age_ratios
def age_ratios(): """Helper to get list of age ratio from the options dialog. :returns: List of age ratio. :rtype: list """ # FIXME(IS) set a correct parameter container parameter_container = None youth_ratio = parameter_container.get_parameter_by_guid( ...
python
def age_ratios(): """Helper to get list of age ratio from the options dialog. :returns: List of age ratio. :rtype: list """ # FIXME(IS) set a correct parameter container parameter_container = None youth_ratio = parameter_container.get_parameter_by_guid( ...
[ "def", "age_ratios", "(", ")", ":", "# FIXME(IS) set a correct parameter container", "parameter_container", "=", "None", "youth_ratio", "=", "parameter_container", ".", "get_parameter_by_guid", "(", "youth_ratio_field", "[", "'key'", "]", ")", ".", "value", "adult_ratio",...
Helper to get list of age ratio from the options dialog. :returns: List of age ratio. :rtype: list
[ "Helper", "to", "get", "list", "of", "age", "ratio", "from", "the", "options", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L793-L810
train
27,220
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.is_good_age_ratios
def is_good_age_ratios(self): """Method to check the sum of age ratio is 1. :returns: True if the sum is 1 or the sum less than 1 but there is None. :rtype: bool """ ratios = self.age_ratios() if None in ratios: # If there is None, just check to ...
python
def is_good_age_ratios(self): """Method to check the sum of age ratio is 1. :returns: True if the sum is 1 or the sum less than 1 but there is None. :rtype: bool """ ratios = self.age_ratios() if None in ratios: # If there is None, just check to ...
[ "def", "is_good_age_ratios", "(", "self", ")", ":", "ratios", "=", "self", ".", "age_ratios", "(", ")", "if", "None", "in", "ratios", ":", "# If there is None, just check to not exceeding 1", "clean_ratios", "=", "[", "x", "for", "x", "in", "ratios", "if", "x"...
Method to check the sum of age ratio is 1. :returns: True if the sum is 1 or the sum less than 1 but there is None. :rtype: bool
[ "Method", "to", "check", "the", "sum", "of", "age", "ratio", "is", "1", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L812-L831
train
27,221
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.save_default_values
def save_default_values(self): """Save InaSAFE default values.""" for parameter_container in self.default_value_parameter_containers: parameters = parameter_container.get_parameters() for parameter in parameters: set_inasafe_default_value_qsetting( ...
python
def save_default_values(self): """Save InaSAFE default values.""" for parameter_container in self.default_value_parameter_containers: parameters = parameter_container.get_parameters() for parameter in parameters: set_inasafe_default_value_qsetting( ...
[ "def", "save_default_values", "(", "self", ")", ":", "for", "parameter_container", "in", "self", ".", "default_value_parameter_containers", ":", "parameters", "=", "parameter_container", ".", "get_parameters", "(", ")", "for", "parameter", "in", "parameters", ":", "...
Save InaSAFE default values.
[ "Save", "InaSAFE", "default", "values", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L833-L843
train
27,222
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.restore_defaults_ratio
def restore_defaults_ratio(self): """Restore InaSAFE default ratio.""" # Set the flag to true because user ask to. self.is_restore_default = True # remove current default ratio for i in reversed(list(range(self.container_layout.count()))): widget = self.container_layo...
python
def restore_defaults_ratio(self): """Restore InaSAFE default ratio.""" # Set the flag to true because user ask to. self.is_restore_default = True # remove current default ratio for i in reversed(list(range(self.container_layout.count()))): widget = self.container_layo...
[ "def", "restore_defaults_ratio", "(", "self", ")", ":", "# Set the flag to true because user ask to.", "self", ".", "is_restore_default", "=", "True", "# remove current default ratio", "for", "i", "in", "reversed", "(", "list", "(", "range", "(", "self", ".", "contain...
Restore InaSAFE default ratio.
[ "Restore", "InaSAFE", "default", "ratio", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L845-L856
train
27,223
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.default_field_to_parameter
def default_field_to_parameter(self, default_field): """Obtain parameter from default field. :param default_field: A default field definition. :type default_field: dict :returns: A parameter object. :rtype: FloatParameter, IntegerParameter """ if default_field.g...
python
def default_field_to_parameter(self, default_field): """Obtain parameter from default field. :param default_field: A default field definition. :type default_field: dict :returns: A parameter object. :rtype: FloatParameter, IntegerParameter """ if default_field.g...
[ "def", "default_field_to_parameter", "(", "self", ",", "default_field", ")", ":", "if", "default_field", ".", "get", "(", "'type'", ")", "==", "QVariant", ".", "Double", ":", "parameter", "=", "FloatParameter", "(", ")", "elif", "default_field", ".", "get", ...
Obtain parameter from default field. :param default_field: A default field definition. :type default_field: dict :returns: A parameter object. :rtype: FloatParameter, IntegerParameter
[ "Obtain", "parameter", "from", "default", "field", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L858-L907
train
27,224
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.set_welcome_message
def set_welcome_message(self): """Create and insert welcome message.""" string = html_header() string += welcome_message().to_html() string += html_footer() self.welcome_message.setHtml(string)
python
def set_welcome_message(self): """Create and insert welcome message.""" string = html_header() string += welcome_message().to_html() string += html_footer() self.welcome_message.setHtml(string)
[ "def", "set_welcome_message", "(", "self", ")", ":", "string", "=", "html_header", "(", ")", "string", "+=", "welcome_message", "(", ")", ".", "to_html", "(", ")", "string", "+=", "html_footer", "(", ")", "self", ".", "welcome_message", ".", "setHtml", "("...
Create and insert welcome message.
[ "Create", "and", "insert", "welcome", "message", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L914-L919
train
27,225
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.show_welcome_dialog
def show_welcome_dialog(self): """Setup for showing welcome message dialog. This method will setup several things: - Only show welcome, organisation profile, and population parameter tab. Currently, they are the first 3 tabs. - Set the title - Move the check box for ...
python
def show_welcome_dialog(self): """Setup for showing welcome message dialog. This method will setup several things: - Only show welcome, organisation profile, and population parameter tab. Currently, they are the first 3 tabs. - Set the title - Move the check box for ...
[ "def", "show_welcome_dialog", "(", "self", ")", ":", "self", ".", "welcome_layout", ".", "addWidget", "(", "self", ".", "welcome_message_check_box", ")", "while", "self", ".", "tabWidget", ".", "count", "(", ")", ">", "3", ":", "self", ".", "tabWidget", "....
Setup for showing welcome message dialog. This method will setup several things: - Only show welcome, organisation profile, and population parameter tab. Currently, they are the first 3 tabs. - Set the title - Move the check box for always showing welcome message.
[ "Setup", "for", "showing", "welcome", "message", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L925-L940
train
27,226
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.export_setting
def export_setting(self): """Export setting from an existing file.""" LOGGER.debug('Export button clicked') home_directory = os.path.expanduser('~') file_name = self.organisation_line_edit.text().replace(' ', '_') file_path, __ = QFileDialog.getSaveFileName( self, ...
python
def export_setting(self): """Export setting from an existing file.""" LOGGER.debug('Export button clicked') home_directory = os.path.expanduser('~') file_name = self.organisation_line_edit.text().replace(' ', '_') file_path, __ = QFileDialog.getSaveFileName( self, ...
[ "def", "export_setting", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Export button clicked'", ")", "home_directory", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "file_name", "=", "self", ".", "organisation_line_edit", ".", "text", "...
Export setting from an existing file.
[ "Export", "setting", "from", "an", "existing", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L942-L954
train
27,227
inasafe/inasafe
safe/gui/tools/options_dialog.py
OptionsDialog.import_setting
def import_setting(self): """Import setting to a file.""" LOGGER.debug('Import button clicked') home_directory = os.path.expanduser('~') file_path, __ = QFileDialog.getOpenFileName( self, self.tr('Import InaSAFE settings'), home_directory, ...
python
def import_setting(self): """Import setting to a file.""" LOGGER.debug('Import button clicked') home_directory = os.path.expanduser('~') file_path, __ = QFileDialog.getOpenFileName( self, self.tr('Import InaSAFE settings'), home_directory, ...
[ "def", "import_setting", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Import button clicked'", ")", "home_directory", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "file_path", ",", "__", "=", "QFileDialog", ".", "getOpenFileName", "("...
Import setting to a file.
[ "Import", "setting", "to", "a", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L956-L975
train
27,228
inasafe/inasafe
safe/definitions/hazard_exposure_specifications.py
specific_notes
def specific_notes(hazard, exposure): """Return notes which are specific for a given hazard and exposure. :param hazard: The hazard definition. :type hazard: safe.definition.hazard :param exposure: The exposure definition. :type hazard: safe.definition.exposure :return: List of notes specific...
python
def specific_notes(hazard, exposure): """Return notes which are specific for a given hazard and exposure. :param hazard: The hazard definition. :type hazard: safe.definition.hazard :param exposure: The exposure definition. :type hazard: safe.definition.exposure :return: List of notes specific...
[ "def", "specific_notes", "(", "hazard", ",", "exposure", ")", ":", "for", "item", "in", "ITEMS", ":", "if", "item", "[", "'hazard'", "]", "==", "hazard", "and", "item", "[", "'exposure'", "]", "==", "exposure", ":", "return", "item", ".", "get", "(", ...
Return notes which are specific for a given hazard and exposure. :param hazard: The hazard definition. :type hazard: safe.definition.hazard :param exposure: The exposure definition. :type hazard: safe.definition.exposure :return: List of notes specific. :rtype: list
[ "Return", "notes", "which", "are", "specific", "for", "a", "given", "hazard", "and", "exposure", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/hazard_exposure_specifications.py#L93-L108
train
27,229
inasafe/inasafe
safe/definitions/hazard_exposure_specifications.py
specific_actions
def specific_actions(hazard, exposure): """Return actions which are specific for a given hazard and exposure. :param hazard: The hazard definition. :type hazard: safe.definition.hazard :param exposure: The exposure definition. :type hazard: safe.definition.exposure :return: List of actions sp...
python
def specific_actions(hazard, exposure): """Return actions which are specific for a given hazard and exposure. :param hazard: The hazard definition. :type hazard: safe.definition.hazard :param exposure: The exposure definition. :type hazard: safe.definition.exposure :return: List of actions sp...
[ "def", "specific_actions", "(", "hazard", ",", "exposure", ")", ":", "for", "item", "in", "ITEMS", ":", "if", "item", "[", "'hazard'", "]", "==", "hazard", "and", "item", "[", "'exposure'", "]", "==", "exposure", ":", "return", "item", ".", "get", "(",...
Return actions which are specific for a given hazard and exposure. :param hazard: The hazard definition. :type hazard: safe.definition.hazard :param exposure: The exposure definition. :type hazard: safe.definition.exposure :return: List of actions specific. :rtype: list
[ "Return", "actions", "which", "are", "specific", "for", "a", "given", "hazard", "and", "exposure", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/hazard_exposure_specifications.py#L111-L126
train
27,230
inasafe/inasafe
safe/report/extractors/infographic_elements/svg_charts.py
DonutChartContext.data_object
def data_object(self): """List of dictionary contains value and labels associations. :return: list of dictionary :rtype: list[dict] """ data_obj = [] for i in range(0, len(self.data)): obj = { 'value': self.data[i], 'label': s...
python
def data_object(self): """List of dictionary contains value and labels associations. :return: list of dictionary :rtype: list[dict] """ data_obj = [] for i in range(0, len(self.data)): obj = { 'value': self.data[i], 'label': s...
[ "def", "data_object", "(", "self", ")", ":", "data_obj", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "data", ")", ")", ":", "obj", "=", "{", "'value'", ":", "self", ".", "data", "[", "i", "]", ",", "'labe...
List of dictionary contains value and labels associations. :return: list of dictionary :rtype: list[dict]
[ "List", "of", "dictionary", "contains", "value", "and", "labels", "associations", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/infographic_elements/svg_charts.py#L243-L258
train
27,231
inasafe/inasafe
safe/report/extractors/infographic_elements/svg_charts.py
DonutChartContext.slices
def slices(self): """List of dictionary context to generate pie slices in svg. :return: list of dictionary :rtype: list[dict] .. versionadded:: 4.0 """ labels = self.labels values = self.data hole_percentage = self.inner_radius_ratio radius = sel...
python
def slices(self): """List of dictionary context to generate pie slices in svg. :return: list of dictionary :rtype: list[dict] .. versionadded:: 4.0 """ labels = self.labels values = self.data hole_percentage = self.inner_radius_ratio radius = sel...
[ "def", "slices", "(", "self", ")", ":", "labels", "=", "self", ".", "labels", "values", "=", "self", ".", "data", "hole_percentage", "=", "self", ".", "inner_radius_ratio", "radius", "=", "self", ".", "DEFAULT_RADIUS", "hole", "=", "hole_percentage", "*", ...
List of dictionary context to generate pie slices in svg. :return: list of dictionary :rtype: list[dict] .. versionadded:: 4.0
[ "List", "of", "dictionary", "context", "to", "generate", "pie", "slices", "in", "svg", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/infographic_elements/svg_charts.py#L261-L353
train
27,232
inasafe/inasafe
safe/report/extractors/infographic_elements/svg_charts.py
DonutChartContext._arc_slice_context
def _arc_slice_context( cls, slice_value, total_values, label, color, stroke_color, radius=128, label_position=(256, 0), start_angle=- math.pi / 2, center_point=(128, 128), hole=0): ...
python
def _arc_slice_context( cls, slice_value, total_values, label, color, stroke_color, radius=128, label_position=(256, 0), start_angle=- math.pi / 2, center_point=(128, 128), hole=0): ...
[ "def", "_arc_slice_context", "(", "cls", ",", "slice_value", ",", "total_values", ",", "label", ",", "color", ",", "stroke_color", ",", "radius", "=", "128", ",", "label_position", "=", "(", "256", ",", "0", ")", ",", "start_angle", "=", "-", "math", "."...
Create arc slice context to be rendered in svg. :param slice_value: The value the slice represent. :type slice_value: float :param total_values: The total value of one full circle arc. In other words, the value when of 100% representation. :type total_values: float ...
[ "Create", "arc", "slice", "context", "to", "be", "rendered", "in", "svg", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/infographic_elements/svg_charts.py#L356-L510
train
27,233
inasafe/inasafe
safe/gui/tools/wizard/step_fc55_agglayer_from_canvas.py
StepFcAggLayerFromCanvas.selected_canvas_agglayer
def selected_canvas_agglayer(self): """Obtain the canvas aggregation layer selected by user. :returns: The currently selected map layer in the list. :rtype: QgsMapLayer """ if self.lstCanvasAggLayers.selectedItems(): item = self.lstCanvasAggLayers.currentItem() ...
python
def selected_canvas_agglayer(self): """Obtain the canvas aggregation layer selected by user. :returns: The currently selected map layer in the list. :rtype: QgsMapLayer """ if self.lstCanvasAggLayers.selectedItems(): item = self.lstCanvasAggLayers.currentItem() ...
[ "def", "selected_canvas_agglayer", "(", "self", ")", ":", "if", "self", ".", "lstCanvasAggLayers", ".", "selectedItems", "(", ")", ":", "item", "=", "self", ".", "lstCanvasAggLayers", ".", "currentItem", "(", ")", "else", ":", "return", "None", "try", ":", ...
Obtain the canvas aggregation layer selected by user. :returns: The currently selected map layer in the list. :rtype: QgsMapLayer
[ "Obtain", "the", "canvas", "aggregation", "layer", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc55_agglayer_from_canvas.py#L76-L92
train
27,234
inasafe/inasafe
safe/gui/tools/wizard/step_fc55_agglayer_from_canvas.py
StepFcAggLayerFromCanvas.set_widgets
def set_widgets(self): """Set widgets on the Aggregation Layer from Canvas tab.""" # The list is already populated in the previous step, but now we # need to do it again in case we're back from the Keyword Wizard. # First, preserve self.parent.layer before clearing the list last_...
python
def set_widgets(self): """Set widgets on the Aggregation Layer from Canvas tab.""" # The list is already populated in the previous step, but now we # need to do it again in case we're back from the Keyword Wizard. # First, preserve self.parent.layer before clearing the list last_...
[ "def", "set_widgets", "(", "self", ")", ":", "# The list is already populated in the previous step, but now we", "# need to do it again in case we're back from the Keyword Wizard.", "# First, preserve self.parent.layer before clearing the list", "last_layer", "=", "self", ".", "parent", ...
Set widgets on the Aggregation Layer from Canvas tab.
[ "Set", "widgets", "on", "the", "Aggregation", "Layer", "from", "Canvas", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc55_agglayer_from_canvas.py#L112-L130
train
27,235
inasafe/inasafe
safe/report/extractors/util.py
layer_definition_type
def layer_definition_type(layer): """Returned relevant layer definition based on layer purpose. Returned the the correct definition of layer based on its purpose. For example, if a layer have layer_purpose: exposure, and exposure: roads then it will return definition for exposure_roads. That's why...
python
def layer_definition_type(layer): """Returned relevant layer definition based on layer purpose. Returned the the correct definition of layer based on its purpose. For example, if a layer have layer_purpose: exposure, and exposure: roads then it will return definition for exposure_roads. That's why...
[ "def", "layer_definition_type", "(", "layer", ")", ":", "layer_purposes", "=", "[", "'exposure'", ",", "'hazard'", "]", "layer_purpose", "=", "[", "p", "for", "p", "in", "layer_purposes", "if", "p", "in", "layer", ".", "keywords", "]", "if", "not", "layer_...
Returned relevant layer definition based on layer purpose. Returned the the correct definition of layer based on its purpose. For example, if a layer have layer_purpose: exposure, and exposure: roads then it will return definition for exposure_roads. That's why it only supports hazard layer or exposur...
[ "Returned", "relevant", "layer", "definition", "based", "on", "layer", "purpose", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/util.py#L18-L44
train
27,236
inasafe/inasafe
safe/report/extractors/util.py
layer_hazard_classification
def layer_hazard_classification(layer): """Returned this particular hazard classification. :param layer: hazard layer or exposure layer :type layer: qgis.core.QgsVectorLayer :return: Hazard classification. :rtype: dict .. versionadded:: 4.0 """ if not layer.keywords.get('hazard'): ...
python
def layer_hazard_classification(layer): """Returned this particular hazard classification. :param layer: hazard layer or exposure layer :type layer: qgis.core.QgsVectorLayer :return: Hazard classification. :rtype: dict .. versionadded:: 4.0 """ if not layer.keywords.get('hazard'): ...
[ "def", "layer_hazard_classification", "(", "layer", ")", ":", "if", "not", "layer", ".", "keywords", ".", "get", "(", "'hazard'", ")", ":", "# return nothing if not hazard layer", "return", "None", "hazard_classification", "=", "None", "# retrieve hazard classification ...
Returned this particular hazard classification. :param layer: hazard layer or exposure layer :type layer: qgis.core.QgsVectorLayer :return: Hazard classification. :rtype: dict .. versionadded:: 4.0
[ "Returned", "this", "particular", "hazard", "classification", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/util.py#L47-L69
train
27,237
inasafe/inasafe
safe/report/extractors/util.py
jinja2_output_as_string
def jinja2_output_as_string(impact_report, component_key): """Get a given jinja2 component output as string. Useful for composing complex document. :param impact_report: Impact Report that contains the component key. :type impact_report: safe.report.impact_report.ImpactReport :param component_key...
python
def jinja2_output_as_string(impact_report, component_key): """Get a given jinja2 component output as string. Useful for composing complex document. :param impact_report: Impact Report that contains the component key. :type impact_report: safe.report.impact_report.ImpactReport :param component_key...
[ "def", "jinja2_output_as_string", "(", "impact_report", ",", "component_key", ")", ":", "metadata", "=", "impact_report", ".", "metadata", "for", "c", "in", "metadata", ".", "components", ":", "if", "c", ".", "key", "==", "component_key", ":", "if", "c", "."...
Get a given jinja2 component output as string. Useful for composing complex document. :param impact_report: Impact Report that contains the component key. :type impact_report: safe.report.impact_report.ImpactReport :param component_key: The key of the component to get the output from. :type compo...
[ "Get", "a", "given", "jinja2", "component", "output", "as", "string", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/util.py#L72-L107
train
27,238
inasafe/inasafe
safe/report/extractors/util.py
value_from_field_name
def value_from_field_name(field_name, analysis_layer): """Get the value of analysis layer based on field name. Can also be used for any layer with one feature. :param field_name: Field name of analysis layer that we want to get. :type field_name: str :param analysis_layer: Analysis layer. :ty...
python
def value_from_field_name(field_name, analysis_layer): """Get the value of analysis layer based on field name. Can also be used for any layer with one feature. :param field_name: Field name of analysis layer that we want to get. :type field_name: str :param analysis_layer: Analysis layer. :ty...
[ "def", "value_from_field_name", "(", "field_name", ",", "analysis_layer", ")", ":", "field_index", "=", "analysis_layer", ".", "fields", "(", ")", ".", "lookupField", "(", "field_name", ")", "if", "field_index", "<", "0", ":", "return", "None", "else", ":", ...
Get the value of analysis layer based on field name. Can also be used for any layer with one feature. :param field_name: Field name of analysis layer that we want to get. :type field_name: str :param analysis_layer: Analysis layer. :type analysis_layer: qgis.core.QgsVectorLayer :return: retu...
[ "Get", "the", "value", "of", "analysis", "layer", "based", "on", "field", "name", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/util.py#L110-L131
train
27,239
inasafe/inasafe
safe/report/extractors/util.py
resolve_from_dictionary
def resolve_from_dictionary(dictionary, key_list, default_value=None): """Take value from a given key list from dictionary. Example: given dictionary d, key_list = ['foo', 'bar'], it will try to resolve d['foo']['bar']. If not possible, return default_value. :param dictionary: A dictionary to reso...
python
def resolve_from_dictionary(dictionary, key_list, default_value=None): """Take value from a given key list from dictionary. Example: given dictionary d, key_list = ['foo', 'bar'], it will try to resolve d['foo']['bar']. If not possible, return default_value. :param dictionary: A dictionary to reso...
[ "def", "resolve_from_dictionary", "(", "dictionary", ",", "key_list", ",", "default_value", "=", "None", ")", ":", "try", ":", "current_value", "=", "dictionary", "key_list", "=", "key_list", "if", "isinstance", "(", "key_list", ",", "list", ")", "else", "[", ...
Take value from a given key list from dictionary. Example: given dictionary d, key_list = ['foo', 'bar'], it will try to resolve d['foo']['bar']. If not possible, return default_value. :param dictionary: A dictionary to resolve. :type dictionary: dict :param key_list: A list of key to resolve...
[ "Take", "value", "from", "a", "given", "key", "list", "from", "dictionary", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/util.py#L134-L161
train
27,240
inasafe/inasafe
safe/report/extractors/util.py
retrieve_exposure_classes_lists
def retrieve_exposure_classes_lists(exposure_keywords): """Retrieve exposures classes. Only if the exposure has some classifications. :param exposure_keywords: exposure keywords :type exposure_keywords: dict :return: lists of classes used in the classifications. :rtype: list(dict) """ ...
python
def retrieve_exposure_classes_lists(exposure_keywords): """Retrieve exposures classes. Only if the exposure has some classifications. :param exposure_keywords: exposure keywords :type exposure_keywords: dict :return: lists of classes used in the classifications. :rtype: list(dict) """ ...
[ "def", "retrieve_exposure_classes_lists", "(", "exposure_keywords", ")", ":", "# return None in case exposure doesn't have classifications", "classification", "=", "exposure_keywords", ".", "get", "(", "'classification'", ")", "if", "not", "classification", ":", "return", "No...
Retrieve exposures classes. Only if the exposure has some classifications. :param exposure_keywords: exposure keywords :type exposure_keywords: dict :return: lists of classes used in the classifications. :rtype: list(dict)
[ "Retrieve", "exposures", "classes", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/util.py#L164-L181
train
27,241
inasafe/inasafe
safe/processors/minimum_needs_post_processors.py
initialize_minimum_needs_post_processors
def initialize_minimum_needs_post_processors(): """Generate definitions for minimum needs post processors.""" processors = [] for field in minimum_needs_fields: field_key = field['key'] field_name = field['name'] field_description = field['description'] need_parameter = fiel...
python
def initialize_minimum_needs_post_processors(): """Generate definitions for minimum needs post processors.""" processors = [] for field in minimum_needs_fields: field_key = field['key'] field_name = field['name'] field_description = field['description'] need_parameter = fiel...
[ "def", "initialize_minimum_needs_post_processors", "(", ")", ":", "processors", "=", "[", "]", "for", "field", "in", "minimum_needs_fields", ":", "field_key", "=", "field", "[", "'key'", "]", "field_name", "=", "field", "[", "'name'", "]", "field_description", "...
Generate definitions for minimum needs post processors.
[ "Generate", "definitions", "for", "minimum", "needs", "post", "processors", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/processors/minimum_needs_post_processors.py#L89-L125
train
27,242
inasafe/inasafe
safe/gui/gui_utilities.py
layer_from_combo
def layer_from_combo(combo): """Get the QgsMapLayer currently selected in a combo. Obtain QgsMapLayer id from the userrole of the QtCombo and return it as a QgsMapLayer. :returns: The currently selected map layer a combo. :rtype: QgsMapLayer """ index = combo.currentIndex() if index < ...
python
def layer_from_combo(combo): """Get the QgsMapLayer currently selected in a combo. Obtain QgsMapLayer id from the userrole of the QtCombo and return it as a QgsMapLayer. :returns: The currently selected map layer a combo. :rtype: QgsMapLayer """ index = combo.currentIndex() if index < ...
[ "def", "layer_from_combo", "(", "combo", ")", ":", "index", "=", "combo", ".", "currentIndex", "(", ")", "if", "index", "<", "0", ":", "return", "None", "layer_id", "=", "combo", ".", "itemData", "(", "index", ",", "Qt", ".", "UserRole", ")", "layer", ...
Get the QgsMapLayer currently selected in a combo. Obtain QgsMapLayer id from the userrole of the QtCombo and return it as a QgsMapLayer. :returns: The currently selected map layer a combo. :rtype: QgsMapLayer
[ "Get", "the", "QgsMapLayer", "currently", "selected", "in", "a", "combo", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/gui_utilities.py#L12-L27
train
27,243
inasafe/inasafe
safe/gui/gui_utilities.py
add_ordered_combo_item
def add_ordered_combo_item( combo, text, data=None, count_selected_features=None, icon=None): """Add a combo item ensuring that all items are listed alphabetically. Although QComboBox allows you to set an InsertAlphabetically enum this only has effect when a user interactively adds combo items to ...
python
def add_ordered_combo_item( combo, text, data=None, count_selected_features=None, icon=None): """Add a combo item ensuring that all items are listed alphabetically. Although QComboBox allows you to set an InsertAlphabetically enum this only has effect when a user interactively adds combo items to ...
[ "def", "add_ordered_combo_item", "(", "combo", ",", "text", ",", "data", "=", "None", ",", "count_selected_features", "=", "None", ",", "icon", "=", "None", ")", ":", "if", "count_selected_features", "is", "not", "None", ":", "text", "+=", "' ('", "+", "tr...
Add a combo item ensuring that all items are listed alphabetically. Although QComboBox allows you to set an InsertAlphabetically enum this only has effect when a user interactively adds combo items to an editable combo. This we have this little function to ensure that combos are always sorted alphabeti...
[ "Add", "a", "combo", "item", "ensuring", "that", "all", "items", "are", "listed", "alphabetically", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/gui_utilities.py#L30-L73
train
27,244
inasafe/inasafe
safe/common/signals.py
send_static_message
def send_static_message(sender, message): """Send a static message to the listeners. Static messages represents a whole new message. Usually it will replace the previous message. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: An instance of our rich...
python
def send_static_message(sender, message): """Send a static message to the listeners. Static messages represents a whole new message. Usually it will replace the previous message. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: An instance of our rich...
[ "def", "send_static_message", "(", "sender", ",", "message", ")", ":", "dispatcher", ".", "send", "(", "signal", "=", "STATIC_MESSAGE_SIGNAL", ",", "sender", "=", "sender", ",", "message", "=", "message", ")" ]
Send a static message to the listeners. Static messages represents a whole new message. Usually it will replace the previous message. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: An instance of our rich message class. :type message: safe.messaging...
[ "Send", "a", "static", "message", "to", "the", "listeners", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/signals.py#L39-L57
train
27,245
inasafe/inasafe
safe/common/signals.py
send_dynamic_message
def send_dynamic_message(sender, message): """Send a dynamic message to the listeners. Dynamic messages represents a progress. Usually it will be appended to the previous messages. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: An instance of our ri...
python
def send_dynamic_message(sender, message): """Send a dynamic message to the listeners. Dynamic messages represents a progress. Usually it will be appended to the previous messages. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: An instance of our ri...
[ "def", "send_dynamic_message", "(", "sender", ",", "message", ")", ":", "dispatcher", ".", "send", "(", "signal", "=", "DYNAMIC_MESSAGE_SIGNAL", ",", "sender", "=", "sender", ",", "message", "=", "message", ")" ]
Send a dynamic message to the listeners. Dynamic messages represents a progress. Usually it will be appended to the previous messages. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: An instance of our rich message class. :type message: safe.messagin...
[ "Send", "a", "dynamic", "message", "to", "the", "listeners", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/signals.py#L60-L78
train
27,246
inasafe/inasafe
safe/common/signals.py
send_error_message
def send_error_message(sender, error_message): """Send an error message to the listeners. Error messages represents and error. It usually replace the previous message since an error has been happened. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param error_mess...
python
def send_error_message(sender, error_message): """Send an error message to the listeners. Error messages represents and error. It usually replace the previous message since an error has been happened. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param error_mess...
[ "def", "send_error_message", "(", "sender", ",", "error_message", ")", ":", "dispatcher", ".", "send", "(", "signal", "=", "ERROR_MESSAGE_SIGNAL", ",", "sender", "=", "sender", ",", "message", "=", "error_message", ")" ]
Send an error message to the listeners. Error messages represents and error. It usually replace the previous message since an error has been happened. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param error_message: An instance of our rich error message class. ...
[ "Send", "an", "error", "message", "to", "the", "listeners", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/signals.py#L81-L98
train
27,247
inasafe/inasafe
safe/common/signals.py
analysis_error
def analysis_error(sender, exception, message): """A helper to spawn an error and halt processing. An exception will be logged, busy status removed and a message displayed. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: an ErrorMessage to display ...
python
def analysis_error(sender, exception, message): """A helper to spawn an error and halt processing. An exception will be logged, busy status removed and a message displayed. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: an ErrorMessage to display ...
[ "def", "analysis_error", "(", "sender", ",", "exception", ",", "message", ")", ":", "LOGGER", ".", "exception", "(", "message", ")", "message", "=", "get_error_message", "(", "exception", ",", "context", "=", "message", ")", "send_error_message", "(", "sender"...
A helper to spawn an error and halt processing. An exception will be logged, busy status removed and a message displayed. .. versionadded:: 3.3 :param sender: The sender. :type sender: object :param message: an ErrorMessage to display :type message: ErrorMessage, Message :param exce...
[ "A", "helper", "to", "spawn", "an", "error", "and", "halt", "processing", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/signals.py#L101-L120
train
27,248
inasafe/inasafe
safe/common/parameters/default_select_parameter_widget.py
DefaultSelectParameterWidget.set_default
def set_default(self, default): """Set default value by item's string. :param default: The default. :type default: str, int :returns: True if success, else False. :rtype: bool """ # Find index of choice try: default_index = self._parameter.de...
python
def set_default(self, default): """Set default value by item's string. :param default: The default. :type default: str, int :returns: True if success, else False. :rtype: bool """ # Find index of choice try: default_index = self._parameter.de...
[ "def", "set_default", "(", "self", ",", "default", ")", ":", "# Find index of choice", "try", ":", "default_index", "=", "self", ".", "_parameter", ".", "default_values", ".", "index", "(", "default", ")", "self", ".", "default_input_button_group", ".", "button"...
Set default value by item's string. :param default: The default. :type default: str, int :returns: True if success, else False. :rtype: bool
[ "Set", "default", "value", "by", "item", "s", "string", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_select_parameter_widget.py#L149-L169
train
27,249
inasafe/inasafe
safe/common/parameters/default_select_parameter_widget.py
DefaultSelectParameterWidget.toggle_input
def toggle_input(self): """Change behaviour of radio button based on input.""" current_index = self.input.currentIndex() # If current input is not a radio button enabler, disable radio button. if self.input.itemData(current_index, Qt.UserRole) != ( self.radio_button_enabl...
python
def toggle_input(self): """Change behaviour of radio button based on input.""" current_index = self.input.currentIndex() # If current input is not a radio button enabler, disable radio button. if self.input.itemData(current_index, Qt.UserRole) != ( self.radio_button_enabl...
[ "def", "toggle_input", "(", "self", ")", ":", "current_index", "=", "self", ".", "input", ".", "currentIndex", "(", ")", "# If current input is not a radio button enabler, disable radio button.", "if", "self", ".", "input", ".", "itemData", "(", "current_index", ",", ...
Change behaviour of radio button based on input.
[ "Change", "behaviour", "of", "radio", "button", "based", "on", "input", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_select_parameter_widget.py#L179-L188
train
27,250
inasafe/inasafe
safe/common/parameters/default_select_parameter_widget.py
DefaultSelectParameterWidget.set_selected_radio_button
def set_selected_radio_button(self): """Set selected radio button to 'Do not report'.""" dont_use_button = self.default_input_button_group.button( len(self._parameter.default_values) - 2) dont_use_button.setChecked(True)
python
def set_selected_radio_button(self): """Set selected radio button to 'Do not report'.""" dont_use_button = self.default_input_button_group.button( len(self._parameter.default_values) - 2) dont_use_button.setChecked(True)
[ "def", "set_selected_radio_button", "(", "self", ")", ":", "dont_use_button", "=", "self", ".", "default_input_button_group", ".", "button", "(", "len", "(", "self", ".", "_parameter", ".", "default_values", ")", "-", "2", ")", "dont_use_button", ".", "setChecke...
Set selected radio button to 'Do not report'.
[ "Set", "selected", "radio", "button", "to", "Do", "not", "report", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_select_parameter_widget.py#L190-L194
train
27,251
inasafe/inasafe
safe/common/parameters/default_select_parameter_widget.py
DefaultSelectParameterWidget.disable_radio_button
def disable_radio_button(self): """Disable radio button group and custom value input area.""" checked = self.default_input_button_group.checkedButton() if checked: self.default_input_button_group.setExclusive(False) checked.setChecked(False) self.default_input...
python
def disable_radio_button(self): """Disable radio button group and custom value input area.""" checked = self.default_input_button_group.checkedButton() if checked: self.default_input_button_group.setExclusive(False) checked.setChecked(False) self.default_input...
[ "def", "disable_radio_button", "(", "self", ")", ":", "checked", "=", "self", ".", "default_input_button_group", ".", "checkedButton", "(", ")", "if", "checked", ":", "self", ".", "default_input_button_group", ".", "setExclusive", "(", "False", ")", "checked", "...
Disable radio button group and custom value input area.
[ "Disable", "radio", "button", "group", "and", "custom", "value", "input", "area", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_select_parameter_widget.py#L196-L205
train
27,252
inasafe/inasafe
safe/common/parameters/default_select_parameter_widget.py
DefaultSelectParameterWidget.enable_radio_button
def enable_radio_button(self): """Enable radio button and custom value input area then set selected radio button to 'Do not report'. """ for button in self.default_input_button_group.buttons(): button.setEnabled(True) self.set_selected_radio_button() self.cust...
python
def enable_radio_button(self): """Enable radio button and custom value input area then set selected radio button to 'Do not report'. """ for button in self.default_input_button_group.buttons(): button.setEnabled(True) self.set_selected_radio_button() self.cust...
[ "def", "enable_radio_button", "(", "self", ")", ":", "for", "button", "in", "self", ".", "default_input_button_group", ".", "buttons", "(", ")", ":", "button", ".", "setEnabled", "(", "True", ")", "self", ".", "set_selected_radio_button", "(", ")", "self", "...
Enable radio button and custom value input area then set selected radio button to 'Do not report'.
[ "Enable", "radio", "button", "and", "custom", "value", "input", "area", "then", "set", "selected", "radio", "button", "to", "Do", "not", "report", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_select_parameter_widget.py#L207-L214
train
27,253
inasafe/inasafe
safe/definitions/earthquake.py
earthquake_fatality_rate
def earthquake_fatality_rate(hazard_level): """Earthquake fatality ratio for a given hazard level. It reads the QGIS QSettings to know what is the default earthquake function. :param hazard_level: The hazard level. :type hazard_level: int :return: The fatality rate. :rtype: float """ ...
python
def earthquake_fatality_rate(hazard_level): """Earthquake fatality ratio for a given hazard level. It reads the QGIS QSettings to know what is the default earthquake function. :param hazard_level: The hazard level. :type hazard_level: int :return: The fatality rate. :rtype: float """ ...
[ "def", "earthquake_fatality_rate", "(", "hazard_level", ")", ":", "earthquake_function", "=", "setting", "(", "'earthquake_function'", ",", "EARTHQUAKE_FUNCTIONS", "[", "0", "]", "[", "'key'", "]", ",", "str", ")", "ratio", "=", "0", "for", "model", "in", "EAR...
Earthquake fatality ratio for a given hazard level. It reads the QGIS QSettings to know what is the default earthquake function. :param hazard_level: The hazard level. :type hazard_level: int :return: The fatality rate. :rtype: float
[ "Earthquake", "fatality", "ratio", "for", "a", "given", "hazard", "level", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L16-L35
train
27,254
inasafe/inasafe
safe/definitions/earthquake.py
itb_fatality_rates
def itb_fatality_rates(): """Indonesian Earthquake Fatality Model. :returns: Fatality rate. :rtype: dic """ # As per email discussion with Ole, Trevor, Hadi, mmi < 4 will have # a fatality rate of 0 - Tim mmi_range = list(range(2, 11)) # Model coefficients x = 0.62275231 y = 8.0...
python
def itb_fatality_rates(): """Indonesian Earthquake Fatality Model. :returns: Fatality rate. :rtype: dic """ # As per email discussion with Ole, Trevor, Hadi, mmi < 4 will have # a fatality rate of 0 - Tim mmi_range = list(range(2, 11)) # Model coefficients x = 0.62275231 y = 8.0...
[ "def", "itb_fatality_rates", "(", ")", ":", "# As per email discussion with Ole, Trevor, Hadi, mmi < 4 will have", "# a fatality rate of 0 - Tim", "mmi_range", "=", "list", "(", "range", "(", "2", ",", "11", ")", ")", "# Model coefficients", "x", "=", "0.62275231", "y", ...
Indonesian Earthquake Fatality Model. :returns: Fatality rate. :rtype: dic
[ "Indonesian", "Earthquake", "Fatality", "Model", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L38-L52
train
27,255
inasafe/inasafe
safe/definitions/earthquake.py
pager_fatality_rates
def pager_fatality_rates(): """USGS Pager fatality estimation model. Fatality rate(MMI) = cum. standard normal dist(1/BETA * ln(MMI/THETA)). Reference: Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). Estimating casualties for large worldwide earthquakes using an empirical approach. U.S. ...
python
def pager_fatality_rates(): """USGS Pager fatality estimation model. Fatality rate(MMI) = cum. standard normal dist(1/BETA * ln(MMI/THETA)). Reference: Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). Estimating casualties for large worldwide earthquakes using an empirical approach. U.S. ...
[ "def", "pager_fatality_rates", "(", ")", ":", "# Model coefficients", "theta", "=", "13.249", "beta", "=", "0.151", "mmi_range", "=", "list", "(", "range", "(", "2", ",", "11", ")", ")", "fatality_rate", "=", "{", "mmi", ":", "0", "if", "mmi", "<", "4"...
USGS Pager fatality estimation model. Fatality rate(MMI) = cum. standard normal dist(1/BETA * ln(MMI/THETA)). Reference: Jaiswal, K. S., Wald, D. J., and Hearne, M. (2009a). Estimating casualties for large worldwide earthquakes using an empirical approach. U.S. Geological Survey Open-File Report ...
[ "USGS", "Pager", "fatality", "estimation", "model", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L55-L87
train
27,256
inasafe/inasafe
safe/definitions/earthquake.py
normal_cdf
def normal_cdf(x, mu=0, sigma=1): """Cumulative Normal Distribution Function. :param x: scalar or array of real numbers. :type x: numpy.ndarray, float :param mu: Mean value. Default 0. :type mu: float, numpy.ndarray :param sigma: Standard deviation. Default 1. :type sigma: float :ret...
python
def normal_cdf(x, mu=0, sigma=1): """Cumulative Normal Distribution Function. :param x: scalar or array of real numbers. :type x: numpy.ndarray, float :param mu: Mean value. Default 0. :type mu: float, numpy.ndarray :param sigma: Standard deviation. Default 1. :type sigma: float :ret...
[ "def", "normal_cdf", "(", "x", ",", "mu", "=", "0", ",", "sigma", "=", "1", ")", ":", "arg", "=", "(", "x", "-", "mu", ")", "/", "(", "sigma", "*", "numpy", ".", "sqrt", "(", "2", ")", ")", "res", "=", "(", "1", "+", "erf", "(", "arg", ...
Cumulative Normal Distribution Function. :param x: scalar or array of real numbers. :type x: numpy.ndarray, float :param mu: Mean value. Default 0. :type mu: float, numpy.ndarray :param sigma: Standard deviation. Default 1. :type sigma: float :returns: An approximation of the cdf of the ...
[ "Cumulative", "Normal", "Distribution", "Function", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L249-L272
train
27,257
inasafe/inasafe
safe/definitions/earthquake.py
log_normal_cdf
def log_normal_cdf(x, median=1, sigma=1): """Cumulative Log Normal Distribution Function. :param x: scalar or array of real numbers. :type x: numpy.ndarray, float :param median: Median (exp(mean of log(x)). Default 1. :type median: float :param sigma: Log normal standard deviation. Default 1....
python
def log_normal_cdf(x, median=1, sigma=1): """Cumulative Log Normal Distribution Function. :param x: scalar or array of real numbers. :type x: numpy.ndarray, float :param median: Median (exp(mean of log(x)). Default 1. :type median: float :param sigma: Log normal standard deviation. Default 1....
[ "def", "log_normal_cdf", "(", "x", ",", "median", "=", "1", ",", "sigma", "=", "1", ")", ":", "return", "normal_cdf", "(", "numpy", ".", "log", "(", "x", ")", ",", "mu", "=", "numpy", ".", "log", "(", "median", ")", ",", "sigma", "=", "sigma", ...
Cumulative Log Normal Distribution Function. :param x: scalar or array of real numbers. :type x: numpy.ndarray, float :param median: Median (exp(mean of log(x)). Default 1. :type median: float :param sigma: Log normal standard deviation. Default 1. :type sigma: float :returns: An approxi...
[ "Cumulative", "Log", "Normal", "Distribution", "Function", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L275-L296
train
27,258
inasafe/inasafe
safe/definitions/earthquake.py
erf
def erf(z): """Approximation to ERF. :param z: Input array or scalar to perform erf on. :type z: numpy.ndarray, float :returns: The approximate error. :rtype: numpy.ndarray, float Note: from: http://www.cs.princeton.edu/introcs/21function/ErrorFunction.java.html Implem...
python
def erf(z): """Approximation to ERF. :param z: Input array or scalar to perform erf on. :type z: numpy.ndarray, float :returns: The approximate error. :rtype: numpy.ndarray, float Note: from: http://www.cs.princeton.edu/introcs/21function/ErrorFunction.java.html Implem...
[ "def", "erf", "(", "z", ")", ":", "# Input check", "try", ":", "len", "(", "z", ")", "except", "TypeError", ":", "scalar", "=", "True", "z", "=", "[", "z", "]", "else", ":", "scalar", "=", "False", "z", "=", "numpy", ".", "array", "(", "z", ")"...
Approximation to ERF. :param z: Input array or scalar to perform erf on. :type z: numpy.ndarray, float :returns: The approximate error. :rtype: numpy.ndarray, float Note: from: http://www.cs.princeton.edu/introcs/21function/ErrorFunction.java.html Implements the Gauss erro...
[ "Approximation", "to", "ERF", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L300-L354
train
27,259
inasafe/inasafe
safe/definitions/earthquake.py
current_earthquake_model_name
def current_earthquake_model_name(): """Human friendly name for the currently active earthquake fatality model. :returns: Name of the current EQ fatality model as defined in users settings. """ default_earthquake_function = setting( 'earthquake_function', EARTHQUAKE_FUNCTIONS[0]['key'],...
python
def current_earthquake_model_name(): """Human friendly name for the currently active earthquake fatality model. :returns: Name of the current EQ fatality model as defined in users settings. """ default_earthquake_function = setting( 'earthquake_function', EARTHQUAKE_FUNCTIONS[0]['key'],...
[ "def", "current_earthquake_model_name", "(", ")", ":", "default_earthquake_function", "=", "setting", "(", "'earthquake_function'", ",", "EARTHQUAKE_FUNCTIONS", "[", "0", "]", "[", "'key'", "]", ",", "str", ")", "current_function", "=", "None", "for", "model", "in...
Human friendly name for the currently active earthquake fatality model. :returns: Name of the current EQ fatality model as defined in users settings.
[ "Human", "friendly", "name", "for", "the", "currently", "active", "earthquake", "fatality", "model", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/earthquake.py#L357-L369
train
27,260
inasafe/inasafe
safe/gis/vector/from_counts_to_ratios.py
from_counts_to_ratios
def from_counts_to_ratios(layer): """Transform counts to ratios. Formula: ratio = subset count / total count :param layer: The vector layer. :type layer: QgsVectorLayer :return: The layer with new ratios. :rtype: QgsVectorLayer .. versionadded:: 4.0 """ output_layer_name = recomp...
python
def from_counts_to_ratios(layer): """Transform counts to ratios. Formula: ratio = subset count / total count :param layer: The vector layer. :type layer: QgsVectorLayer :return: The layer with new ratios. :rtype: QgsVectorLayer .. versionadded:: 4.0 """ output_layer_name = recomp...
[ "def", "from_counts_to_ratios", "(", "layer", ")", ":", "output_layer_name", "=", "recompute_counts_steps", "[", "'output_layer_name'", "]", "exposure", "=", "definition", "(", "layer", ".", "keywords", "[", "'exposure'", "]", ")", "inasafe_fields", "=", "layer", ...
Transform counts to ratios. Formula: ratio = subset count / total count :param layer: The vector layer. :type layer: QgsVectorLayer :return: The layer with new ratios. :rtype: QgsVectorLayer .. versionadded:: 4.0
[ "Transform", "counts", "to", "ratios", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/from_counts_to_ratios.py#L26-L105
train
27,261
inasafe/inasafe
safe/utilities/pivot_table.py
FlatTable.get_value
def get_value(self, **kwargs): """Return the value for a specific key.""" key = tuple(kwargs[group] for group in self.groups) if key not in self.data: self.data[key] = 0 return self.data[key]
python
def get_value(self, **kwargs): """Return the value for a specific key.""" key = tuple(kwargs[group] for group in self.groups) if key not in self.data: self.data[key] = 0 return self.data[key]
[ "def", "get_value", "(", "self", ",", "*", "*", "kwargs", ")", ":", "key", "=", "tuple", "(", "kwargs", "[", "group", "]", "for", "group", "in", "self", ".", "groups", ")", "if", "key", "not", "in", "self", ".", "data", ":", "self", ".", "data", ...
Return the value for a specific key.
[ "Return", "the", "value", "for", "a", "specific", "key", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/pivot_table.py#L52-L57
train
27,262
inasafe/inasafe
safe/utilities/pivot_table.py
FlatTable.group_values
def group_values(self, group_name): """Return all distinct group values for given group.""" group_index = self.groups.index(group_name) values = [] for key in self.data_keys: if key[group_index] not in values: values.append(key[group_index]) return val...
python
def group_values(self, group_name): """Return all distinct group values for given group.""" group_index = self.groups.index(group_name) values = [] for key in self.data_keys: if key[group_index] not in values: values.append(key[group_index]) return val...
[ "def", "group_values", "(", "self", ",", "group_name", ")", ":", "group_index", "=", "self", ".", "groups", ".", "index", "(", "group_name", ")", "values", "=", "[", "]", "for", "key", "in", "self", ".", "data_keys", ":", "if", "key", "[", "group_index...
Return all distinct group values for given group.
[ "Return", "all", "distinct", "group", "values", "for", "given", "group", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/pivot_table.py#L59-L66
train
27,263
inasafe/inasafe
safe/utilities/pivot_table.py
FlatTable.from_json
def from_json(self, json_string): """Override current FlatTable using data from json. :param json_string: JSON String :type json_string: str """ obj = json.loads(json_string) self.from_dict(obj['groups'], obj['data']) return self
python
def from_json(self, json_string): """Override current FlatTable using data from json. :param json_string: JSON String :type json_string: str """ obj = json.loads(json_string) self.from_dict(obj['groups'], obj['data']) return self
[ "def", "from_json", "(", "self", ",", "json_string", ")", ":", "obj", "=", "json", ".", "loads", "(", "json_string", ")", "self", ".", "from_dict", "(", "obj", "[", "'groups'", "]", ",", "obj", "[", "'data'", "]", ")", "return", "self" ]
Override current FlatTable using data from json. :param json_string: JSON String :type json_string: str
[ "Override", "current", "FlatTable", "using", "data", "from", "json", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/pivot_table.py#L76-L86
train
27,264
inasafe/inasafe
safe/utilities/pivot_table.py
FlatTable.from_dict
def from_dict(self, groups, data): """Populate FlatTable based on groups and data. :param groups: List of group name. :type groups: list :param data: Dictionary of raw table. :type data: list example of groups: ["road_type", "hazard"] example of data: [ ...
python
def from_dict(self, groups, data): """Populate FlatTable based on groups and data. :param groups: List of group name. :type groups: list :param data: Dictionary of raw table. :type data: list example of groups: ["road_type", "hazard"] example of data: [ ...
[ "def", "from_dict", "(", "self", ",", "groups", ",", "data", ")", ":", "self", ".", "groups", "=", "tuple", "(", "groups", ")", "for", "item", "in", "data", ":", "kwargs", "=", "{", "}", "for", "i", "in", "range", "(", "len", "(", "self", ".", ...
Populate FlatTable based on groups and data. :param groups: List of group name. :type groups: list :param data: Dictionary of raw table. :type data: list example of groups: ["road_type", "hazard"] example of data: [ ["residential", "low", 50], [...
[ "Populate", "FlatTable", "based", "on", "groups", "and", "data", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/pivot_table.py#L103-L128
train
27,265
inasafe/inasafe
safe/gui/tools/help/needs_calculator_help.py
needs_calculator_help
def needs_calculator_help(): """Help message for needs calculator dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(conten...
python
def needs_calculator_help(): """Help message for needs calculator dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(conten...
[ "def", "needs_calculator_help", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "heading", "(", ")", ")", "message", ".", "add", "(", "content",...
Help message for needs calculator dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message
[ "Help", "message", "for", "needs", "calculator", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/needs_calculator_help.py#L14-L27
train
27,266
inasafe/inasafe
safe/gis/vector/reproject.py
reproject
def reproject(layer, output_crs, callback=None): """Reproject a vector layer to a specific CRS. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsVectorLayer :param output_crs: The destination CRS. :type output_crs: QgsCoordinateReferen...
python
def reproject(layer, output_crs, callback=None): """Reproject a vector layer to a specific CRS. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsVectorLayer :param output_crs: The destination CRS. :type output_crs: QgsCoordinateReferen...
[ "def", "reproject", "(", "layer", ",", "output_crs", ",", "callback", "=", "None", ")", ":", "output_layer_name", "=", "reproject_steps", "[", "'output_layer_name'", "]", "output_layer_name", "=", "output_layer_name", "%", "layer", ".", "keywords", "[", "'layer_pu...
Reproject a vector layer to a specific CRS. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsVectorLayer :param output_crs: The destination CRS. :type output_crs: QgsCoordinateReferenceSystem :param callback: A function to all to indi...
[ "Reproject", "a", "vector", "layer", "to", "a", "specific", "CRS", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/reproject.py#L23-L78
train
27,267
inasafe/inasafe
safe/gui/tools/wizard/step_fc25_hazlayer_from_browser.py
StepFcHazLayerFromBrowser.set_widgets
def set_widgets(self): """Set widgets on the Hazard Layer From Browser tab.""" self.tvBrowserHazard_selection_changed() # Set icon hazard = self.parent.step_fc_functions1.selected_value( layer_purpose_hazard['key']) icon_path = get_image_path(hazard) self.lbl...
python
def set_widgets(self): """Set widgets on the Hazard Layer From Browser tab.""" self.tvBrowserHazard_selection_changed() # Set icon hazard = self.parent.step_fc_functions1.selected_value( layer_purpose_hazard['key']) icon_path = get_image_path(hazard) self.lbl...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "tvBrowserHazard_selection_changed", "(", ")", "# Set icon", "hazard", "=", "self", ".", "parent", ".", "step_fc_functions1", ".", "selected_value", "(", "layer_purpose_hazard", "[", "'key'", "]", ")", "i...
Set widgets on the Hazard Layer From Browser tab.
[ "Set", "widgets", "on", "the", "Hazard", "Layer", "From", "Browser", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc25_hazlayer_from_browser.py#L71-L79
train
27,268
inasafe/inasafe
safe/gui/tools/save_scenario.py
SaveScenarioDialog.validate_input
def validate_input(self): """Validate the input before saving a scenario. Those validations are: 1. self.exposure_layer must be not None 2. self.hazard_layer must be not None 3. self.function_id is not an empty string or None """ self.exposure_layer = layer_from_...
python
def validate_input(self): """Validate the input before saving a scenario. Those validations are: 1. self.exposure_layer must be not None 2. self.hazard_layer must be not None 3. self.function_id is not an empty string or None """ self.exposure_layer = layer_from_...
[ "def", "validate_input", "(", "self", ")", ":", "self", ".", "exposure_layer", "=", "layer_from_combo", "(", "self", ".", "dock", ".", "exposure_layer_combo", ")", "self", ".", "hazard_layer", "=", "layer_from_combo", "(", "self", ".", "dock", ".", "hazard_lay...
Validate the input before saving a scenario. Those validations are: 1. self.exposure_layer must be not None 2. self.hazard_layer must be not None 3. self.function_id is not an empty string or None
[ "Validate", "the", "input", "before", "saving", "a", "scenario", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/save_scenario.py#L65-L92
train
27,269
inasafe/inasafe
safe/gui/tools/save_scenario.py
SaveScenarioDialog.save_scenario
def save_scenario(self, scenario_file_path=None): """Save current scenario to a text file. You can use the saved scenario with the batch runner. :param scenario_file_path: A path to the scenario file. :type scenario_file_path: str """ # Validate Input warning_ti...
python
def save_scenario(self, scenario_file_path=None): """Save current scenario to a text file. You can use the saved scenario with the batch runner. :param scenario_file_path: A path to the scenario file. :type scenario_file_path: str """ # Validate Input warning_ti...
[ "def", "save_scenario", "(", "self", ",", "scenario_file_path", "=", "None", ")", ":", "# Validate Input", "warning_title", "=", "tr", "(", "'InaSAFE Save Scenario Warning'", ")", "is_valid", ",", "warning_message", "=", "self", ".", "validate_input", "(", ")", "i...
Save current scenario to a text file. You can use the saved scenario with the batch runner. :param scenario_file_path: A path to the scenario file. :type scenario_file_path: str
[ "Save", "current", "scenario", "to", "a", "text", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/save_scenario.py#L94-L183
train
27,270
inasafe/inasafe
safe/gui/tools/save_scenario.py
SaveScenarioDialog.relative_path
def relative_path(reference_path, input_path): """Get the relative path to input_path from reference_path. :param reference_path: The reference path. :type reference_path: str :param input_path: The input path. :type input_path: str """ start_path = os.path.dirn...
python
def relative_path(reference_path, input_path): """Get the relative path to input_path from reference_path. :param reference_path: The reference path. :type reference_path: str :param input_path: The input path. :type input_path: str """ start_path = os.path.dirn...
[ "def", "relative_path", "(", "reference_path", ",", "input_path", ")", ":", "start_path", "=", "os", ".", "path", ".", "dirname", "(", "reference_path", ")", "try", ":", "relative_path", "=", "os", ".", "path", ".", "relpath", "(", "input_path", ",", "star...
Get the relative path to input_path from reference_path. :param reference_path: The reference path. :type reference_path: str :param input_path: The input path. :type input_path: str
[ "Get", "the", "relative", "path", "to", "input_path", "from", "reference_path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/save_scenario.py#L186-L201
train
27,271
inasafe/inasafe
safe/report/report_metadata.py
ReportComponentsMetadata.info
def info(self): """Short info about the component. :return: Returned dictionary of information about the component. :rtype: dict """ return { 'key': self.key, 'processor': self.processor, 'extractor': self.extractor, 'output_path':...
python
def info(self): """Short info about the component. :return: Returned dictionary of information about the component. :rtype: dict """ return { 'key': self.key, 'processor': self.processor, 'extractor': self.extractor, 'output_path':...
[ "def", "info", "(", "self", ")", ":", "return", "{", "'key'", ":", "self", ".", "key", ",", "'processor'", ":", "self", ".", "processor", ",", "'extractor'", ":", "self", ".", "extractor", ",", "'output_path'", ":", "self", ".", "output_path", ",", "'o...
Short info about the component. :return: Returned dictionary of information about the component. :rtype: dict
[ "Short", "info", "about", "the", "component", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/report_metadata.py#L219-L233
train
27,272
inasafe/inasafe
safe/report/report_metadata.py
QgisComposerComponentsMetadata.info
def info(self): """Short info of the metadata. :return: Returned dictionary of information about the component. :rtype: dict """ return super(QgisComposerComponentsMetadata, self).info.update({ 'orientation': self.orientation, 'page_dpi': self.page_dpi, ...
python
def info(self): """Short info of the metadata. :return: Returned dictionary of information about the component. :rtype: dict """ return super(QgisComposerComponentsMetadata, self).info.update({ 'orientation': self.orientation, 'page_dpi': self.page_dpi, ...
[ "def", "info", "(", "self", ")", ":", "return", "super", "(", "QgisComposerComponentsMetadata", ",", "self", ")", ".", "info", ".", "update", "(", "{", "'orientation'", ":", "self", ".", "orientation", ",", "'page_dpi'", ":", "self", ".", "page_dpi", ",", ...
Short info of the metadata. :return: Returned dictionary of information about the component. :rtype: dict
[ "Short", "info", "of", "the", "metadata", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/report_metadata.py#L351-L362
train
27,273
inasafe/inasafe
safe/report/report_metadata.py
ReportMetadata.component_by_key
def component_by_key(self, key): """Retrieve component by its key. :param key: Component key :type key: str :return: ReportComponentsMetadata :rtype: ReportComponentsMetadata .. versionadded:: 4.0 """ filtered = [c for c in self.components if c.key == k...
python
def component_by_key(self, key): """Retrieve component by its key. :param key: Component key :type key: str :return: ReportComponentsMetadata :rtype: ReportComponentsMetadata .. versionadded:: 4.0 """ filtered = [c for c in self.components if c.key == k...
[ "def", "component_by_key", "(", "self", ",", "key", ")", ":", "filtered", "=", "[", "c", "for", "c", "in", "self", ".", "components", "if", "c", ".", "key", "==", "key", "]", "if", "filtered", ":", "return", "filtered", "[", "0", "]", "return", "No...
Retrieve component by its key. :param key: Component key :type key: str :return: ReportComponentsMetadata :rtype: ReportComponentsMetadata .. versionadded:: 4.0
[ "Retrieve", "component", "by", "its", "key", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/report_metadata.py#L471-L485
train
27,274
inasafe/inasafe
safe/report/report_metadata.py
ReportMetadata.component_by_tags
def component_by_tags(self, tags): """Retrieve components by tags. :param tags: List of tags :type tags: list :return: List of ReportComponentsMetadata :rtype: list[ReportComponentsMetadata] .. versionadded:: 4.0 """ tags_keys = [t['key'] for t in tags]...
python
def component_by_tags(self, tags): """Retrieve components by tags. :param tags: List of tags :type tags: list :return: List of ReportComponentsMetadata :rtype: list[ReportComponentsMetadata] .. versionadded:: 4.0 """ tags_keys = [t['key'] for t in tags]...
[ "def", "component_by_tags", "(", "self", ",", "tags", ")", ":", "tags_keys", "=", "[", "t", "[", "'key'", "]", "for", "t", "in", "tags", "]", "filtered", "=", "[", "c", "for", "c", "in", "self", ".", "components", "if", "set", "(", "tags_keys", ")"...
Retrieve components by tags. :param tags: List of tags :type tags: list :return: List of ReportComponentsMetadata :rtype: list[ReportComponentsMetadata] .. versionadded:: 4.0
[ "Retrieve", "components", "by", "tags", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/report_metadata.py#L487-L502
train
27,275
inasafe/inasafe
safe/definitions/minimum_needs.py
_normalize_field_name
def _normalize_field_name(value): """Normalizing value string used as key and field name. :param value: String to normalize :type value: str :return: normalized string :rtype: str """ # Replace non word/letter character return_value = re.sub(r'[^\w\s-]+', '', value) # Replaces whit...
python
def _normalize_field_name(value): """Normalizing value string used as key and field name. :param value: String to normalize :type value: str :return: normalized string :rtype: str """ # Replace non word/letter character return_value = re.sub(r'[^\w\s-]+', '', value) # Replaces whit...
[ "def", "_normalize_field_name", "(", "value", ")", ":", "# Replace non word/letter character", "return_value", "=", "re", ".", "sub", "(", "r'[^\\w\\s-]+'", ",", "''", ",", "value", ")", "# Replaces whitespace with underscores", "return_value", "=", "re", ".", "sub", ...
Normalizing value string used as key and field name. :param value: String to normalize :type value: str :return: normalized string :rtype: str
[ "Normalizing", "value", "string", "used", "as", "key", "and", "field", "name", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/minimum_needs.py#L31-L44
train
27,276
inasafe/inasafe
safe/definitions/minimum_needs.py
_initializes_minimum_needs_fields
def _initializes_minimum_needs_fields(): """Initialize minimum needs fields. Minimum needs definitions are taken from currently used profile. """ needs_profile = NeedsProfile() needs_profile.load() fields = [] needs_parameters = needs_profile.get_needs_parameters() for need_parameter ...
python
def _initializes_minimum_needs_fields(): """Initialize minimum needs fields. Minimum needs definitions are taken from currently used profile. """ needs_profile = NeedsProfile() needs_profile.load() fields = [] needs_parameters = needs_profile.get_needs_parameters() for need_parameter ...
[ "def", "_initializes_minimum_needs_fields", "(", ")", ":", "needs_profile", "=", "NeedsProfile", "(", ")", "needs_profile", ".", "load", "(", ")", "fields", "=", "[", "]", "needs_parameters", "=", "needs_profile", ".", "get_needs_parameters", "(", ")", "for", "n...
Initialize minimum needs fields. Minimum needs definitions are taken from currently used profile.
[ "Initialize", "minimum", "needs", "fields", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/minimum_needs.py#L47-L92
train
27,277
inasafe/inasafe
safe/definitions/minimum_needs.py
minimum_needs_parameter
def minimum_needs_parameter(field=None, parameter_name=None): """Get minimum needs parameter from a given field. :param field: Field provided :type field: dict :param parameter_name: Need parameter's name :type parameter_name: str :return: Need paramter :rtype: ResourceParameter """ ...
python
def minimum_needs_parameter(field=None, parameter_name=None): """Get minimum needs parameter from a given field. :param field: Field provided :type field: dict :param parameter_name: Need parameter's name :type parameter_name: str :return: Need paramter :rtype: ResourceParameter """ ...
[ "def", "minimum_needs_parameter", "(", "field", "=", "None", ",", "parameter_name", "=", "None", ")", ":", "try", ":", "if", "field", "[", "'key'", "]", ":", "for", "need_field", "in", "minimum_needs_fields", ":", "if", "need_field", "[", "'key'", "]", "==...
Get minimum needs parameter from a given field. :param field: Field provided :type field: dict :param parameter_name: Need parameter's name :type parameter_name: str :return: Need paramter :rtype: ResourceParameter
[ "Get", "minimum", "needs", "parameter", "from", "a", "given", "field", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/definitions/minimum_needs.py#L110-L136
train
27,278
inasafe/inasafe
safe/gui/tools/wizard/wizard_step.py
WizardStep.step_type
def step_type(self): """Whether it's a IFCW step or Keyword Wizard Step.""" if 'stepfc' in self.__class__.__name__.lower(): return STEP_FC if 'stepkw' in self.__class__.__name__.lower(): return STEP_KW
python
def step_type(self): """Whether it's a IFCW step or Keyword Wizard Step.""" if 'stepfc' in self.__class__.__name__.lower(): return STEP_FC if 'stepkw' in self.__class__.__name__.lower(): return STEP_KW
[ "def", "step_type", "(", "self", ")", ":", "if", "'stepfc'", "in", "self", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ":", "return", "STEP_FC", "if", "'stepkw'", "in", "self", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ...
Whether it's a IFCW step or Keyword Wizard Step.
[ "Whether", "it", "s", "a", "IFCW", "step", "or", "Keyword", "Wizard", "Step", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_step.py#L92-L97
train
27,279
inasafe/inasafe
safe/gui/tools/wizard/wizard_step.py
WizardStep.help
def help(self): """Return full help message for the step wizard. :returns: A message object contains help text. :rtype: m.Message """ message = m.Message() message.add(m.Brand()) message.add(self.help_heading()) message.add(self.help_content()) re...
python
def help(self): """Return full help message for the step wizard. :returns: A message object contains help text. :rtype: m.Message """ message = m.Message() message.add(m.Brand()) message.add(self.help_heading()) message.add(self.help_content()) re...
[ "def", "help", "(", "self", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "self", ".", "help_heading", "(", ")", ")", "message", ".", "add", "(...
Return full help message for the step wizard. :returns: A message object contains help text. :rtype: m.Message
[ "Return", "full", "help", "message", "for", "the", "step", "wizard", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_step.py#L108-L118
train
27,280
inasafe/inasafe
safe/gui/tools/wizard/wizard_step.py
WizardStep.help_heading
def help_heading(self): """Helper method that returns just the header. :returns: A heading object. :rtype: safe.messaging.heading.Heading """ message = m.Heading( tr('Help for {step_name}').format(step_name=self.step_name), **SUBSECTION_STYLE) ret...
python
def help_heading(self): """Helper method that returns just the header. :returns: A heading object. :rtype: safe.messaging.heading.Heading """ message = m.Heading( tr('Help for {step_name}').format(step_name=self.step_name), **SUBSECTION_STYLE) ret...
[ "def", "help_heading", "(", "self", ")", ":", "message", "=", "m", ".", "Heading", "(", "tr", "(", "'Help for {step_name}'", ")", ".", "format", "(", "step_name", "=", "self", ".", "step_name", ")", ",", "*", "*", "SUBSECTION_STYLE", ")", "return", "mess...
Helper method that returns just the header. :returns: A heading object. :rtype: safe.messaging.heading.Heading
[ "Helper", "method", "that", "returns", "just", "the", "header", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_step.py#L120-L129
train
27,281
inasafe/inasafe
safe/utilities/help.py
get_help_html
def get_help_html(message=None): """Create the HTML content for the help dialog or for external browser :param message: An optional message object to display in the dialog. :type message: Message.Message :return: the help HTML content :rtype: str """ html = html_help_header() if mes...
python
def get_help_html(message=None): """Create the HTML content for the help dialog or for external browser :param message: An optional message object to display in the dialog. :type message: Message.Message :return: the help HTML content :rtype: str """ html = html_help_header() if mes...
[ "def", "get_help_html", "(", "message", "=", "None", ")", ":", "html", "=", "html_help_header", "(", ")", "if", "message", "is", "None", ":", "message", "=", "dock_help", "(", ")", "html", "+=", "message", ".", "to_html", "(", ")", "html", "+=", "html_...
Create the HTML content for the help dialog or for external browser :param message: An optional message object to display in the dialog. :type message: Message.Message :return: the help HTML content :rtype: str
[ "Create", "the", "HTML", "content", "for", "the", "help", "dialog", "or", "for", "external", "browser" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/help.py#L15-L32
train
27,282
inasafe/inasafe
safe/utilities/help.py
show_help
def show_help(message=None): """Open an help message in the user's browser :param message: An optional message object to display in the dialog. :type message: Message.Message """ help_path = mktemp('.html') with open(help_path, 'wb+') as f: help_html = get_help_html(message) f....
python
def show_help(message=None): """Open an help message in the user's browser :param message: An optional message object to display in the dialog. :type message: Message.Message """ help_path = mktemp('.html') with open(help_path, 'wb+') as f: help_html = get_help_html(message) f....
[ "def", "show_help", "(", "message", "=", "None", ")", ":", "help_path", "=", "mktemp", "(", "'.html'", ")", "with", "open", "(", "help_path", ",", "'wb+'", ")", "as", "f", ":", "help_html", "=", "get_help_html", "(", "message", ")", "f", ".", "write", ...
Open an help message in the user's browser :param message: An optional message object to display in the dialog. :type message: Message.Message
[ "Open", "an", "help", "message", "in", "the", "user", "s", "browser" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/help.py#L35-L47
train
27,283
inasafe/inasafe
safe/gui/tools/help/definitions_help.py
definitions_help
def definitions_help(): """Help message for Definitions. .. versionadded:: 4.0.0 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content()) return me...
python
def definitions_help(): """Help message for Definitions. .. versionadded:: 4.0.0 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content()) return me...
[ "def", "definitions_help", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "heading", "(", ")", ")", "message", ".", "add", "(", "content", "(...
Help message for Definitions. .. versionadded:: 4.0.0 :returns: A message object containing helpful information. :rtype: messaging.message.Message
[ "Help", "message", "for", "Definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/definitions_help.py#L84-L96
train
27,284
inasafe/inasafe
safe/gui/tools/help/definitions_help.py
_make_defaults_hazard_table
def _make_defaults_hazard_table(): """Build headers for a table related to hazard classes. :return: A table with headers. :rtype: m.Table """ table = m.Table(style_class='table table-condensed table-striped') row = m.Row() # first row is for colour - we dont use a header here as some tables...
python
def _make_defaults_hazard_table(): """Build headers for a table related to hazard classes. :return: A table with headers. :rtype: m.Table """ table = m.Table(style_class='table table-condensed table-striped') row = m.Row() # first row is for colour - we dont use a header here as some tables...
[ "def", "_make_defaults_hazard_table", "(", ")", ":", "table", "=", "m", ".", "Table", "(", "style_class", "=", "'table table-condensed table-striped'", ")", "row", "=", "m", ".", "Row", "(", ")", "# first row is for colour - we dont use a header here as some tables", "#...
Build headers for a table related to hazard classes. :return: A table with headers. :rtype: m.Table
[ "Build", "headers", "for", "a", "table", "related", "to", "hazard", "classes", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/definitions_help.py#L1437-L1456
train
27,285
inasafe/inasafe
safe/gui/tools/help/definitions_help.py
_make_defaults_exposure_table
def _make_defaults_exposure_table(): """Build headers for a table related to exposure classes. :return: A table with headers. :rtype: m.Table """ table = m.Table(style_class='table table-condensed table-striped') row = m.Row() row.add(m.Cell(tr('Name'), header=True)) row.add(m.Cell(tr('...
python
def _make_defaults_exposure_table(): """Build headers for a table related to exposure classes. :return: A table with headers. :rtype: m.Table """ table = m.Table(style_class='table table-condensed table-striped') row = m.Row() row.add(m.Cell(tr('Name'), header=True)) row.add(m.Cell(tr('...
[ "def", "_make_defaults_exposure_table", "(", ")", ":", "table", "=", "m", ".", "Table", "(", "style_class", "=", "'table table-condensed table-striped'", ")", "row", "=", "m", ".", "Row", "(", ")", "row", ".", "add", "(", "m", ".", "Cell", "(", "tr", "("...
Build headers for a table related to exposure classes. :return: A table with headers. :rtype: m.Table
[ "Build", "headers", "for", "a", "table", "related", "to", "exposure", "classes", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/definitions_help.py#L1459-L1470
train
27,286
inasafe/inasafe
safe/gui/tools/help/definitions_help.py
_add_dict_to_bullets
def _add_dict_to_bullets(target, value): """Add notes and actions in dictionary to the bullets :param target: Target bullets :type target: Bullets :param value: Dictionary that contains actions or notes :type value: dict :return: Updated bullets :rtype: Bullets """ actions = value...
python
def _add_dict_to_bullets(target, value): """Add notes and actions in dictionary to the bullets :param target: Target bullets :type target: Bullets :param value: Dictionary that contains actions or notes :type value: dict :return: Updated bullets :rtype: Bullets """ actions = value...
[ "def", "_add_dict_to_bullets", "(", "target", ",", "value", ")", ":", "actions", "=", "value", ".", "get", "(", "'action_list'", ")", "notes", "=", "value", ".", "get", "(", "'item_list'", ")", "items_tobe_added", "=", "[", "]", "if", "actions", ":", "it...
Add notes and actions in dictionary to the bullets :param target: Target bullets :type target: Bullets :param value: Dictionary that contains actions or notes :type value: dict :return: Updated bullets :rtype: Bullets
[ "Add", "notes", "and", "actions", "in", "dictionary", "to", "the", "bullets" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/definitions_help.py#L1473-L1496
train
27,287
inasafe/inasafe
safe/gui/tools/wizard/step_fc35_explayer_from_canvas.py
StepFcExpLayerFromCanvas.selected_canvas_explayer
def selected_canvas_explayer(self): """Obtain the canvas exposure layer selected by user. :returns: The currently selected map layer in the list. :rtype: QgsMapLayer """ if self.lstCanvasExpLayers.selectedItems(): item = self.lstCanvasExpLayers.currentItem() ...
python
def selected_canvas_explayer(self): """Obtain the canvas exposure layer selected by user. :returns: The currently selected map layer in the list. :rtype: QgsMapLayer """ if self.lstCanvasExpLayers.selectedItems(): item = self.lstCanvasExpLayers.currentItem() ...
[ "def", "selected_canvas_explayer", "(", "self", ")", ":", "if", "self", ".", "lstCanvasExpLayers", ".", "selectedItems", "(", ")", ":", "item", "=", "self", ".", "lstCanvasExpLayers", ".", "currentItem", "(", ")", "else", ":", "return", "None", "try", ":", ...
Obtain the canvas exposure layer selected by user. :returns: The currently selected map layer in the list. :rtype: QgsMapLayer
[ "Obtain", "the", "canvas", "exposure", "layer", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc35_explayer_from_canvas.py#L73-L90
train
27,288
inasafe/inasafe
safe/gui/tools/wizard/step_fc35_explayer_from_canvas.py
StepFcExpLayerFromCanvas.set_widgets
def set_widgets(self): """Set widgets on the Exposure Layer From Canvas tab.""" # The list is already populated in the previous step, but now we # need to do it again in case we're back from the Keyword Wizard. # First, preserve self.parent.layer before clearing the list last_lay...
python
def set_widgets(self): """Set widgets on the Exposure Layer From Canvas tab.""" # The list is already populated in the previous step, but now we # need to do it again in case we're back from the Keyword Wizard. # First, preserve self.parent.layer before clearing the list last_lay...
[ "def", "set_widgets", "(", "self", ")", ":", "# The list is already populated in the previous step, but now we", "# need to do it again in case we're back from the Keyword Wizard.", "# First, preserve self.parent.layer before clearing the list", "last_layer", "=", "self", ".", "parent", ...
Set widgets on the Exposure Layer From Canvas tab.
[ "Set", "widgets", "on", "the", "Exposure", "Layer", "From", "Canvas", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc35_explayer_from_canvas.py#L110-L132
train
27,289
inasafe/inasafe
extras/data_audit.py
IP_verified
def IP_verified(directory, extensions_to_ignore=None, directories_to_ignore=None, files_to_ignore=None, verbose=False): """Find and audit potential data files that might violate IP This is the public function to be used to ascertain that all d...
python
def IP_verified(directory, extensions_to_ignore=None, directories_to_ignore=None, files_to_ignore=None, verbose=False): """Find and audit potential data files that might violate IP This is the public function to be used to ascertain that all d...
[ "def", "IP_verified", "(", "directory", ",", "extensions_to_ignore", "=", "None", ",", "directories_to_ignore", "=", "None", ",", "files_to_ignore", "=", "None", ",", "verbose", "=", "False", ")", ":", "# Identify data files", "oldpath", "=", "None", "all_files", ...
Find and audit potential data files that might violate IP This is the public function to be used to ascertain that all data in the specified directory tree has been audited according to the GA data IP tracking process. if IP_verified is False: # Stop and take remedial action ... el...
[ "Find", "and", "audit", "potential", "data", "files", "that", "might", "violate", "IP" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/data_audit.py#L77-L198
train
27,290
inasafe/inasafe
extras/data_audit.py
identify_datafiles
def identify_datafiles(root, extensions_to_ignore=None, directories_to_ignore=None, files_to_ignore=None): """ Identify files that might contain data See function IP_verified() for details about optinoal parmeters """ for dirpath, di...
python
def identify_datafiles(root, extensions_to_ignore=None, directories_to_ignore=None, files_to_ignore=None): """ Identify files that might contain data See function IP_verified() for details about optinoal parmeters """ for dirpath, di...
[ "def", "identify_datafiles", "(", "root", ",", "extensions_to_ignore", "=", "None", ",", "directories_to_ignore", "=", "None", ",", "files_to_ignore", "=", "None", ")", ":", "for", "dirpath", ",", "dirnames", ",", "filenames", "in", "walk", "(", "root", ")", ...
Identify files that might contain data See function IP_verified() for details about optinoal parmeters
[ "Identify", "files", "that", "might", "contain", "data" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/data_audit.py#L205-L234
train
27,291
inasafe/inasafe
safe/gui/widgets/profile_widget.py
ProfileWidget.data
def data(self): """Get the data from the current state of widgets. :returns: Profile data in dictionary. :rtype: dict """ if len(self.widget_items) == 0: return data = {} for hazard_item in self.widget_items: hazard = hazard_item.data(0, Q...
python
def data(self): """Get the data from the current state of widgets. :returns: Profile data in dictionary. :rtype: dict """ if len(self.widget_items) == 0: return data = {} for hazard_item in self.widget_items: hazard = hazard_item.data(0, Q...
[ "def", "data", "(", "self", ")", ":", "if", "len", "(", "self", ".", "widget_items", ")", "==", "0", ":", "return", "data", "=", "{", "}", "for", "hazard_item", "in", "self", ".", "widget_items", ":", "hazard", "=", "hazard_item", ".", "data", "(", ...
Get the data from the current state of widgets. :returns: Profile data in dictionary. :rtype: dict
[ "Get", "the", "data", "from", "the", "current", "state", "of", "widgets", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/profile_widget.py#L58-L90
train
27,292
inasafe/inasafe
safe/gui/widgets/profile_widget.py
ProfileWidget.data
def data(self, profile_data): """Set data for the widget. :param profile_data: profile data. :type profile_data: dict It will replace the previous data. """ default_profile = generate_default_profile() self.clear() for hazard in sorted(default_profile.ke...
python
def data(self, profile_data): """Set data for the widget. :param profile_data: profile data. :type profile_data: dict It will replace the previous data. """ default_profile = generate_default_profile() self.clear() for hazard in sorted(default_profile.ke...
[ "def", "data", "(", "self", ",", "profile_data", ")", ":", "default_profile", "=", "generate_default_profile", "(", ")", "self", ".", "clear", "(", ")", "for", "hazard", "in", "sorted", "(", "default_profile", ".", "keys", "(", ")", ")", ":", "classificati...
Set data for the widget. :param profile_data: profile data. :type profile_data: dict It will replace the previous data.
[ "Set", "data", "for", "the", "widget", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/profile_widget.py#L93-L158
train
27,293
inasafe/inasafe
safe/gui/tools/wizard/step_fc05_functions2.py
StepFcFunctions2.selected_functions_2
def selected_functions_2(self): """Obtain functions available for hazard and exposure selected by user. :returns: List of the available functions metadata. :rtype: list, None """ selection = self.tblFunctions2.selectedItems() if len(selection) != 1: return []...
python
def selected_functions_2(self): """Obtain functions available for hazard and exposure selected by user. :returns: List of the available functions metadata. :rtype: list, None """ selection = self.tblFunctions2.selectedItems() if len(selection) != 1: return []...
[ "def", "selected_functions_2", "(", "self", ")", ":", "selection", "=", "self", ".", "tblFunctions2", ".", "selectedItems", "(", ")", "if", "len", "(", "selection", ")", "!=", "1", ":", "return", "[", "]", "return", "selection", "[", "0", "]", ".", "da...
Obtain functions available for hazard and exposure selected by user. :returns: List of the available functions metadata. :rtype: list, None
[ "Obtain", "functions", "available", "for", "hazard", "and", "exposure", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc05_functions2.py#L86-L95
train
27,294
inasafe/inasafe
safe/gui/tools/wizard/step_fc05_functions2.py
StepFcFunctions2.set_widgets
def set_widgets(self): """Set widgets on the Impact Functions Table 2 tab.""" self.tblFunctions2.clear() hazard, exposure, _, _ = self.parent.\ selected_impact_function_constraints() hazard_layer_geometries = get_allowed_geometries( layer_purpose_hazard['key']) ...
python
def set_widgets(self): """Set widgets on the Impact Functions Table 2 tab.""" self.tblFunctions2.clear() hazard, exposure, _, _ = self.parent.\ selected_impact_function_constraints() hazard_layer_geometries = get_allowed_geometries( layer_purpose_hazard['key']) ...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "tblFunctions2", ".", "clear", "(", ")", "hazard", ",", "exposure", ",", "_", ",", "_", "=", "self", ".", "parent", ".", "selected_impact_function_constraints", "(", ")", "hazard_layer_geometries", "=...
Set widgets on the Impact Functions Table 2 tab.
[ "Set", "widgets", "on", "the", "Impact", "Functions", "Table", "2", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc05_functions2.py#L141-L202
train
27,295
inasafe/inasafe
safe/common/parameters/percentage_parameter_widget.py
PercentageSpinBox.setValue
def setValue(self, p_float): """Override method to set a value to show it as 0 to 100. :param p_float: The float number that want to be set. :type p_float: float """ p_float = p_float * 100 super(PercentageSpinBox, self).setValue(p_float)
python
def setValue(self, p_float): """Override method to set a value to show it as 0 to 100. :param p_float: The float number that want to be set. :type p_float: float """ p_float = p_float * 100 super(PercentageSpinBox, self).setValue(p_float)
[ "def", "setValue", "(", "self", ",", "p_float", ")", ":", "p_float", "=", "p_float", "*", "100", "super", "(", "PercentageSpinBox", ",", "self", ")", ".", "setValue", "(", "p_float", ")" ]
Override method to set a value to show it as 0 to 100. :param p_float: The float number that want to be set. :type p_float: float
[ "Override", "method", "to", "set", "a", "value", "to", "show", "it", "as", "0", "to", "100", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/percentage_parameter_widget.py#L53-L61
train
27,296
inasafe/inasafe
safe/gui/widgets/message_viewer.py
MessageViewer.impact_path
def impact_path(self, value): """Setter to impact path. :param value: The impact path. :type value: str """ self._impact_path = value if value is None: self.action_show_report.setEnabled(False) self.action_show_log.setEnabled(False) se...
python
def impact_path(self, value): """Setter to impact path. :param value: The impact path. :type value: str """ self._impact_path = value if value is None: self.action_show_report.setEnabled(False) self.action_show_log.setEnabled(False) se...
[ "def", "impact_path", "(", "self", ",", "value", ")", ":", "self", ".", "_impact_path", "=", "value", "if", "value", "is", "None", ":", "self", ".", "action_show_report", ".", "setEnabled", "(", "False", ")", "self", ".", "action_show_log", ".", "setEnable...
Setter to impact path. :param value: The impact path. :type value: str
[ "Setter", "to", "impact", "path", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L103-L123
train
27,297
inasafe/inasafe
safe/gui/widgets/message_viewer.py
MessageViewer.contextMenuEvent
def contextMenuEvent(self, event): """Slot automatically called by Qt on right click on the WebView. :param event: the event that caused the context menu to be called. """ context_menu = QMenu(self) # add select all action_select_all = self.page().action( Q...
python
def contextMenuEvent(self, event): """Slot automatically called by Qt on right click on the WebView. :param event: the event that caused the context menu to be called. """ context_menu = QMenu(self) # add select all action_select_all = self.page().action( Q...
[ "def", "contextMenuEvent", "(", "self", ",", "event", ")", ":", "context_menu", "=", "QMenu", "(", "self", ")", "# add select all", "action_select_all", "=", "self", ".", "page", "(", ")", ".", "action", "(", "QtWebKitWidgets", ".", "QWebPage", ".", "SelectA...
Slot automatically called by Qt on right click on the WebView. :param event: the event that caused the context menu to be called.
[ "Slot", "automatically", "called", "by", "Qt", "on", "right", "click", "on", "the", "WebView", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L125-L182
train
27,298
inasafe/inasafe
safe/gui/widgets/message_viewer.py
MessageViewer.static_message_event
def static_message_event(self, sender, message): """Static message event handler - set message state based on event. Static message events will clear the message buffer before displaying themselves. :param sender: Unused - the object that sent the message. :type sender: Object,...
python
def static_message_event(self, sender, message): """Static message event handler - set message state based on event. Static message events will clear the message buffer before displaying themselves. :param sender: Unused - the object that sent the message. :type sender: Object,...
[ "def", "static_message_event", "(", "self", ",", "sender", ",", "message", ")", ":", "self", ".", "static_message_count", "+=", "1", "if", "message", "==", "self", ".", "static_message", ":", "return", "# LOGGER.debug('Static message event %i' % self.static_message_coun...
Static message event handler - set message state based on event. Static message events will clear the message buffer before displaying themselves. :param sender: Unused - the object that sent the message. :type sender: Object, None :param message: A message to show in the view...
[ "Static", "message", "event", "handler", "-", "set", "message", "state", "based", "on", "event", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L184-L205
train
27,299