_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q243200 | create_api_docs | train | def create_api_docs(code_path, api_docs_path, max_depth=2):
"""Function for generating .rst file for all .py file in dir_path folder.
:param code_path: Path of the source code.
:type code_path: str
:param api_docs_path: Path of the api documentation directory.
:type api_docs_path: str
:param ... | python | {
"resource": ""
} |
q243201 | StepKwDefaultInaSAFEFields.get_inasafe_fields | train | def get_inasafe_fields(self):
"""Return inasafe fields from the current wizard state.
:returns: Dictionary of key and value from InaSAFE Fields.
:rtype: dict
"""
inasafe_fields = {}
parameters = self.parameter_container.get_parameters(True)
for parameter in param... | python | {
"resource": ""
} |
q243202 | StepKwDefaultInaSAFEFields.get_inasafe_default_values | train | def get_inasafe_default_values(self):
"""Return inasafe default from the current wizard state.
:returns: Dictionary of key and value from InaSAFE Default Values.
:rtype: dict
"""
inasafe_default_values = {}
parameters = self.parameter_container.get_parameters(True)
... | python | {
"resource": ""
} |
q243203 | function_options_help | train | def function_options_help():
"""Help message for Function 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(conten... | python | {
"resource": ""
} |
q243204 | format_number | train | def format_number(
x, use_rounding=True, is_population=False, coefficient=1):
"""Format a number according to the standards.
:param x: A number to be formatted in a locale friendly way.
:type x: int
:param use_rounding: Flag to enable a rounding.
:type use_rounding: bool
:param is_pop... | python | {
"resource": ""
} |
q243205 | add_separators | train | def add_separators(x):
"""Format integer with separator between thousands.
:param x: A number to be formatted in a locale friendly way.
:type x: int
:returns: A locale friendly formatted string e.g. 1,000,0000.00
representing the original x. If a ValueError exception occurs,
x is simpl... | python | {
"resource": ""
} |
q243206 | round_affected_number | train | def round_affected_number(
number,
use_rounding=False,
use_population_rounding=False):
"""Tries to convert and round the number.
Rounded using population rounding rule.
:param number: number represented as string or float
:type number: str, float
:param use_rounding: flag ... | python | {
"resource": ""
} |
q243207 | rounding_full | train | def rounding_full(number, is_population=False):
"""This function performs a rigorous rounding.
:param number: The amount to round.
:type number: int, float
:param is_population: If we should use the population rounding rule, #4062.
:type is_population: bool
:returns: result and rounding brack... | python | {
"resource": ""
} |
q243208 | convert_unit | train | def convert_unit(number, input_unit, expected_unit):
"""A helper to convert the unit.
:param number: The number to update.
:type number: int
:param input_unit: The unit of the number.
:type input_unit: safe.definitions.units
:param expected_unit: The expected output unit.
:type expected_u... | python | {
"resource": ""
} |
q243209 | coefficient_between_units | train | def coefficient_between_units(unit_a, unit_b):
"""A helper to get the coefficient between two units.
:param unit_a: The first unit.
:type unit_a: safe.definitions.units
:param unit_b: The second unit.
:type unit_b: safe.definitions.units
:return: The coefficient between these two units.
:... | python | {
"resource": ""
} |
q243210 | fatalities_range | train | def fatalities_range(number):
"""A helper to return fatalities as a range of number.
See https://github.com/inasafe/inasafe/issues/3666#issuecomment-283565297
:param number: The exact number. Will be converted as a range.
:type number: int, float
:return: The range of the number.
:rtype: str
... | python | {
"resource": ""
} |
q243211 | html_scientific_notation_rate | train | def html_scientific_notation_rate(rate):
"""Helper for convert decimal rate using scientific notation.
For example we want to show the very detail value of fatality rate
because it might be a very small number.
:param rate: Rate value
:type rate: float
:return: Rate value with html tag to sho... | python | {
"resource": ""
} |
q243212 | denomination | train | def denomination(value, min_nominal=None):
"""Return the denomination of a number.
:param value: The value.
:type value: int
:param min_nominal: Minimum value of denomination eg: 1000, 100.
:type min_nominal: int
:return: The new value and the denomination as a unit definition.
:rtype: tu... | python | {
"resource": ""
} |
q243213 | legend_title_header_element | train | def legend_title_header_element(feature, parent):
"""Retrieve legend title header string from definitions."""
_ = feature, parent # NOQA
header = legend_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243214 | exposure_summary_layer | train | def exposure_summary_layer():
"""Helper method for retrieving exposure summary layer.
If the analysis is multi-exposure, then it will return the exposure
summary layer from place exposure analysis.
"""
project_context_scope = QgsExpressionContextUtils.projectScope(
QgsProject.instance())
... | python | {
"resource": ""
} |
q243215 | distance_to_nearest_place | train | def distance_to_nearest_place(feature, parent):
"""If the impact layer has a distance field, it will return the distance to
the nearest place in metres.
e.g. distance_to_nearest_place() -> 1234
"""
_ = feature, parent # NOQA
layer = exposure_summary_layer()
if not layer:
return No... | python | {
"resource": ""
} |
q243216 | direction_to_nearest_place | train | def direction_to_nearest_place(feature, parent):
"""If the impact layer has a distance field, it will return the direction
to the nearest place.
e.g. direction_to_nearest_place() -> NW
"""
_ = feature, parent # NOQA
layer = exposure_summary_layer()
if not layer:
return None
i... | python | {
"resource": ""
} |
q243217 | bearing_to_nearest_place | train | def bearing_to_nearest_place(feature, parent):
"""If the impact layer has a distance field, it will return the bearing
to the nearest place in degrees.
e.g. bearing_to_nearest_place() -> 280
"""
_ = feature, parent # NOQA
layer = exposure_summary_layer()
if not layer:
return None
... | python | {
"resource": ""
} |
q243218 | name_of_the_nearest_place | train | def name_of_the_nearest_place(feature, parent):
"""If the impact layer has a distance field, it will return the name
of the nearest place.
e.g. name_of_the_nearest_place() -> Tokyo
"""
_ = feature, parent # NOQA
layer = exposure_summary_layer()
if not layer:
return None
index... | python | {
"resource": ""
} |
q243219 | disclaimer_title_header_element | train | def disclaimer_title_header_element(feature, parent):
"""Retrieve disclaimer title header string from definitions."""
_ = feature, parent # NOQA
header = disclaimer_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243220 | information_title_header_element | train | def information_title_header_element(feature, parent):
"""Retrieve information title header string from definitions."""
_ = feature, parent # NOQA
header = information_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243221 | time_title_header_element | train | def time_title_header_element(feature, parent):
"""Retrieve time title header string from definitions."""
_ = feature, parent # NOQA
header = time_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243222 | caution_title_header_element | train | def caution_title_header_element(feature, parent):
"""Retrieve caution title header string from definitions."""
_ = feature, parent # NOQA
header = caution_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243223 | source_title_header_element | train | def source_title_header_element(feature, parent):
"""Retrieve source title header string from definitions."""
_ = feature, parent # NOQA
header = source_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243224 | analysis_title_header_element | train | def analysis_title_header_element(feature, parent):
"""Retrieve analysis title header string from definitions."""
_ = feature, parent # NOQA
header = analysis_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243225 | version_title_header_element | train | def version_title_header_element(feature, parent):
"""Retrieve version title header string from definitions."""
_ = feature, parent # NOQA
header = version_title_header['string_format']
return header.capitalize() | python | {
"resource": ""
} |
q243226 | crs_text_element | train | def crs_text_element(crs, feature, parent):
"""Retrieve coordinate reference system text string from definitions.
Example usage: crs_text_element('EPSG:3857').
"""
_ = feature, parent # NOQA
crs_definition = QgsCoordinateReferenceSystem(crs)
crs_description = crs_definition.description()
t... | python | {
"resource": ""
} |
q243227 | north_arrow_path | train | def north_arrow_path(feature, parent):
"""Retrieve the full path of default north arrow logo."""
_ = feature, parent # NOQA
north_arrow_file = setting(inasafe_north_arrow_path['setting_key'])
if os.path.exists(north_arrow_file):
return north_arrow_file
else:
LOGGER.info(
... | python | {
"resource": ""
} |
q243228 | organisation_logo_path | train | def organisation_logo_path(feature, parent):
"""Retrieve the full path of used specified organisation logo."""
_ = feature, parent # NOQA
organisation_logo_file = setting(
inasafe_organisation_logo_path['setting_key'])
if os.path.exists(organisation_logo_file):
return organisation_logo_... | python | {
"resource": ""
} |
q243229 | multi_buffer_help | train | def multi_buffer_help():
"""Help message for multi buffer dialog.
.. 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())
... | python | {
"resource": ""
} |
q243230 | multiply | train | def multiply(**kwargs):
"""Simple postprocessor where we multiply the input values.
:param kwargs: Dictionary of values to multiply
:type kwargs: dict
:return: The result.
:rtype: float
"""
result = 1
for i in list(kwargs.values()):
if not i:
# If one value is null,... | python | {
"resource": ""
} |
q243231 | calculate_distance | train | def calculate_distance(
distance_calculator,
place_geometry,
latitude,
longitude,
earthquake_hazard=None,
place_exposure=None):
"""Simple postprocessor where we compute the distance between two points.
:param distance_calculator: The size calculator.
:type di... | python | {
"resource": ""
} |
q243232 | calculate_bearing | train | def calculate_bearing(
place_geometry,
latitude,
longitude,
earthquake_hazard=None,
place_exposure=None
):
"""Simple postprocessor where we compute the bearing angle between two
points.
:param place_geometry: Geometry of place.
:type place_geometry: QgsGeometry
... | python | {
"resource": ""
} |
q243233 | calculate_cardinality | train | def calculate_cardinality(
angle,
earthquake_hazard=None,
place_exposure=None
):
"""Simple postprocessor where we compute the cardinality of an angle.
:param angle: Bearing angle.
:type angle: float
:param earthquake_hazard: The hazard to use.
:type earthquake_hazard: str
... | python | {
"resource": ""
} |
q243234 | post_processor_affected_function | train | def post_processor_affected_function(
exposure=None, hazard=None, classification=None, hazard_class=None):
"""Private function used in the affected postprocessor.
It returns a boolean if it's affected or not, or not exposed.
:param exposure: The exposure to use.
:type exposure: str
:param... | python | {
"resource": ""
} |
q243235 | post_processor_population_displacement_function | train | def post_processor_population_displacement_function(
hazard=None, classification=None, hazard_class=None, population=None):
"""Private function used in the displacement postprocessor.
:param hazard: The hazard to use.
:type hazard: str
:param classification: The hazard classification to use.
... | python | {
"resource": ""
} |
q243236 | post_processor_population_fatality_function | train | def post_processor_population_fatality_function(
classification=None, hazard_class=None, population=None):
"""Private function used in the fatality postprocessor.
:param classification: The hazard classification to use.
:type classification: str
:param hazard_class: The hazard class of the fea... | python | {
"resource": ""
} |
q243237 | append_ISO19115_keywords | train | def append_ISO19115_keywords(keywords):
"""Append ISO19115 from setting to keywords.
:param keywords: The keywords destination.
:type keywords: dict
"""
# Map setting's key and metadata key
ISO19115_mapping = {
'ISO19115_ORGANIZATION': 'organisation',
'ISO19115_URL': 'url',
... | python | {
"resource": ""
} |
q243238 | write_iso19115_metadata | train | def write_iso19115_metadata(layer_uri, keywords, version_35=False):
"""Create metadata object from a layer path and keywords dictionary.
This function will save these keywords to the file system or the database.
:param version_35: If we write keywords version 3.5. Default to False.
:type version_35: ... | python | {
"resource": ""
} |
q243239 | read_iso19115_metadata | train | def read_iso19115_metadata(layer_uri, keyword=None, version_35=False):
"""Retrieve keywords from a metadata object
:param layer_uri: Uri to layer.
:type layer_uri: basestring
:param keyword: The key of keyword that want to be read. If None, return
all keywords in dictionary.
:type keyword:... | python | {
"resource": ""
} |
q243240 | active_classification | train | def active_classification(keywords, exposure_key):
"""Helper to retrieve active classification for an exposure.
:param keywords: Hazard layer keywords.
:type keywords: dict
:param exposure_key: The exposure key.
:type exposure_key: str
:returns: The active classification key. None if there is... | python | {
"resource": ""
} |
q243241 | active_thresholds_value_maps | train | def active_thresholds_value_maps(keywords, exposure_key):
"""Helper to retrieve active value maps or thresholds for an exposure.
:param keywords: Hazard layer keywords.
:type keywords: dict
:param exposure_key: The exposure key.
:type exposure_key: str
:returns: Active thresholds or value map... | python | {
"resource": ""
} |
q243242 | copy_layer_keywords | train | def copy_layer_keywords(layer_keywords):
"""Helper to make a deep copy of a layer keywords.
:param layer_keywords: A dictionary of layer's keywords.
:type layer_keywords: dict
:returns: A deep copy of layer keywords.
:rtype: dict
"""
copy_keywords = {}
for key, value in list(layer_keyw... | python | {
"resource": ""
} |
q243243 | StepKwFieldsMapping.set_widgets | train | def set_widgets(self):
"""Set widgets on the Field Mapping step."""
on_the_fly_metadata = {}
layer_purpose = self.parent.step_kw_purpose.selected_purpose()
on_the_fly_metadata['layer_purpose'] = layer_purpose['key']
if layer_purpose != layer_purpose_aggregation:
subca... | python | {
"resource": ""
} |
q243244 | check_inasafe_fields | train | def check_inasafe_fields(layer, keywords_only=False):
"""Helper to check inasafe_fields.
:param layer: The layer to check.
:type layer: QgsVectorLayer
:param keywords_only: If we should check from the keywords only. False by
default, we will check also from the layer.
:type keywords_only: ... | python | {
"resource": ""
} |
q243245 | check_layer | train | def check_layer(layer, has_geometry=True):
"""Helper to check layer validity.
This function wil; raise InvalidLayerError if the layer is invalid.
:param layer: The layer to check.
:type layer: QgsMapLayer
:param has_geometry: If the layer must have a geometry. True by default.
If it's a r... | python | {
"resource": ""
} |
q243246 | default_provenance | train | def default_provenance():
"""The provenance for the default values.
:return: default provenance.
:rtype: str
"""
field = TextParameter()
field.name = tr('Provenance')
field.description = tr('The provenance of minimum needs')
field.value = 'The minimum needs are based on BNPB Perka 7/200... | python | {
"resource": ""
} |
q243247 | PetaBencanaDialog.accept | train | def accept(self):
"""Do PetaBencana download and display it in QGIS.
.. versionadded: 3.3
"""
self.save_state()
try:
self.require_directory()
except CanceledImportDialogError:
return
QgsApplication.instance().setOverrideCursor(
... | python | {
"resource": ""
} |
q243248 | PetaBencanaDialog.add_flooded_field | train | def add_flooded_field(self, shapefile_path):
"""Create the layer from the local shp adding the flooded field.
.. versionadded:: 3.3
Use this method to add a calculated field to a shapefile. The shapefile
should have a field called 'count' containing the number of flood
reports ... | python | {
"resource": ""
} |
q243249 | PetaBencanaDialog.copy_keywords | train | def copy_keywords(self, shapefile_path):
"""Copy keywords from the OSM resource directory to the output path.
.. versionadded: 3.3
In addition to copying the template, tokens within the template will
be replaced with new values for the date token and title token.
:param shapef... | python | {
"resource": ""
} |
q243250 | PetaBencanaDialog.copy_style | train | def copy_style(shapefile_path):
"""Copy style from the OSM resource directory to the output path.
.. versionadded: 3.3
:param shapefile_path: Path to the shapefile that should get the path
added.
:type shapefile_path: basestring
"""
source_qml_path = resourc... | python | {
"resource": ""
} |
q243251 | PetaBencanaDialog.download | train | def download(self, url, output_path):
"""Download file from API url and write to output path.
:param url: URL of the API.
:type url: str
:param output_path: Path of output file,
:type output_path: str
"""
request_failed_message = self.tr(
"Can't acce... | python | {
"resource": ""
} |
q243252 | PetaBencanaDialog.populate_combo_box | train | def populate_combo_box(self):
"""Populate combobox for selecting city."""
if self.radio_button_production.isChecked():
self.source = production_api['url']
available_data = production_api['available_data']
else:
self.source = development_api['url']
... | python | {
"resource": ""
} |
q243253 | PetaBencanaDialog.define_url | train | def define_url(self):
"""Define API url based on which source is selected.
:return: Valid url of selected source.
:rtype: str
"""
current_index = self.city_combo_box.currentIndex()
city_code = self.city_combo_box.itemData(current_index, Qt.UserRole)
source = (sel... | python | {
"resource": ""
} |
q243254 | analysis_provenance_details_simplified_extractor | train | def analysis_provenance_details_simplified_extractor(
impact_report, component_metadata):
"""Extracting simplified version of provenance details of layers.
This extractor will produce provenance details which will be displayed in
the main report.
:param impact_report: the impact report that ac... | python | {
"resource": ""
} |
q243255 | analysis_provenance_details_pdf_extractor | train | def analysis_provenance_details_pdf_extractor(
impact_report, component_metadata):
"""Extracting the main provenance details to its own pdf report.
For PDF generations
:param impact_report: the impact report that acts as a proxy to fetch
all the data that extractor needed
:type impact_... | python | {
"resource": ""
} |
q243256 | headerize | train | def headerize(provenances):
"""Create a header for each keyword.
:param provenances: The keywords.
:type provenances: dict
:return: New keywords with header for every keyword.
:rtype: dict
"""
special_case = {
'Inasafe': 'InaSAFE',
'Qgis': 'QGIS',
'Pyqt': 'PyQt',
... | python | {
"resource": ""
} |
q243257 | resolve_dict_keywords | train | def resolve_dict_keywords(keywords):
"""Replace dictionary content with html.
:param keywords: The keywords.
:type keywords: dict
:return: New keywords with updated content.
:rtype: dict
"""
for keyword in ['value_map', 'inasafe_fields', 'inasafe_default_values']:
value = keywords... | python | {
"resource": ""
} |
q243258 | sorted_keywords_by_order | train | def sorted_keywords_by_order(keywords, order):
"""Sort keywords based on defined order.
:param keywords: Keyword to be sorted.
:type keywords: dict
:param order: Ordered list of key.
:type order: list
:return: Ordered dictionary based on order list.
:rtype: OrderedDict
"""
# we n... | python | {
"resource": ""
} |
q243259 | Plugin.add_action | train | def add_action(self, action, add_to_toolbar=True, add_to_legend=False):
"""Add a toolbar icon to the InaSAFE toolbar.
:param action: The action that should be added to the toolbar.
:type action: QAction
:param add_to_toolbar: Flag indicating whether the action should also
b... | python | {
"resource": ""
} |
q243260 | Plugin._create_keywords_wizard_action | train | def _create_keywords_wizard_action(self):
"""Create action for keywords creation wizard."""
icon = resources_path('img', 'icons', 'show-keyword-wizard.svg')
self.action_keywords_wizard = QAction(
QIcon(icon),
self.tr('Keywords Creation Wizard'),
self.iface.mai... | python | {
"resource": ""
} |
q243261 | Plugin._create_analysis_wizard_action | train | def _create_analysis_wizard_action(self):
"""Create action for IF-centric wizard."""
icon = resources_path('img', 'icons', 'show-wizard.svg')
self.action_function_centric_wizard = QAction(
QIcon(icon),
self.tr('Impact Function Centric Wizard'),
self.iface.main... | python | {
"resource": ""
} |
q243262 | Plugin._create_options_dialog_action | train | def _create_options_dialog_action(self):
"""Create action for options dialog."""
icon = resources_path('img', 'icons', 'configure-inasafe.svg')
self.action_options = QAction(
QIcon(icon),
self.tr('Options'), self.iface.mainWindow())
self.action_options.setStatusTi... | python | {
"resource": ""
} |
q243263 | Plugin._create_minimum_needs_action | train | def _create_minimum_needs_action(self):
"""Create action for minimum needs dialog."""
icon = resources_path('img', 'icons', 'show-minimum-needs.svg')
self.action_minimum_needs = QAction(
QIcon(icon),
self.tr('Minimum Needs Calculator'), self.iface.mainWindow())
se... | python | {
"resource": ""
} |
q243264 | Plugin._create_multi_buffer_action | train | def _create_multi_buffer_action(self):
"""Create action for multi buffer dialog."""
icon = resources_path('img', 'icons', 'show-multi-buffer.svg')
self.action_multi_buffer = QAction(
QIcon(icon),
self.tr('Multi Buffer'), self.iface.mainWindow())
self.action_multi_... | python | {
"resource": ""
} |
q243265 | Plugin._create_minimum_needs_options_action | train | def _create_minimum_needs_options_action(self):
"""Create action for global minimum needs dialog."""
icon = resources_path('img', 'icons', 'show-global-minimum-needs.svg')
self.action_minimum_needs_config = QAction(
QIcon(icon),
self.tr('Minimum Needs Configuration'),
... | python | {
"resource": ""
} |
q243266 | Plugin._create_shakemap_converter_action | train | def _create_shakemap_converter_action(self):
"""Create action for converter dialog."""
icon = resources_path('img', 'icons', 'show-converter-tool.svg')
self.action_shake_converter = QAction(
QIcon(icon),
self.tr('Shakemap Converter'), self.iface.mainWindow())
self... | python | {
"resource": ""
} |
q243267 | Plugin._create_batch_runner_action | train | def _create_batch_runner_action(self):
"""Create action for batch runner dialog."""
icon = resources_path('img', 'icons', 'show-batch-runner.svg')
self.action_batch_runner = QAction(
QIcon(icon),
self.tr('Batch Runner'), self.iface.mainWindow())
self.action_batch_... | python | {
"resource": ""
} |
q243268 | Plugin._create_save_scenario_action | train | def _create_save_scenario_action(self):
"""Create action for save scenario dialog."""
icon = resources_path('img', 'icons', 'save-as-scenario.svg')
self.action_save_scenario = QAction(
QIcon(icon),
self.tr('Save Current Scenario'), self.iface.mainWindow())
message... | python | {
"resource": ""
} |
q243269 | Plugin._create_geonode_uploader_action | train | def _create_geonode_uploader_action(self):
"""Create action for Geonode uploader dialog."""
icon = resources_path('img', 'icons', 'geonode.png')
label = tr('Geonode Uploader')
self.action_geonode = QAction(
QIcon(icon), label, self.iface.mainWindow())
self.action_geon... | python | {
"resource": ""
} |
q243270 | Plugin._create_metadata_converter_action | train | def _create_metadata_converter_action(self):
"""Create action for showing metadata converter dialog."""
icon = resources_path('img', 'icons', 'show-metadata-converter.svg')
self.action_metadata_converter = QAction(
QIcon(icon),
self.tr('InaSAFE Metadata Converter'),
... | python | {
"resource": ""
} |
q243271 | Plugin._create_field_mapping_action | train | def _create_field_mapping_action(self):
"""Create action for showing field mapping dialog."""
icon = resources_path('img', 'icons', 'show-mapping-tool.svg')
self.action_field_mapping = QAction(
QIcon(icon),
self.tr('InaSAFE Field Mapping Tool'),
self.iface.mai... | python | {
"resource": ""
} |
q243272 | Plugin._create_multi_exposure_action | train | def _create_multi_exposure_action(self):
"""Create action for showing the multi exposure tool."""
self.action_multi_exposure = QAction(
QIcon(resources_path('img', 'icons', 'show-multi-exposure.svg')),
self.tr('InaSAFE Multi Exposure Tool'),
self.iface.mainWindow())
... | python | {
"resource": ""
} |
q243273 | Plugin._create_rubber_bands_action | train | def _create_rubber_bands_action(self):
"""Create action for toggling rubber bands."""
icon = resources_path('img', 'icons', 'toggle-rubber-bands.svg')
self.action_toggle_rubberbands = QAction(
QIcon(icon),
self.tr('Toggle Scenario Outlines'), self.iface.mainWindow())
... | python | {
"resource": ""
} |
q243274 | Plugin._create_analysis_extent_action | train | def _create_analysis_extent_action(self):
"""Create action for analysis extent dialog."""
icon = resources_path('img', 'icons', 'set-extents-tool.svg')
self.action_extent_selector = QAction(
QIcon(icon),
self.tr('Set Analysis Area'),
self.iface.mainWindow())
... | python | {
"resource": ""
} |
q243275 | Plugin._create_dock | train | def _create_dock(self):
"""Create dockwidget and tabify it with the legend."""
# Import dock here as it needs to be imported AFTER i18n is set up
from safe.gui.widgets.dock import Dock
self.dock_widget = Dock(self.iface)
self.dock_widget.setObjectName('InaSAFE-Dock')
self... | python | {
"resource": ""
} |
q243276 | Plugin._add_spacer_to_menu | train | def _add_spacer_to_menu(self):
"""Create a spacer to the menu to separate action groups."""
separator = QAction(self.iface.mainWindow())
separator.setSeparator(True)
self.iface.addPluginToMenu(self.tr('InaSAFE'), separator) | python | {
"resource": ""
} |
q243277 | Plugin.clear_modules | train | def clear_modules():
"""Unload inasafe functions and try to return QGIS to before InaSAFE.
.. todo:: I think this function can be removed. TS.
"""
# next lets force remove any inasafe related modules
modules = []
for module in sys.modules:
if 'inasafe' in mod... | python | {
"resource": ""
} |
q243278 | Plugin.toggle_dock_visibility | train | def toggle_dock_visibility(self):
"""Show or hide the dock widget."""
if self.dock_widget.isVisible():
self.dock_widget.setVisible(False)
else:
self.dock_widget.setVisible(True)
self.dock_widget.raise_() | python | {
"resource": ""
} |
q243279 | Plugin.show_extent_selector | train | def show_extent_selector(self):
"""Show the extent selector widget for defining analysis extents."""
# import here only so that it is AFTER i18n set up
from safe.gui.tools.extent_selector_dialog import ExtentSelectorDialog
widget = ExtentSelectorDialog(
self.iface,
... | python | {
"resource": ""
} |
q243280 | Plugin.show_options | train | def show_options(self):
"""Show the options dialog."""
# import here only so that it is AFTER i18n set up
from safe.gui.tools.options_dialog import OptionsDialog
dialog = OptionsDialog(
iface=self.iface,
parent=self.iface.mainWindow())
dialog.show_option_... | python | {
"resource": ""
} |
q243281 | Plugin.show_welcome_message | train | def show_welcome_message(self):
"""Show the welcome message."""
# import here only so that it is AFTER i18n set up
from safe.gui.tools.options_dialog import OptionsDialog
# Do not show by default
show_message = False
previous_version = StrictVersion(setting('previous_ve... | python | {
"resource": ""
} |
q243282 | Plugin.show_keywords_wizard | train | def show_keywords_wizard(self):
"""Show the keywords creation wizard."""
# import here only so that it is AFTER i18n set up
from safe.gui.tools.wizard.wizard_dialog import WizardDialog
if self.iface.activeLayer() is None:
return
# Don't break an existing wizard sess... | python | {
"resource": ""
} |
q243283 | Plugin.show_function_centric_wizard | train | def show_function_centric_wizard(self):
"""Show the function centric wizard."""
# import here only so that it is AFTER i18n set up
from safe.gui.tools.wizard.wizard_dialog import WizardDialog
# Don't break an existing wizard session if accidentally clicked
if self.wizard and sel... | python | {
"resource": ""
} |
q243284 | Plugin.show_shakemap_importer | train | def show_shakemap_importer(self):
"""Show the converter dialog."""
# import here only so that it is AFTER i18n set up
from safe.gui.tools.shake_grid.shakemap_converter_dialog import (
ShakemapConverterDialog)
dialog = ShakemapConverterDialog(
self.iface.mainWindo... | python | {
"resource": ""
} |
q243285 | Plugin.show_multi_buffer | train | def show_multi_buffer(self):
"""Show the multi buffer tool."""
from safe.gui.tools.multi_buffer_dialog import (
MultiBufferDialog)
dialog = MultiBufferDialog(
self.iface.mainWindow(), self.iface, self.dock_widget)
dialog.exec_() | python | {
"resource": ""
} |
q243286 | Plugin.show_osm_downloader | train | def show_osm_downloader(self):
"""Show the OSM buildings downloader dialog."""
from safe.gui.tools.osm_downloader_dialog import OsmDownloaderDialog
dialog = OsmDownloaderDialog(self.iface.mainWindow(), self.iface)
# otherwise dialog is never deleted
dialog.setAttribute(Qt.WA_Del... | python | {
"resource": ""
} |
q243287 | Plugin.show_geonode_uploader | train | def show_geonode_uploader(self):
"""Show the Geonode uploader dialog."""
from safe.gui.tools.geonode_uploader import GeonodeUploaderDialog
dialog = GeonodeUploaderDialog(self.iface.mainWindow())
dialog.show() | python | {
"resource": ""
} |
q243288 | Plugin.add_osm_layer | train | def add_osm_layer(self):
"""Add OSM tile layer to the map.
This uses a gdal wrapper around the OSM tile service - see the
WorldOSM.gdal file for how it is constructed.
"""
path = resources_path('osm', 'WorldOSM.gdal')
layer = QgsRasterLayer(path, self.tr('OpenStreetMap')... | python | {
"resource": ""
} |
q243289 | Plugin.show_field_mapping | train | def show_field_mapping(self):
"""Show InaSAFE Field Mapping."""
from safe.gui.tools.field_mapping_dialog import FieldMappingDialog
dialog = FieldMappingDialog(
parent=self.iface.mainWindow(),
iface=self.iface,)
if dialog.exec_(): # modal
LOGGER.debug(... | python | {
"resource": ""
} |
q243290 | Plugin.show_metadata_converter | train | def show_metadata_converter(self):
"""Show InaSAFE Metadata Converter."""
from safe.gui.tools.metadata_converter_dialog import (
MetadataConverterDialog)
dialog = MetadataConverterDialog(
parent=self.iface.mainWindow(),
iface=self.iface,
)
dial... | python | {
"resource": ""
} |
q243291 | Plugin.show_multi_exposure | train | def show_multi_exposure(self):
"""Show InaSAFE Multi Exposure."""
from safe.gui.tools.multi_exposure_dialog import MultiExposureDialog
dialog = MultiExposureDialog(
self.iface.mainWindow(), self.iface)
dialog.exec_() | python | {
"resource": ""
} |
q243292 | Plugin.add_petabencana_layer | train | def add_petabencana_layer(self):
"""Add petabencana layer to the map.
This uses the PetaBencana API to fetch the latest floods in JK. See
https://data.petabencana.id/floods
"""
from safe.gui.tools.peta_bencana_dialog import PetaBencanaDialog
dialog = PetaBencanaDialog(se... | python | {
"resource": ""
} |
q243293 | Plugin.show_batch_runner | train | def show_batch_runner(self):
"""Show the batch runner dialog."""
from safe.gui.tools.batch.batch_dialog import BatchDialog
dialog = BatchDialog(
parent=self.iface.mainWindow(),
iface=self.iface,
dock=self.dock_widget)
dialog.exec_() | python | {
"resource": ""
} |
q243294 | Plugin.save_scenario | train | def save_scenario(self):
"""Save current scenario to text file."""
from safe.gui.tools.save_scenario import SaveScenarioDialog
dialog = SaveScenarioDialog(
iface=self.iface,
dock=self.dock_widget)
dialog.save_scenario() | python | {
"resource": ""
} |
q243295 | Plugin.layer_changed | train | def layer_changed(self, layer):
"""Enable or disable keywords editor icon when active layer changes.
:param layer: The layer that is now active.
:type layer: QgsMapLayer
"""
if not layer:
enable_keyword_wizard = False
elif not hasattr(layer, 'providerType'):
... | python | {
"resource": ""
} |
q243296 | FieldMappingWidget.populate_tabs | train | def populate_tabs(self):
"""Populating tabs based on layer metadata."""
self.delete_tabs()
layer_purpose = self.metadata.get('layer_purpose')
if not layer_purpose:
message = tr(
'Key layer_purpose is not found in the layer {layer_name}'
).format(la... | python | {
"resource": ""
} |
q243297 | evaluate_formula | train | def evaluate_formula(formula, variables):
"""Very simple formula evaluator. Beware the security.
:param formula: A simple formula.
:type formula: str
:param variables: A collection of variable (key and value).
:type variables: dict
:returns: The result of the formula execution.
:rtype: fl... | python | {
"resource": ""
} |
q243298 | enough_input | train | def enough_input(layer, post_processor_input):
"""Check if the input from impact_fields in enough.
:param layer: The vector layer to use for post processing.
:type layer: QgsVectorLayer
:param post_processor_input: Collection of post processor input
requirements.
:type post_processor_input... | python | {
"resource": ""
} |
q243299 | GroupSelectParameter.set_value_for_key | train | def set_value_for_key(self, key, value):
"""Set the value of key to value.
:param key: The key.
:type key: str
:param value: The value to be assigned.
:type value: list, float, int
"""
if key in self.options:
self.options[key]['value'] = value | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.