_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q243400 | Table.to_html | train | def to_html(self):
"""Render a Table MessageElement as html.
:returns: The html representation of the Table MessageElement
:rtype: basestring
"""
table = '<table%s>\n' % self.html_attributes()
if self.caption is not None:
if isinstance(self.caption, MessageEl... | python | {
"resource": ""
} |
q243401 | Table.to_text | train | def to_text(self):
"""Render a Table MessageElement as plain text.
:returns: The text representation of the Table MessageElement
:rtype: basestring
"""
table = ''
if self.caption is not None:
table += '%s</caption>\n' % self.caption
table += '\n'
... | python | {
"resource": ""
} |
q243402 | extra_keywords_to_widgets | train | def extra_keywords_to_widgets(extra_keyword_definition):
"""Create widgets for extra keyword.
:param extra_keyword_definition: An extra keyword definition.
:type extra_keyword_definition: dict
:return: QCheckBox and The input widget
:rtype: (QCheckBox, QWidget)
"""
# Check box
check_bo... | python | {
"resource": ""
} |
q243403 | StepKwExtraKeywords.set_widgets | train | def set_widgets(self):
"""Set widgets on the extra keywords tab."""
self.clear()
self.description_label.setText(
'In this step you can set some extra keywords for the layer. This '
'keywords can be used for creating richer reporting or map.')
subcategory = self.pa... | python | {
"resource": ""
} |
q243404 | StepKwExtraKeywords.get_extra_keywords | train | def get_extra_keywords(self):
"""Obtain extra keywords from the current state."""
extra_keywords = {}
for key, widgets in list(self.widgets_dict.items()):
if widgets[0].isChecked():
if isinstance(widgets[1], QLineEdit):
extra_keywords[key] = widget... | python | {
"resource": ""
} |
q243405 | StepKwExtraKeywords.set_existing_extra_keywords | train | def set_existing_extra_keywords(self):
"""Set extra keywords from the value from metadata."""
extra_keywords = self.parent.get_existing_keyword('extra_keywords')
for key, widgets in list(self.widgets_dict.items()):
value = extra_keywords.get(key)
if value is None:
... | python | {
"resource": ""
} |
q243406 | create_memory_layer | train | def create_memory_layer(
layer_name, geometry, coordinate_reference_system=None, fields=None):
"""Create a vector memory layer.
:param layer_name: The name of the layer.
:type layer_name: str
:param geometry: The geometry of the layer.
:rtype geometry: QgsWkbTypes (note:
... | python | {
"resource": ""
} |
q243407 | copy_layer | train | def copy_layer(source, target):
"""Copy a vector layer to another one.
:param source: The vector layer to copy.
:type source: QgsVectorLayer
:param target: The destination.
:type source: QgsVectorLayer
"""
out_feature = QgsFeature()
target.startEditing()
request = QgsFeatureReques... | python | {
"resource": ""
} |
q243408 | rename_fields | train | def rename_fields(layer, fields_to_copy):
"""Rename fields inside an attribute table.
Only since QGIS 2.16.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param fields_to_copy: Dictionary of fields to copy.
:type fields_to_copy: dict
"""
for field in fields_to_copy:
... | python | {
"resource": ""
} |
q243409 | copy_fields | train | def copy_fields(layer, fields_to_copy):
"""Copy fields inside an attribute table.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param fields_to_copy: Dictionary of fields to copy.
:type fields_to_copy: dict
"""
for field in fields_to_copy:
index = layer.fields().loo... | python | {
"resource": ""
} |
q243410 | remove_fields | train | def remove_fields(layer, fields_to_remove):
"""Remove fields from a vector layer.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param fields_to_remove: List of fields to remove.
:type fields_to_remove: list
"""
index_to_remove = []
data_provider = layer.dataProvider()
... | python | {
"resource": ""
} |
q243411 | create_spatial_index | train | def create_spatial_index(layer):
"""Helper function to create the spatial index on a vector layer.
This function is mainly used to see the processing time with the decorator.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:return: The index.
:rtype: QgsSpatialIndex
"""
re... | python | {
"resource": ""
} |
q243412 | read_dynamic_inasafe_field | train | def read_dynamic_inasafe_field(inasafe_fields, dynamic_field, black_list=None):
"""Helper to read inasafe_fields using a dynamic field.
:param inasafe_fields: inasafe_fields keywords to use.
:type inasafe_fields: dict
:param dynamic_field: The dynamic field to use.
:type dynamic_field: safe.defini... | python | {
"resource": ""
} |
q243413 | SizeCalculator.measure | train | def measure(self, geometry):
"""Measure the length or the area of a geometry.
:param geometry: The geometry.
:type geometry: QgsGeometry
:return: The geometric size in the expected exposure unit.
:rtype: float
"""
message = 'Size with NaN value : geometry valid=... | python | {
"resource": ""
} |
q243414 | MessageElement._is_qstring | train | def _is_qstring(message):
"""Check if its a QString without adding any dep to PyQt5."""
my_class = str(message.__class__)
my_class_name = my_class.replace('<class \'', '').replace('\'>', '')
if my_class_name == 'PyQt5.QtCore.QString':
return True
return False | python | {
"resource": ""
} |
q243415 | MessageElement.html_attributes | train | def html_attributes(self):
"""Get extra html attributes such as id and class."""
extra_attributes = ''
if self.element_id is not None:
extra_attributes = ' id="%s"' % self.element_id
if self.style_class is not None:
extra_attributes = '%s class="%s"' % (
... | python | {
"resource": ""
} |
q243416 | BoundMethodWeakref.calculateKey | train | def calculateKey( cls, target ):
"""Calculate the reference key for this reference
Currently this is a two-tuple of the id()'s of the
target object and the target function respectively.
"""
return (id(getattr(target,im_self)),id(getattr(target,im_func))) | python | {
"resource": ""
} |
q243417 | WizardStepBrowser.postgis_path_to_uri | train | def postgis_path_to_uri(path):
"""Convert layer path from QgsBrowserModel to full QgsDataSourceUri.
:param path: The layer path from QgsBrowserModel
:type path: string
:returns: layer uri.
:rtype: QgsDataSourceUri
"""
connection_name = path.split('/')[1]
... | python | {
"resource": ""
} |
q243418 | WizardStepBrowser.get_layer_description_from_browser | train | def get_layer_description_from_browser(self, category):
"""Obtain the description of the browser layer selected by user.
:param category: The category of the layer to get the description.
:type category: string
:returns: Tuple of boolean and string. Boolean is true if layer is
... | python | {
"resource": ""
} |
q243419 | reclassify | train | def reclassify(layer, exposure_key=None):
"""Reclassify a continuous vector layer.
This function will modify the input.
For instance if you want to reclassify like this table :
Original Value | Class
- ∞ < val <= 0 | 1
0 < val <= 0.5 | 2
... | python | {
"resource": ""
} |
q243420 | StepKwField.on_lstFields_itemSelectionChanged | train | def on_lstFields_itemSelectionChanged(self):
"""Update field_names description label and unlock the Next button.
.. note:: This is an automatic Qt slot
executed when the field_names selection changes.
"""
self.clear_further_steps()
field_names = self.selected_fields()... | python | {
"resource": ""
} |
q243421 | StepKwField.selected_fields | train | def selected_fields(self):
"""Obtain the fields selected by user.
:returns: Keyword of the selected field.
:rtype: list, str
"""
items = self.lstFields.selectedItems()
if items and self.mode == MULTI_MODE:
return [item.text() for item in items]
elif i... | python | {
"resource": ""
} |
q243422 | ProvenanceStep.dict | train | def dict(self):
"""
the dict representation.
:return: the dict
:rtype: dict
"""
return {
'title': self.title,
'description': self.description,
'time': self.time.isoformat(),
'data': self.data()
} | python | {
"resource": ""
} |
q243423 | ProvenanceStep._get_xml | train | def _get_xml(self, close_tag=True):
"""
generate the xml string representation.
:param close_tag: should the '</provenance_step>' tag be added or not.
:type close_tag: bool
:return: the xml
:rtype: str
"""
provenance_step_element = Element('provenance_s... | python | {
"resource": ""
} |
q243424 | layout_item | train | def layout_item(layout, item_id, item_class):
"""Fetch a specific item according to its type in a layout.
There's some sip casting conversion issues with QgsLayout::itemById.
Don't use it, and use this function instead.
See https://github.com/inasafe/inasafe/issues/4271
:param layout: The layout t... | python | {
"resource": ""
} |
q243425 | jinja2_renderer | train | def jinja2_renderer(impact_report, component):
"""Versatile text renderer using Jinja2 Template.
Render using Jinja2 template.
:param impact_report: ImpactReport contains data about the report that is
going to be generated.
:type impact_report: safe.report.impact_report.ImpactReport
:para... | python | {
"resource": ""
} |
q243426 | create_qgis_pdf_output | train | def create_qgis_pdf_output(
impact_report,
output_path,
layout,
file_format,
metadata):
"""Produce PDF output using QgsLayout.
:param output_path: The output path.
:type output_path: str
:param layout: QGIS Layout object.
:type layout: qgis.core.QgsPrintLayo... | python | {
"resource": ""
} |
q243427 | create_qgis_template_output | train | def create_qgis_template_output(output_path, layout):
"""Produce QGIS Template output.
:param output_path: The output path.
:type output_path: str
:param composition: QGIS Composition object to get template.
values
:type composition: qgis.core.QgsLayout
:return: Generated output path.... | python | {
"resource": ""
} |
q243428 | qt_svg_to_png_renderer | train | def qt_svg_to_png_renderer(impact_report, component):
"""Render SVG into PNG.
:param impact_report: ImpactReport contains data about the report that is
going to be generated.
:type impact_report: safe.report.impact_report.ImpactReport
:param component: Contains the component metadata and conte... | python | {
"resource": ""
} |
q243429 | atlas_renderer | train | def atlas_renderer(layout, coverage_layer, output_path, file_format):
"""Extract composition using atlas generation.
:param layout: QGIS Print Layout object used for producing the report.
:type layout: qgis.core.QgsPrintLayout
:param coverage_layer: Coverage Layer used for atlas map.
:type coverag... | python | {
"resource": ""
} |
q243430 | GeonodeUploaderDialog.reset_defaults | train | def reset_defaults(self):
"""Reset login and password in QgsSettings."""
self.save_login.setChecked(False)
self.save_password.setChecked(False)
self.save_url.setChecked(False)
set_setting(GEONODE_USER, '')
set_setting(GEONODE_PASSWORD, '')
set_setting(GEONODE_URL... | python | {
"resource": ""
} |
q243431 | GeonodeUploaderDialog.fill_layer_combo | train | def fill_layer_combo(self):
"""Fill layer combobox."""
project = QgsProject.instance()
# MapLayers returns a QMap<QString id, QgsMapLayer layer>
layers = list(project.mapLayers().values())
extensions = tuple(extension_siblings.keys())
for layer in layers:
if ... | python | {
"resource": ""
} |
q243432 | GeonodeUploaderDialog.check_ok_button | train | def check_ok_button(self):
"""Helper to enable or not the OK button."""
login = self.login.text()
password = self.password.text()
url = self.url.text()
if self.layers.count() >= 1 and login and password and url:
self.ok_button.setEnabled(True)
else:
... | python | {
"resource": ""
} |
q243433 | GeonodeUploaderDialog.accept | train | def accept(self):
"""Upload the layer to Geonode."""
enable_busy_cursor()
self.button_box.setEnabled(False)
layer = layer_from_combo(self.layers)
login = self.login.text()
if self.save_login.isChecked():
set_setting(GEONODE_USER, login)
else:
... | python | {
"resource": ""
} |
q243434 | update_value_map | train | def update_value_map(layer, exposure_key=None):
"""Assign inasafe values according to definitions for a vector layer.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param exposure_key: The exposure key.
:type exposure_key: str
:return: The classified vector layer.
:rtype: Qg... | python | {
"resource": ""
} |
q243435 | MinimumNeeds.get_minimum_needs | train | def get_minimum_needs(self):
"""Get the minimum needed information about the minimum needs.
That is the resource and the amount.
:returns: minimum needs
:rtype: OrderedDict
"""
minimum_needs = OrderedDict()
for resource in self.minimum_needs['resources']:
... | python | {
"resource": ""
} |
q243436 | MinimumNeeds.set_need | train | def set_need(self, resource, amount, units, frequency='weekly'):
"""Append a single new minimum need entry to the list.
:param resource: Minimum need resource name.
:type resource: basestring
:param amount: Amount per person per time interval
:type amount: int, float
:... | python | {
"resource": ""
} |
q243437 | MinimumNeeds._defaults | train | def _defaults(cls):
"""Helper to get the default minimum needs.
.. note:: Key names will be translated.
"""
minimum_needs = {
"resources": [
{
"Default": "2.8",
"Minimum allowed": "0",
"Maximum allow... | python | {
"resource": ""
} |
q243438 | MinimumNeeds.read_from_file | train | def read_from_file(self, filename):
"""Read from an existing json file.
:param filename: The file to be written to.
:type filename: basestring, str
:returns: Success status. -1 for unsuccessful 0 for success
:rtype: int
"""
if not exists(filename):
r... | python | {
"resource": ""
} |
q243439 | MinimumNeeds.write_to_file | train | def write_to_file(self, filename):
"""Write minimum needs as json to a file.
:param filename: The file to be written to.
:type filename: basestring, str
"""
if not exists(dirname(filename)):
return -1
with open(filename, 'w') as fd:
needs_json = j... | python | {
"resource": ""
} |
q243440 | osm_downloader_help | train | def osm_downloader_help():
"""Help message for OSM Downloader dialog.
.. versionadded:: 3.2.1
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())... | python | {
"resource": ""
} |
q243441 | Provenance.dict | train | def dict(self):
"""
the python object for rendering json.
It is called dict to be
coherent with the other modules but it actually returns a list
:return: the python object for rendering json
:rtype: list
"""
json_list = []
for step in self.steps... | python | {
"resource": ""
} |
q243442 | Provenance.append_step | train | def append_step(self, title, description, timestamp=None, data=None):
"""
Append a new provenance step.
:param title: the title of the ProvenanceStep
:type title: str
:param description: the description of the ProvenanceStep
:type description: str
:param timest... | python | {
"resource": ""
} |
q243443 | Provenance.append_if_provenance_step | train | def append_if_provenance_step(
self, title, description, timestamp=None, data=None):
"""Append a new IF provenance step.
:param title: the title of the IF ProvenanceStep
:type title: str
:param description: the description of the IF ProvenanceStep
:type description:... | python | {
"resource": ""
} |
q243444 | assign_highest_value | train | def assign_highest_value(exposure, hazard):
"""Assign the highest hazard value to an indivisible feature.
For indivisible polygon exposure layers such as buildings, we need to
assigned the greatest hazard that each polygon touches and use that as the
effective hazard class.
Issue https://github.co... | python | {
"resource": ""
} |
q243445 | get_version | train | def get_version():
"""Obtain InaSAFE's version from version file.
:returns: The current version number.
:rtype: str
"""
# Get location of application wide version info
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
version_file = os.path.join(root_dir, 'safe', 'definit... | python | {
"resource": ""
} |
q243446 | StepKwSummary.set_widgets | train | def set_widgets(self):
"""Set widgets on the Keywords Summary tab."""
current_keywords = self.parent.get_keywords()
current_keywords[inasafe_keyword_version_key] = inasafe_keyword_version
header_path = resources_path('header.html')
footer_path = resources_path('footer.html')
... | python | {
"resource": ""
} |
q243447 | DefaultValueParameterWidget.raise_invalid_type_exception | train | def raise_invalid_type_exception(self):
"""Raise invalid type."""
message = 'Expecting element type of %s' % (
self._parameter.element_type.__name__)
err = ValueError(message)
return err | python | {
"resource": ""
} |
q243448 | DefaultValueParameterWidget.set_value | train | def set_value(self, value):
"""Set value by item's string.
:param value: The value.
:type value: str, int
:returns: True if success, else False.
:rtype: bool
"""
# Find index of choice
try:
value_index = self._parameter.options.index(value)
... | python | {
"resource": ""
} |
q243449 | DefaultValueParameterWidget.toggle_custom_value | train | def toggle_custom_value(self):
"""Enable or disable the custom value line edit."""
radio_button_checked_id = self.input_button_group.checkedId()
if (radio_button_checked_id
== len(self._parameter.options) - 1):
self.custom_value.setDisabled(False)
else:
... | python | {
"resource": ""
} |
q243450 | Tree.ended | train | def ended(self):
"""We call this method when the function is finished."""
self._end_time = time.time()
if setting(key='memory_profile', expected_type=bool):
self._end_memory = get_free_memory() | python | {
"resource": ""
} |
q243451 | Tree.elapsed_time | train | def elapsed_time(self):
"""To know the duration of the function.
This property might return None if the function is still running.
"""
if self._end_time:
elapsed_time = round(self._end_time - self._start_time, 3)
return elapsed_time
else:
retu... | python | {
"resource": ""
} |
q243452 | Tree.memory_used | train | def memory_used(self):
"""To know the allocated memory at function termination.
..versionadded:: 4.1
This property might return None if the function is still running.
This function should help to show memory leaks or ram greedy code.
"""
if self._end_memory:
... | python | {
"resource": ""
} |
q243453 | Tree.append | train | def append(self, node):
"""To append a new child."""
if node.parent == self.key and not self.elapsed_time:
self.children.append(node)
else:
# Recursive call
for child in self.children:
if not child.elapsed_time:
child.append... | python | {
"resource": ""
} |
q243454 | get_map_title | train | def get_map_title(hazard, exposure, hazard_category):
"""Helper to get map title.
:param hazard: A hazard definition.
:type hazard: dict
:param exposure: An exposure definition.
:type exposure: dict
:param hazard_category: A hazard category definition.
:type hazard_category: dict
:re... | python | {
"resource": ""
} |
q243455 | get_analysis_question | train | def get_analysis_question(hazard, exposure):
"""Construct analysis question based on hazard and exposure.
:param hazard: A hazard definition.
:type hazard: dict
:param exposure: An exposure definition.
:type exposure: dict
:returns: Analysis question based on reporting standards.
:rtype: ... | python | {
"resource": ""
} |
q243456 | get_multi_exposure_analysis_question | train | def get_multi_exposure_analysis_question(hazard, exposures):
"""Construct analysis question based on hazard and exposures.
:param hazard: A hazard definition.
:type hazard: dict
:param exposure: A list of exposure definition.
:type exposure: list
:returns: Analysis question based on reporting... | python | {
"resource": ""
} |
q243457 | Message.add | train | def add(self, message):
"""Add a MessageElement to the end of the queue.
Strings can be passed and are automatically converted in to
item.Text()
:param message: An element to add to the message queue.
:type message: safe.messaging.Message, MessageElement, str
"""
... | python | {
"resource": ""
} |
q243458 | Message.prepend | train | def prepend(self, message):
"""Prepend a MessageElement to the beginning of the queue.
Strings can be passed and are automatically converted in to
item.Text()
:param message: An element to add to the message queue.
:type message: safe.messaging.Message, MessageElement, str
... | python | {
"resource": ""
} |
q243459 | Message.to_text | train | def to_text(self):
"""Render a MessageElement queue as plain text.
:returns: Plain text representation of the message.
:rtype: str
"""
message = ''
last_was_text = False
for m in self.message:
if last_was_text and not isinstance(m, Text):
... | python | {
"resource": ""
} |
q243460 | Message.to_html | train | def to_html(
self,
suppress_newlines=False,
in_div_flag=False): # pylint: disable=W0221
"""Render a MessageElement as html.
:param suppress_newlines: Whether to suppress any newlines in the
output. If this option is enabled, the entire html output will b... | python | {
"resource": ""
} |
q243461 | validate_sum | train | def validate_sum(parameter_container, validation_message, **kwargs):
"""Validate the sum of parameter value's.
:param parameter_container: The container that use this validator.
:type parameter_container: ParameterContainer
:param validation_message: The message if there is validation error.
:type... | python | {
"resource": ""
} |
q243462 | StepKwLayerMode.on_lstLayerModes_itemSelectionChanged | train | def on_lstLayerModes_itemSelectionChanged(self):
"""Update layer mode description label and unit widgets.
.. note:: This is an automatic Qt slot
executed when the subcategory selection changes.
"""
self.clear_further_steps()
# Set widgets
layer_mode = self.sel... | python | {
"resource": ""
} |
q243463 | NeedsCalculatorDialog.update_button_status | train | def update_button_status(self):
"""Function to enable or disable the Ok button.
"""
# enable/disable ok button
if len(self.displaced.currentField()) > 0:
self.button_box.button(
QtWidgets.QDialogButtonBox.Ok).setEnabled(True)
else:
self.but... | python | {
"resource": ""
} |
q243464 | NeedsCalculatorDialog.minimum_needs | train | def minimum_needs(self, input_layer):
"""Compute minimum needs given a layer and a column containing pop.
:param input_layer: Vector layer assumed to contain
population counts.
:type input_layer: QgsVectorLayer
:returns: A tuple containing True and the vector layer if
... | python | {
"resource": ""
} |
q243465 | NeedsCalculatorDialog.prepare_new_layer | train | def prepare_new_layer(self, input_layer):
"""Prepare new layer for the output layer.
:param input_layer: Vector layer.
:type input_layer: QgsVectorLayer
:return: New memory layer duplicated from input_layer.
:rtype: QgsVectorLayer
"""
# create memory layer
... | python | {
"resource": ""
} |
q243466 | NeedsCalculatorDialog.accept | train | def accept(self):
"""Process the layer and field and generate a new layer.
.. note:: This is called on OK click.
"""
# run minimum needs calculator
try:
success, self.result_layer = (
self.minimum_needs(self.layer.currentLayer()))
if not ... | python | {
"resource": ""
} |
q243467 | StepFcAnalysis.setup_and_run_analysis | train | def setup_and_run_analysis(self):
"""Execute analysis after the tab is displayed.
Please check the code in dock.py accept(). It should follow
approximately the same code.
"""
self.show_busy()
# Read user's settings
self.read_settings()
# Prepare impact fu... | python | {
"resource": ""
} |
q243468 | StepFcAnalysis.set_widgets | train | def set_widgets(self):
"""Set widgets on the Progress tab."""
self.progress_bar.setValue(0)
self.results_webview.setHtml('')
self.pbnReportWeb.hide()
self.pbnReportPDF.hide()
self.pbnReportComposer.hide()
self.lblAnalysisStatus.setText(tr('Running analysis...')) | python | {
"resource": ""
} |
q243469 | StepFcAnalysis.read_settings | train | def read_settings(self):
"""Set the IF state from QSettings."""
extent = setting('user_extent', None, str)
if extent:
extent = QgsGeometry.fromWkt(extent)
if not extent.isGeosValid():
extent = None
crs = setting('user_extent_crs', None, str)
... | python | {
"resource": ""
} |
q243470 | StepFcAnalysis.prepare_impact_function | train | def prepare_impact_function(self):
"""Create analysis as a representation of current situation of IFCW."""
# Impact Functions
impact_function = ImpactFunction()
impact_function.callback = self.progress_callback
# Layers
impact_function.hazard = self.parent.hazard_layer
... | python | {
"resource": ""
} |
q243471 | StepFcAnalysis.setup_gui_analysis_done | train | def setup_gui_analysis_done(self):
"""Helper method to setup gui if analysis is done."""
self.progress_bar.hide()
self.lblAnalysisStatus.setText(tr('Analysis done.'))
self.pbnReportWeb.show()
self.pbnReportPDF.show()
# self.pbnReportComposer.show() # Hide until it works ... | python | {
"resource": ""
} |
q243472 | StepFcAnalysis.show_busy | train | def show_busy(self):
"""Lock buttons and enable the busy cursor."""
self.progress_bar.show()
self.parent.pbnNext.setEnabled(False)
self.parent.pbnBack.setEnabled(False)
self.parent.pbnCancel.setEnabled(False)
self.parent.repaint()
enable_busy_cursor()
QgsA... | python | {
"resource": ""
} |
q243473 | StepFcAnalysis.hide_busy | train | def hide_busy(self):
"""Unlock buttons A helper function to indicate processing is done."""
self.progress_bar.hide()
self.parent.pbnNext.setEnabled(True)
self.parent.pbnBack.setEnabled(True)
self.parent.pbnCancel.setEnabled(True)
self.parent.repaint()
disable_busy... | python | {
"resource": ""
} |
q243474 | StepFcAnalysis.progress_callback | train | def progress_callback(self, current_value, maximum_value, message=None):
"""GUI based callback implementation for showing progress.
:param current_value: Current progress.
:type current_value: int
:param maximum_value: Maximum range (point at which task is complete.
:type maxim... | python | {
"resource": ""
} |
q243475 | swap_pairs | train | def swap_pairs(line, starttag=position_tag):
"""Swap coordinate pairs
Inputs
line: gml line assumed to contain pairs of coordinates ordered as
latitude, longitude
starttag: tag marking the start of the coordinate pairs.
"""
endtag = starttag.replace('<', '</')
index ... | python | {
"resource": ""
} |
q243476 | swap_coords | train | def swap_coords(filename):
"""Swap lat and lon in filename
"""
# Read from input file
fid = open(filename, 'r')
lines = fid.readlines()
fid.close()
# Open output file
basename, ext = os.path.splitext(filename)
fid = open(basename + '_converted' + ext, 'w')
# Report
N = len... | python | {
"resource": ""
} |
q243477 | StepKwClassification.classifications_for_layer | train | def classifications_for_layer(self):
"""Return a list of valid classifications for a layer.
:returns: A list where each value represents a valid classification.
:rtype: list
"""
subcategory_key = self.parent.step_kw_subcategory.\
selected_subcategory()['key']
... | python | {
"resource": ""
} |
q243478 | StepKwClassification.on_lstClassifications_itemSelectionChanged | train | def on_lstClassifications_itemSelectionChanged(self):
"""Update classification description label and unlock the Next button.
.. note:: This is an automatic Qt slot
executed when the field selection changes.
"""
self.clear_further_steps()
classification = self.selected... | python | {
"resource": ""
} |
q243479 | StepKwClassification.selected_classification | train | def selected_classification(self):
"""Obtain the classification selected by user.
:returns: Metadata of the selected classification.
:rtype: dict, None
"""
item = self.lstClassifications.currentItem()
try:
return definition(item.data(QtCore.Qt.UserRole))
... | python | {
"resource": ""
} |
q243480 | StepKwClassification.set_widgets | train | def set_widgets(self):
"""Set widgets on the Classification tab."""
self.clear_further_steps()
purpose = self.parent.step_kw_purpose.selected_purpose()['name']
subcategory = self.parent.step_kw_subcategory.\
selected_subcategory()['name']
self.lstClassifications.clear... | python | {
"resource": ""
} |
q243481 | siblings_files | train | def siblings_files(path):
"""Return a list of sibling files available."""
file_basename, extension = splitext(path)
main_extension = extension.lower()
files = {}
if extension.lower() in list(extension_siblings.keys()):
for text_extension in list(extension_siblings[main_extension].keys()):
... | python | {
"resource": ""
} |
q243482 | pretty_print_post | train | def pretty_print_post(req):
"""Helper to print a "prepared" query. Useful to debug a POST query.
However pay attention at the formatting used in
this function because it is programmed to be pretty
printed and may differ from the actual request.
"""
print(('{}\n{}\n{}\n\n{}'.format(
'---... | python | {
"resource": ""
} |
q243483 | login_user | train | def login_user(server, login, password):
"""Get the login session.
:param server: The Geonode server URL.
:type server: basestring
:param login: The login to use on Geonode.
:type login: basestring
:param password: The password to use on Geonode.
:type password: basestring
"""
log... | python | {
"resource": ""
} |
q243484 | upload | train | def upload(server, session, base_file, charset='UTF-8'):
"""Push a layer to a Geonode instance.
:param server: The Geonode server URL.
:type server: basestring
:param base_file: The base file layer to upload such as a shp, geojson, ...
:type base_file: basestring
:param charset: The encoding ... | python | {
"resource": ""
} |
q243485 | add_logging_handler_once | train | def add_logging_handler_once(logger, handler):
"""A helper to add a handler to a logger, ensuring there are no duplicates.
:param logger: Logger that should have a handler added.
:type logger: logging.logger
:param handler: Handler instance to be added. It will not be added if an
instance of t... | python | {
"resource": ""
} |
q243486 | setup_logger | train | def setup_logger(logger_name, log_file=None, sentry_url=None):
"""Run once when the module is loaded and enable logging.
:param logger_name: The logger name that we want to set up.
:type logger_name: str
:param log_file: Optional full path to a file to write logs to.
:type log_file: str
:para... | python | {
"resource": ""
} |
q243487 | QgsLogHandler.emit | train | def emit(self, record):
"""Try to log the message to QGIS if available, otherwise do nothing.
:param record: logging record containing whatever info needs to be
logged.
"""
try:
# Check logging.LogRecord properties for lots of other goodies
# like... | python | {
"resource": ""
} |
q243488 | initialize_processing | train | def initialize_processing():
"""
Initializes processing, if it's not already been done
"""
need_initialize = False
needed_algorithms = [
'native:clip',
'gdal:cliprasterbyextent',
'native:union',
'native:intersection'
]
if not QgsApplication.processingRegist... | python | {
"resource": ""
} |
q243489 | create_processing_context | train | def create_processing_context(feedback):
"""
Creates a default processing context
:param feedback: Linked processing feedback object
:type feedback: QgsProcessingFeedback
:return: Processing context
:rtype: QgsProcessingContext
"""
context = QgsProcessingContext()
context.setFeedba... | python | {
"resource": ""
} |
q243490 | DataStore.add_layer | train | def add_layer(self, layer, layer_name, save_style=False):
"""Add a layer to the datastore.
:param layer: The layer to add.
:type layer: QgsMapLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
:param save_style: If we have to save a ... | python | {
"resource": ""
} |
q243491 | DataStore.layer | train | def layer(self, layer_name):
"""Get QGIS layer.
:param layer_name: The name of the layer to fetch.
:type layer_name: str
:return: The QGIS layer.
:rtype: QgsMapLayer
.. versionadded:: 4.0
"""
uri = self.layer_uri(layer_name)
layer = QgsVectorLay... | python | {
"resource": ""
} |
q243492 | DataStore.layer_keyword | train | def layer_keyword(self, keyword, value):
"""Get a layer according to a keyword and its value.
:param keyword: The keyword to check.
:type keyword: basestring
:param value: The value to check for the specific keyword.
:type value: basestring
:return: The QGIS layer.
... | python | {
"resource": ""
} |
q243493 | purposes_for_layer | train | def purposes_for_layer(layer_geometry_key):
"""Get purposes of a layer geometry id.
:param layer_geometry_key: The geometry id
:type layer_geometry_key: str
:returns: List of suitable layer purpose.
:rtype: list
"""
return_value = []
for layer_purpose in layer_purposes:
layer_g... | python | {
"resource": ""
} |
q243494 | hazards_for_layer | train | def hazards_for_layer(layer_geometry_key):
"""Get hazard categories form layer_geometry_key.
:param layer_geometry_key: The geometry id
:type layer_geometry_key: str
:returns: List of hazard
:rtype: list
"""
result = []
for hazard in hazard_all:
if layer_geometry_key in hazard.... | python | {
"resource": ""
} |
q243495 | exposures_for_layer | train | def exposures_for_layer(layer_geometry_key):
"""Get hazard categories form layer_geometry_key
:param layer_geometry_key: The geometry key
:type layer_geometry_key: str
:returns: List of hazard
:rtype: list
"""
result = []
for exposure in exposure_all:
if layer_geometry_key in e... | python | {
"resource": ""
} |
q243496 | get_layer_modes | train | def get_layer_modes(subcategory):
"""Return all sorted layer modes from exposure or hazard.
:param subcategory: Hazard or Exposure key.
:type subcategory: str
:returns: List of layer modes definition.
:rtype: list
"""
layer_modes = definition(subcategory)['layer_modes']
return sorted(l... | python | {
"resource": ""
} |
q243497 | hazard_units | train | def hazard_units(hazard):
"""Helper to get unit of a hazard.
:param hazard: Hazard type.
:type hazard: str
:returns: List of hazard units.
:rtype: list
"""
units = definition(hazard)['continuous_hazard_units']
return sorted(units, key=lambda k: k['key']) | python | {
"resource": ""
} |
q243498 | exposure_units | train | def exposure_units(exposure):
"""Helper to get unit of an exposure.
:param exposure: Exposure type.
:type exposure: str
:returns: List of exposure units.
:rtype: list
"""
units = definition(exposure)['units']
return sorted(units, key=lambda k: k['key']) | python | {
"resource": ""
} |
q243499 | get_classifications | train | def get_classifications(subcategory_key):
"""Get hazard or exposure classifications.
:param subcategory_key: The hazard or exposure key
:type subcategory_key: str
:returns: List of hazard or exposure classifications
:rtype: list
"""
classifications = definition(subcategory_key)['classifica... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.