_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q243700 | StepKwMultiClassifications.set_wizard_step_description | train | def set_wizard_step_description(self):
"""Set the text for description."""
subcategory = self.parent.step_kw_subcategory.selected_subcategory()
field = self.parent.step_kw_field.selected_fields()
is_raster = is_raster_layer(self.parent.layer)
if is_raster:
if self.la... | python | {
"resource": ""
} |
q243701 | StepKwMultiClassifications.edit_button_clicked | train | def edit_button_clicked(self, edit_button, exposure_combo_box, exposure):
"""Method to handle when an edit button is clicked.
:param edit_button: The edit button.
:type edit_button: QPushButton
:param exposure_combo_box: The combo box of the exposure, contains
list of class... | python | {
"resource": ""
} |
q243702 | StepKwMultiClassifications.set_widgets | train | def set_widgets(self):
"""Set widgets on the Multi classification step."""
self.clear()
self.layer_mode = self.parent.step_kw_layermode.selected_layermode()
self.layer_purpose = self.parent.step_kw_purpose.selected_purpose()
self.set_current_state()
# Set the step descri... | python | {
"resource": ""
} |
q243703 | StepKwMultiClassifications.add_buttons | train | def add_buttons(self, classification):
"""Helper to setup 3 buttons.
:param classification: The current classification.
:type classification: dict
"""
# Note(IS): Until we have good behaviour, we will disable cancel
# button.
# Add 3 buttons: Restore default, Can... | python | {
"resource": ""
} |
q243704 | StepKwMultiClassifications.update_dragged_item_flags | train | def update_dragged_item_flags(self, item):
"""Fix the drop flag after the item is dropped.
Check if it looks like an item dragged from QListWidget
to QTreeWidget and disable the drop flag.
For some reasons the flag is set when dragging.
:param item: Item which is dragged.
... | python | {
"resource": ""
} |
q243705 | StepKwMultiClassifications.cancel_button_clicked | train | def cancel_button_clicked(self):
"""Action for cancel button clicked."""
# Change mode
self.mode = CHOOSE_MODE
# Enable all edit buttons and combo boxes
for i in range(len(self.exposures)):
if i == self.special_case_index:
self.exposure_edit_buttons[i]... | python | {
"resource": ""
} |
q243706 | StepKwMultiClassifications.save_button_clicked | train | def save_button_clicked(self, classification):
"""Action for save button clicked.
:param classification: The classification that being edited.
:type classification: dict
"""
# Save current edit
if self.layer_mode == layer_mode_continuous:
thresholds = self.ge... | python | {
"resource": ""
} |
q243707 | StepKwMultiClassifications.restore_default_button_clicked | train | def restore_default_button_clicked(self, classification):
"""Action for restore default button clicked.
It will set the threshold with default value.
:param classification: The classification that being edited.
:type classification: dict
"""
# Obtain default value
... | python | {
"resource": ""
} |
q243708 | StepKwMultiClassifications.get_threshold | train | def get_threshold(self):
"""Return threshold based on current state."""
value_map = dict()
for key, value in list(self.threshold_classes.items()):
value_map[key] = [
value[0].value(),
value[1].value(),
]
return value_map | python | {
"resource": ""
} |
q243709 | StepKwMultiClassifications.set_current_state | train | def set_current_state(self):
""""Helper to set the state of the step from current keywords."""
if not self.thresholds:
self.thresholds = self.parent.get_existing_keyword('thresholds')
if not self.value_maps:
self.value_maps = self.parent.get_existing_keyword('value_maps') | python | {
"resource": ""
} |
q243710 | StepKwMultiClassifications.classifications_combo_box_changed | train | def classifications_combo_box_changed(
self, index, exposure, exposure_combo_box, edit_button):
"""Action when classification combo box changed.
:param index: The index of the combo box.
:type index: int
:param exposure: The exposure associated with the combo box.
:... | python | {
"resource": ""
} |
q243711 | StepKwMultiClassifications.activate_classification | train | def activate_classification(self, exposure, classification=None):
"""Set active to True for classification for the exposure.
If classification = None, all classification set active = False.
:param exposure: Exposure definition.
:type exposure: dict
:param classification: Class... | python | {
"resource": ""
} |
q243712 | set_inasafe_default_value_qsetting | train | def set_inasafe_default_value_qsetting(
qsetting, category, inasafe_field_key, value):
"""Helper method to set inasafe default value to qsetting.
:param qsetting: QSettings.
:type qsetting: QSettings
:param category: Category of the default value. It can be global or
recent. Global mea... | python | {
"resource": ""
} |
q243713 | get_inasafe_default_value_qsetting | train | def get_inasafe_default_value_qsetting(
qsetting, category, inasafe_field_key):
"""Helper method to get the inasafe default value from qsetting.
:param qsetting: QSetting.
:type qsetting: QSetting
:param category: Category of the default value. It can be global or
recent. Global means ... | python | {
"resource": ""
} |
q243714 | FileDownloader.download | train | def download(self):
"""Downloading the file.
:returns: True if success, otherwise returns a tuple with format like
this (QNetworkReply.NetworkError, error_message)
:raises: IOError - when cannot create output_path
"""
# Prepare output path
self.output_file =... | python | {
"resource": ""
} |
q243715 | FileDownloader.get_buffer | train | def get_buffer(self):
"""Get buffer from self.reply and store it to our buffer container."""
buffer_size = self.reply.size()
data = self.reply.read(buffer_size)
self.downloaded_file_buffer.append(data) | python | {
"resource": ""
} |
q243716 | StepKwTitle.on_leTitle_textChanged | train | def on_leTitle_textChanged(self):
"""Unlock the Next button
.. note:: This is an automatic Qt slot
executed when the title value changes.
"""
self.parent.pbnNext.setEnabled(bool(self.leTitle.text())) | python | {
"resource": ""
} |
q243717 | StepKwTitle.set_widgets | train | def set_widgets(self):
"""Set widgets on the Title tab."""
# Set title from keyword first, if not found use layer name
if self.parent.layer:
if self.parent.get_existing_keyword('title'):
title = self.parent.get_existing_keyword('title')
else:
... | python | {
"resource": ""
} |
q243718 | ExtentSelectorDialog.start_capture | train | def start_capture(self):
"""Start capturing the rectangle."""
previous_map_tool = self.canvas.mapTool()
if previous_map_tool != self.tool:
self.previous_map_tool = previous_map_tool
self.canvas.setMapTool(self.tool)
self.hide() | python | {
"resource": ""
} |
q243719 | ExtentSelectorDialog.stop_capture | train | def stop_capture(self):
"""Stop capturing the rectangle and reshow the dialog."""
self._populate_coordinates()
self.canvas.setMapTool(self.previous_map_tool)
self.show() | python | {
"resource": ""
} |
q243720 | ExtentSelectorDialog.clear | train | def clear(self):
"""Clear the currently set extent."""
self.tool.reset()
self._populate_coordinates()
# Revert to using hazard, exposure and view as basis for analysis
self.hazard_exposure_view_extent.setChecked(True) | python | {
"resource": ""
} |
q243721 | ExtentSelectorDialog.reject | train | def reject(self):
"""User rejected the rectangle."""
self.canvas.unsetMapTool(self.tool)
if self.previous_map_tool != self.tool:
self.canvas.setMapTool(self.previous_map_tool)
self.tool.reset()
self.extent_selector_closed.emit()
super(ExtentSelectorDialog, sel... | python | {
"resource": ""
} |
q243722 | ExtentSelectorDialog.accept | train | def accept(self):
"""User accepted the rectangle."""
mode = None
if self.hazard_exposure_view_extent.isChecked():
mode = HAZARD_EXPOSURE_VIEW
elif self.exposure_only.isChecked():
mode = EXPOSURE
elif self.hazard_exposure_only.isChecked():
mode ... | python | {
"resource": ""
} |
q243723 | ExtentSelectorDialog._are_coordinates_valid | train | def _are_coordinates_valid(self):
"""Check if the coordinates are valid.
:return: True if coordinates are valid otherwise False.
:type: bool
"""
try:
QgsPointXY(
self.x_minimum.value(),
self.y_maximum.value())
QgsPointXY(
... | python | {
"resource": ""
} |
q243724 | ExtentSelectorDialog._coordinates_changed | train | def _coordinates_changed(self):
"""Handle a change in the coordinate input boxes."""
if self._are_coordinates_valid():
point1 = QgsPointXY(
self.x_minimum.value(),
self.y_maximum.value())
point2 = QgsPointXY(
self.x_maximum.value(),... | python | {
"resource": ""
} |
q243725 | ExtentSelectorDialog._populate_coordinates | train | def _populate_coordinates(self):
"""Update the UI with the current active coordinates."""
rect = self.tool.rectangle()
self.blockSignals(True)
if not rect.isEmpty():
self.x_minimum.setValue(rect.xMinimum())
self.y_minimum.setValue(rect.yMinimum())
self... | python | {
"resource": ""
} |
q243726 | ExtentSelectorDialog.bookmarks_index_changed | train | def bookmarks_index_changed(self):
"""Update the UI when the bookmarks combobox has changed."""
index = self.bookmarks_list.currentIndex()
if index >= 0:
self.tool.reset()
rectangle = self.bookmarks_list.itemData(index)
self.tool.set_rectangle(rectangle)
... | python | {
"resource": ""
} |
q243727 | ExtentSelectorDialog.on_hazard_exposure_bookmark_toggled | train | def on_hazard_exposure_bookmark_toggled(self, enabled):
"""Update the UI when the user toggles the bookmarks radiobutton.
:param enabled: The status of the radiobutton.
:type enabled: bool
"""
if enabled:
self.bookmarks_index_changed()
else:
self.... | python | {
"resource": ""
} |
q243728 | ExtentSelectorDialog._populate_bookmarks_list | train | def _populate_bookmarks_list(self):
"""Read the sqlite database and populate the bookmarks list.
If no bookmarks are found, the bookmarks radio button will be disabled
and the label will be shown indicating that the user should add
bookmarks in QGIS first.
Every bookmark are re... | python | {
"resource": ""
} |
q243729 | basestring_to_message | train | def basestring_to_message(text):
"""Convert a basestring to a Message object if needed.
Avoid using this function, better to create the Message object yourself.
This one is very generic.
This function exists ust in case we get a basestring and we really need a
Message object.
:param text: The... | python | {
"resource": ""
} |
q243730 | get_error_message | train | def get_error_message(exception, context=None, suggestion=None):
"""Convert exception into an ErrorMessage containing a stack trace.
:param exception: Exception object.
:type exception: Exception
:param context: Optional context message.
:type context: str
:param suggestion: Optional suggesti... | python | {
"resource": ""
} |
q243731 | humanise_exception | train | def humanise_exception(exception):
"""Humanise a python exception by giving the class name and traceback.
The function will return a tuple with the exception name and the traceback.
:param exception: Exception object.
:type exception: Exception
:return: A tuple with the exception name and the tra... | python | {
"resource": ""
} |
q243732 | html_to_file | train | def html_to_file(html, file_path=None, open_browser=False):
"""Save the html to an html file adapting the paths to the filesystem.
if a file_path is passed, it is used, if not a unique_filename is
generated.
:param html: the html for the output file.
:type html: str
:param file_path: the path... | python | {
"resource": ""
} |
q243733 | is_keyword_version_supported | train | def is_keyword_version_supported(
keyword_version, inasafe_version=inasafe_keyword_version):
"""Check if the keyword version is supported by this InaSAFE version.
.. versionadded: 3.3
:param keyword_version: String representation of the keyword version.
:type keyword_version: str
:param i... | python | {
"resource": ""
} |
q243734 | write_json | train | def write_json(data, filename):
"""Custom handler for writing json file in InaSAFE.
Criteria:
- use indent = 2
- Handle NULL from QGIS
:param data: The data that will be written.
:type data: dict
:param filename: The file name.
:type filename: str
"""
def custom_default(obj):... | python | {
"resource": ""
} |
q243735 | monkey_patch_keywords | train | def monkey_patch_keywords(layer):
"""In InaSAFE V4, we do monkey patching for keywords.
:param layer: The layer to monkey patch keywords.
:type layer: QgsMapLayer
"""
keyword_io = KeywordIO()
try:
layer.keywords = keyword_io.read_keywords(layer)
except (NoKeywordsFoundError, Metadat... | python | {
"resource": ""
} |
q243736 | readable_os_version | train | def readable_os_version():
"""Give a proper name for OS version
:return: Proper OS version
:rtype: str
"""
if platform.system() == 'Linux':
return _linux_os_release()
elif platform.system() == 'Darwin':
return ' {version}'.format(version=platform.mac_ver()[0])
elif platform.... | python | {
"resource": ""
} |
q243737 | is_plugin_installed | train | def is_plugin_installed(name):
"""Check if a plugin is installed, even if it's not enabled.
:param name: Name of the plugin to check.
:type name: string
:return: If the plugin is installed.
:rtype: bool
"""
for directory in plugin_paths:
if isdir(join(directory, name)):
... | python | {
"resource": ""
} |
q243738 | reload_inasafe_modules | train | def reload_inasafe_modules(module_name=None):
"""Reload python modules.
:param module_name: Specific module name.
:type module_name: str
"""
if not module_name:
module_name = 'safe'
list_modules = list(sys.modules.keys())
for module in list_modules:
if not sys.modules[modul... | python | {
"resource": ""
} |
q243739 | FieldMappingTab.populate_field_list | train | def populate_field_list(self, excluded_fields=None):
"""Helper to add field of the layer to the list.
:param excluded_fields: List of field that want to be excluded.
:type excluded_fields: list
"""
# Populate fields list
if excluded_fields is None:
excluded_f... | python | {
"resource": ""
} |
q243740 | FieldMappingTab.get_parameter_value | train | def get_parameter_value(self):
"""Get parameter of the tab.
:returns: Dictionary of parameters by type in this format:
{'fields': {}, 'values': {}}.
:rtype: dict
"""
parameters = self.parameter_container.get_parameters(True)
field_parameters = {}
valu... | python | {
"resource": ""
} |
q243741 | FieldMappingTab.update_footer | train | def update_footer(self):
"""Update footer when the field list change."""
field_item = self.field_list.currentItem()
if not field_item:
self.footer_label.setText('')
return
field_name = field_item.data(Qt.UserRole)
field = self.layer.fields().field(field_... | python | {
"resource": ""
} |
q243742 | FieldMappingTab.drop_remove | train | def drop_remove(*args, **kwargs):
"""Action when we need to remove dropped item.
:param *args: Position arguments.
:type *args: list
:param kwargs: Keywords arguments.
:type kwargs: dict
"""
dropped_item = args[0]
field_list = kwargs['field_list']
... | python | {
"resource": ""
} |
q243743 | smart_clip | train | def smart_clip(layer_to_clip, mask_layer):
"""Smart clip a vector layer with another.
Issue https://github.com/inasafe/inasafe/issues/3186
:param layer_to_clip: The vector layer to clip.
:type layer_to_clip: QgsVectorLayer
:param mask_layer: The vector layer to use for clipping.
:type mask_la... | python | {
"resource": ""
} |
q243744 | missing_keyword_message | train | def missing_keyword_message(sender, missing_keyword_exception):
"""Display an error when there is missing keyword.
:param sender: The sender.
:type sender: object
:param missing_keyword_exception: A KeywordNotFoundError exception.
:type missing_keyword_exception: KeywordNotFoundError
"""
w... | python | {
"resource": ""
} |
q243745 | conflicting_plugin_message | train | def conflicting_plugin_message():
"""Unfortunately, one plugin is conflicting with InaSAFE.
We are displaying a message about this conflict.
:returns: Information for the user on how to get started.
:rtype: safe.messaging.Message
"""
message = m.Message()
message.add(LOGO_ELEMENT)
mess... | python | {
"resource": ""
} |
q243746 | getting_started_message | train | def getting_started_message():
"""Generate a message for initial application state.
:returns: Information for the user on how to get started.
:rtype: safe.messaging.Message
"""
message = m.Message()
message.add(LOGO_ELEMENT)
message.add(m.Heading(tr('Getting started'), **INFO_STYLE))
no... | python | {
"resource": ""
} |
q243747 | ready_message | train | def ready_message():
"""Helper to create a message indicating inasafe is ready.
:returns Message: A localised message indicating we are ready to run.
"""
title = m.Heading(tr('Ready'), **PROGRESS_UPDATE_STYLE)
notes = m.Paragraph(
tr('You can now proceed to run your analysis by clicking the... | python | {
"resource": ""
} |
q243748 | show_keyword_version_message | train | def show_keyword_version_message(sender, keyword_version, inasafe_version):
"""Show a message indicating that the keywords version is mismatch
.. versionadded: 3.2
:param sender: Sender of the message signal. Default to Any object.
:type sender: object
:param keyword_version: The version of the l... | python | {
"resource": ""
} |
q243749 | show_keywords_need_review_message | train | def show_keywords_need_review_message(sender, message=None):
"""Show a message keywords are not adequate to run an analysis.
.. versionadded: 4.0
:param sender: Sender of the message signal. Default to Any object.
:type sender: object
:param message: Additional message to display.
:type messa... | python | {
"resource": ""
} |
q243750 | generate_input_error_message | train | def generate_input_error_message(header, text):
"""Generate an error message with a header and a text.
:param header: The header of the message.
:type header: basestring
:param text: The text of the message.
:type text: m.Paragraph
:return: The error message ready to be displayed in the dock.... | python | {
"resource": ""
} |
q243751 | enable_messaging | train | def enable_messaging(message_viewer, sender=dispatcher.Any):
"""Set up the dispatcher for messaging.
:param message_viewer: A message viewer to show the message.
:type message_viewer: MessageViewer
:param sender: Sender of the message signal. Default to Any object.
:type sender: object
"""
... | python | {
"resource": ""
} |
q243752 | options_help | train | def options_help():
"""Help message for options dialog.
.. versionadded:: 3.2.1
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())
return me... | python | {
"resource": ""
} |
q243753 | minimum_needs_extractor | train | def minimum_needs_extractor(impact_report, component_metadata):
"""Extracting minimum needs of the impact layer.
:param impact_report: the impact report that acts as a proxy to fetch
all the data that extractor needed
:type impact_report: safe.report.impact_report.ImpactReport
:param component... | python | {
"resource": ""
} |
q243754 | BulletedList.to_text | train | def to_text(self):
"""Render a Text MessageElement as plain text.
:returns: The plain text representation of the Text MessageElement.
:rtype: basestring
"""
if self.items is None:
return
else:
text = ''
for item in self.items:
... | python | {
"resource": ""
} |
q243755 | deep_convert_dict | train | def deep_convert_dict(value):
"""Converts any OrderedDict elements in a value to
ordinary dictionaries, safe for storage in QSettings
:param value: value to convert
:type value: Union[dict,OrderedDict]
:return: dict
"""
to_ret = value
if isinstance(value, OrderedDict):
to_ret =... | python | {
"resource": ""
} |
q243756 | set_general_setting | train | def set_general_setting(key, value, qsettings=None):
"""Set value to QSettings based on key.
:param key: Unique key for setting.
:type key: basestring
:param value: Value to be saved.
:type value: QVariant
:param qsettings: A custom QSettings to use. If it's not defined, it will
use t... | python | {
"resource": ""
} |
q243757 | general_setting | train | def general_setting(key, default=None, expected_type=None, qsettings=None):
"""Helper function to get a value from settings.
:param key: Unique key for setting.
:type key: basestring
:param default: The default value in case of the key is not found or there
is an error.
:type default: base... | python | {
"resource": ""
} |
q243758 | set_setting | train | def set_setting(key, value, qsettings=None):
"""Set value to QSettings based on key in InaSAFE scope.
:param key: Unique key for setting.
:type key: basestring
:param value: Value to be saved.
:type value: QVariant
:param qsettings: A custom QSettings to use. If it's not defined, it will
... | python | {
"resource": ""
} |
q243759 | setting | train | def setting(key, default=None, expected_type=None, qsettings=None):
"""Helper function to get a value from settings under InaSAFE scope.
:param key: Unique key for setting.
:type key: basestring
:param default: The default value in case of the key is not found or there
is an error.
:type d... | python | {
"resource": ""
} |
q243760 | export_setting | train | 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 | {
"resource": ""
} |
q243761 | import_setting | train | 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 | {
"resource": ""
} |
q243762 | OptionsDialog.save_boolean_setting | train | 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 | {
"resource": ""
} |
q243763 | OptionsDialog.restore_boolean_setting | train | 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 | {
"resource": ""
} |
q243764 | OptionsDialog.save_text_setting | train | 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 | {
"resource": ""
} |
q243765 | OptionsDialog.restore_text_setting | train | 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 | {
"resource": ""
} |
q243766 | OptionsDialog.update_earthquake_info | train | 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 | {
"resource": ""
} |
q243767 | OptionsDialog.open_keyword_cache_path | train | 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 | {
"resource": ""
} |
q243768 | OptionsDialog.open_user_directory_path | train | 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 | {
"resource": ""
} |
q243769 | OptionsDialog.open_north_arrow_path | train | 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 | {
"resource": ""
} |
q243770 | OptionsDialog.open_organisation_logo_path | train | 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 | {
"resource": ""
} |
q243771 | OptionsDialog.open_report_template_path | train | 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 | {
"resource": ""
} |
q243772 | OptionsDialog.toggle_logo_path | train | 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 | {
"resource": ""
} |
q243773 | OptionsDialog.update_logo_preview | train | 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 | {
"resource": ""
} |
q243774 | OptionsDialog.set_north_arrow | train | 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 | {
"resource": ""
} |
q243775 | OptionsDialog.set_user_dir | train | 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 | {
"resource": ""
} |
q243776 | OptionsDialog.set_templates_dir | train | 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 | {
"resource": ""
} |
q243777 | OptionsDialog.set_org_disclaimer | train | 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 | {
"resource": ""
} |
q243778 | OptionsDialog.restore_default_values_page | train | 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 | {
"resource": ""
} |
q243779 | OptionsDialog.restore_population_parameters | train | 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 | {
"resource": ""
} |
q243780 | OptionsDialog.age_ratios | train | 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 | {
"resource": ""
} |
q243781 | OptionsDialog.is_good_age_ratios | train | 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 | {
"resource": ""
} |
q243782 | OptionsDialog.save_default_values | train | 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 | {
"resource": ""
} |
q243783 | OptionsDialog.restore_defaults_ratio | train | 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 | {
"resource": ""
} |
q243784 | OptionsDialog.default_field_to_parameter | train | 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 | {
"resource": ""
} |
q243785 | OptionsDialog.set_welcome_message | train | 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 | {
"resource": ""
} |
q243786 | OptionsDialog.show_welcome_dialog | train | 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 | {
"resource": ""
} |
q243787 | OptionsDialog.export_setting | train | 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 | {
"resource": ""
} |
q243788 | OptionsDialog.import_setting | train | 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 | {
"resource": ""
} |
q243789 | specific_notes | train | 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 | {
"resource": ""
} |
q243790 | specific_actions | train | 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 | {
"resource": ""
} |
q243791 | DonutChartContext.data_object | train | 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 | {
"resource": ""
} |
q243792 | DonutChartContext.slices | train | 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 | {
"resource": ""
} |
q243793 | DonutChartContext._arc_slice_context | train | 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 | {
"resource": ""
} |
q243794 | StepFcAggLayerFromCanvas.selected_canvas_agglayer | train | 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 | {
"resource": ""
} |
q243795 | StepFcAggLayerFromCanvas.set_widgets | train | 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 | {
"resource": ""
} |
q243796 | layer_definition_type | train | 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 | {
"resource": ""
} |
q243797 | layer_hazard_classification | train | 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 | {
"resource": ""
} |
q243798 | jinja2_output_as_string | train | 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 | {
"resource": ""
} |
q243799 | value_from_field_name | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.