_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q243300
StepKwUnit.on_lstUnits_itemSelectionChanged
train
def on_lstUnits_itemSelectionChanged(self): """Update unit description label and field widgets. .. note:: This is an automatic Qt slot executed when the unit selection changes. """ self.clear_further_steps() # Set widgets unit = self.selected_unit() # ...
python
{ "resource": "" }
q243301
StepKwUnit.selected_unit
train
def selected_unit(self): """Obtain the unit selected by user. :returns: Metadata of the selected unit. :rtype: dict, None """ item = self.lstUnits.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) except (AttributeError, NameError): ...
python
{ "resource": "" }
q243302
StepKwUnit.set_widgets
train
def set_widgets(self): """Set widgets on the Unit tab.""" self.clear_further_steps() # Set widgets purpose = self.parent.step_kw_purpose.selected_purpose() subcategory = self.parent.step_kw_subcategory.selected_subcategory() self.lblSelectUnit.setText( unit_qu...
python
{ "resource": "" }
q243303
get_report_section
train
def get_report_section( html_report, component_id, container_wrapper_format=container_format): """Get specific report section from InaSAFE analysis summary report. :param html_report: The html report. :type html_report: basestring :param component_id: The component key. :type component_id:...
python
{ "resource": "" }
q243304
analysis_summary_report
train
def analysis_summary_report(feature, parent): """Retrieve an HTML table report of current selected analysis. """ _ = feature, parent # NOQA project_context_scope = QgsExpressionContextUtils.projectScope( QgsProject.instance()) key = provenance_layer_analysis_impacted['provenance_key'] i...
python
{ "resource": "" }
q243305
analysis_question_report
train
def analysis_question_report(feature, parent): """Retrieve the analysis question section from InaSAFE report. """ _ = feature, parent # NOQA project_context_scope = QgsExpressionContextUtils.projectScope() key = provenance_layer_analysis_impacted['provenance_key'] if not project_context_scope.h...
python
{ "resource": "" }
q243306
population_analysis_summary_report
train
def population_analysis_summary_report(feature, parent): """Retrieve an HTML population analysis table report from a multi exposure analysis. """ _ = feature, parent # NOQA analysis_dir = get_analysis_dir(exposure_population['key']) if analysis_dir: return get_impact_report_as_string(an...
python
{ "resource": "" }
q243307
road_analysis_summary_report
train
def road_analysis_summary_report(feature, parent): """Retrieve an HTML road analysis table report from a multi exposure analysis. """ _ = feature, parent # NOQA analysis_dir = get_analysis_dir(exposure_road['key']) if analysis_dir: return get_impact_report_as_string(analysis_dir) re...
python
{ "resource": "" }
q243308
structure_analysis_summary_report
train
def structure_analysis_summary_report(feature, parent): """Retrieve an HTML structure analysis table report from a multi exposure analysis. """ _ = feature, parent # NOQA analysis_dir = get_analysis_dir(exposure_structure['key']) if analysis_dir: return get_impact_report_as_string(analy...
python
{ "resource": "" }
q243309
place_analysis_summary_report
train
def place_analysis_summary_report(feature, parent): """Retrieve an HTML place analysis table report from a multi exposure analysis. """ _ = feature, parent # NOQA analysis_dir = get_analysis_dir(exposure_place['key']) if analysis_dir: return get_impact_report_as_string(analysis_dir) ...
python
{ "resource": "" }
q243310
land_cover_analysis_summary_report
train
def land_cover_analysis_summary_report(feature, parent): """Retrieve an HTML land cover analysis table report from a multi exposure analysis. """ _ = feature, parent # NOQA analysis_dir = get_analysis_dir(exposure_land_cover['key']) if analysis_dir: return get_impact_report_as_string(an...
python
{ "resource": "" }
q243311
multi_exposure_analysis_summary_report
train
def multi_exposure_analysis_summary_report(feature, parent): """Retrieve an HTML multi exposure analysis table report. """ _ = feature, parent # NOQA analysis_dir = get_analysis_dir() if analysis_dir: return get_impact_report_as_string(analysis_dir) return None
python
{ "resource": "" }
q243312
WizardHelp.show_help
train
def show_help(self, wizard_step): """Set wizard step and show the help text.""" self.wizard_step = wizard_step header = html_header() footer = html_footer() content = header message = self.wizard_step.help() content += message.to_html() content += foot...
python
{ "resource": "" }
q243313
WizardHelp.restore_button_state
train
def restore_button_state(self): """Helper to restore button state.""" self.parent.pbnNext.setEnabled(self.next_button_state) self.parent.pbnBack.setEnabled(self.back_button_state)
python
{ "resource": "" }
q243314
html_footer
train
def html_footer(): """Get a standard html footer for wrapping content in. :returns: A header containing a web page closing content in html - up to and including the body close tag. :rtype: str """ file_path = resources_path('footer.html') with open(file_path) as header_file: con...
python
{ "resource": "" }
q243315
html_header
train
def html_header(): """Get a standard html header for wrapping content in. :returns: A header containing a web page preamble in html - up to and including the body open tag. :rtype: str """ file_path = resources_path('header.html') with codecs.open(file_path, 'r', encoding='utf8') as he...
python
{ "resource": "" }
q243316
resources_path
train
def resources_path(*args): """Get the path to our resources folder. .. versionadded:: 3.0 Note that in version 3.0 we removed the use of Qt Resource files in favour of directly accessing on-disk resources. :param args List of path elements e.g. ['img', 'logos', 'image.png'] :type args: str ...
python
{ "resource": "" }
q243317
resource_url
train
def resource_url(path): """Get the a local filesystem url to a given resource. .. versionadded:: 3.0 Note that in version 3.0 we removed the use of Qt Resource files in favour of directly accessing on-disk resources. :param path: Path to resource e.g. /home/timlinux/foo/bar.png :type path: st...
python
{ "resource": "" }
q243318
get_ui_class
train
def get_ui_class(ui_file): """Get UI Python class from .ui file. Can be filename.ui or subdirectory/filename.ui :param ui_file: The file of the ui in safe.gui.ui :type ui_file: str """ os.path.sep.join(ui_file.split('/')) ui_file_path = os.path.abspath( os.path.join( ...
python
{ "resource": "" }
q243319
StepKwSource.set_widgets
train
def set_widgets(self): """Set widgets on the Source tab.""" # Just set values based on existing keywords source = self.parent.get_existing_keyword('source') if source or source == 0: self.leSource.setText(source) else: self.leSource.clear() source...
python
{ "resource": "" }
q243320
welcome_message
train
def welcome_message(): """Welcome message for first running users. .. versionadded:: 4.3.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": "" }
q243321
read_scenarios
train
def read_scenarios(filename): """Read keywords dictionary from file. :param filename: Name of file holding scenarios . :return Dictionary of with structure like this {{ 'foo' : { 'a': 'b', 'c': 'd'}, { 'bar' : { 'd': 'e', 'f': 'g'}} A scenarios file may look like this: [j...
python
{ "resource": "" }
q243322
validate_scenario
train
def validate_scenario(blocks, scenario_directory): """Function to validate input layer stored in scenario file. Check whether the files that are used in scenario file need to be updated or not. :param blocks: dictionary from read_scenarios :type blocks: dictionary :param scenario_directory: d...
python
{ "resource": "" }
q243323
append_row
train
def append_row(table, label, data): """Append new row to table widget. :param table: The table that shall have the row added to it. :type table: QTableWidget :param label: Label for the row. :type label: str :param data: custom data associated with label value. :type data: str """ ...
python
{ "resource": "" }
q243324
BatchDialog.restore_state
train
def restore_state(self): """Restore GUI state from configuration file.""" # restore last source path last_source_path = setting( 'lastSourceDir', self.default_directory, expected_type=str) self.source_directory.setText(last_source_path) # restore path pdf output ...
python
{ "resource": "" }
q243325
BatchDialog.save_state
train
def save_state(self): """Save current state of GUI to configuration file.""" set_setting('lastSourceDir', self.source_directory.text()) set_setting('lastOutputDir', self.output_directory.text()) set_setting( 'useDefaultOutputDir', self.scenario_directory_radio.isChecked())
python
{ "resource": "" }
q243326
BatchDialog.choose_directory
train
def choose_directory(self, line_edit, title): """ Show a directory selection dialog. This function will show the dialog then set line_edit widget text with output from the dialog. :param line_edit: Widget whose text should be updated. :type line_edit: QLineEdit :param t...
python
{ "resource": "" }
q243327
BatchDialog.populate_table
train
def populate_table(self, scenario_directory): """ Populate table with files from scenario_directory directory. :param scenario_directory: Path where .txt & .py reside. :type scenario_directory: QString """ parsed_files = [] unparsed_files = [] self.table.clearCon...
python
{ "resource": "" }
q243328
BatchDialog.run_script
train
def run_script(self, filename): """ Run a python script in QGIS to exercise InaSAFE functionality. This functionality was originally intended for verifying that the key elements are InaSAFE are loading correctly and available. However, the utility of this function is such that you can r...
python
{ "resource": "" }
q243329
BatchDialog.reset_status
train
def reset_status(self): """Set all scenarios' status to empty in the table.""" for row in range(self.table.rowCount()): status_item = self.table.item(row, 1) status_item.setText(self.tr(''))
python
{ "resource": "" }
q243330
BatchDialog.prepare_task
train
def prepare_task(self, items): """Prepare scenario for impact function variable. :param items: Dictionary containing settings for impact function. :type items: Python dictionary. :return: A tuple containing True and dictionary containing parameters if post processor su...
python
{ "resource": "" }
q243331
BatchDialog.set_layer_visible
train
def set_layer_visible(layer, visible): """Sets a layer in the project visible or not :param layer: layer to change :type layer: QgsMapLayer :param visible: True to show layer, False to hide layer :type visible: bool """ if layer is None: return ...
python
{ "resource": "" }
q243332
BatchDialog.run_selected_clicked
train
def run_selected_clicked(self): """Run the selected scenario.""" # get all selected rows rows = sorted(set(index.row() for index in self.table.selectedIndexes())) self.enable_busy_cursor() # iterate over selected rows for row in rows: ...
python
{ "resource": "" }
q243333
BatchDialog.run_all_clicked
train
def run_all_clicked(self): """Run all scenario when pbRunAll is clicked.""" self.reset_status() self.enable_busy_cursor() report = [] fail_count = 0 pass_count = 0 index = 0 for row in range(self.table.rowCount()): item = self.table.item(row,...
python
{ "resource": "" }
q243334
BatchDialog.write_report
train
def write_report(self, report, pass_count, fail_count): """Write a report status of Batch Runner. For convenience, the name will use current time. :param report: A list of each scenario and its status. :type report: list :param pass_count: Number of passing scenarios. ...
python
{ "resource": "" }
q243335
BatchDialog.generate_pdf_report
train
def generate_pdf_report(self, impact_function, iface, scenario_name): """Generate and store map and impact report from impact function. Directory where the report stored is specified by user input from the dialog. This function is adapted from analysis_utilities.py :param impact_functi...
python
{ "resource": "" }
q243336
BatchDialog.show_report
train
def show_report(self, report_path): """Show batch report file in batchReportFileName using an external app. This method uses QDesktop services to display the report (typically using gedit or similar text editor). :param report_path: Path to the file of batch report. :type repor...
python
{ "resource": "" }
q243337
BatchDialog.update_default_output_dir
train
def update_default_output_dir(self): """Update output dir if set to default.""" if self.scenario_directory_radio.isChecked(): self.output_directory.setText(self.source_directory.text())
python
{ "resource": "" }
q243338
BatchDialog.enable_busy_cursor
train
def enable_busy_cursor(self): """Set the hourglass enabled.""" QgsApplication.instance().setOverrideCursor( QtGui.QCursor(QtCore.Qt.WaitCursor) )
python
{ "resource": "" }
q243339
BatchDialog.on_scenario_directory_radio_toggled
train
def on_scenario_directory_radio_toggled(self, flag): """Autoconnect slot activated when scenario_directory_radio is checked. :param flag: Flag indicating whether the checkbox was toggled on or off. :type flag: bool """ if flag: self.output_directory.setTe...
python
{ "resource": "" }
q243340
BatchDialog.on_source_directory_chooser_clicked
train
def on_source_directory_chooser_clicked(self): """Autoconnect slot activated when tbSourceDir is clicked.""" title = self.tr('Set the source directory for script and scenario') self.choose_directory(self.source_directory, title)
python
{ "resource": "" }
q243341
BatchDialog.on_output_directory_chooser_clicked
train
def on_output_directory_chooser_clicked(self): """Auto connect slot activated when tbOutputDiris clicked.""" title = self.tr('Set the output directory for pdf report files') self.choose_directory(self.output_directory, title)
python
{ "resource": "" }
q243342
Cell.to_html
train
def to_html(self): """Render a Cell MessageElement as html :returns: The html representation of the Cell MessageElement :rtype: basestring """ # Apply bootstrap alignment classes first if self.align is 'left': if self.style_class is None: self...
python
{ "resource": "" }
q243343
error_creator5
train
def error_creator5(): """Raise a safe style error and append a full message.""" try: error_creator4() except SafeError as e4: message = ErrorMessage( 'Creator 5 problem', detail=Message( Paragraph('Could not', ImportantText('call'), 'function.'), ...
python
{ "resource": "" }
q243344
qgis_composer_infographic_extractor
train
def qgis_composer_infographic_extractor(impact_report, component_metadata): """Extract composer context specific for infographic template. This method extract necessary context for a given impact report and component metadata and save the context so it can be used in composer rendering phase :para...
python
{ "resource": "" }
q243345
StepKwInaSAFEFields.inasafe_fields_for_the_layer
train
def inasafe_fields_for_the_layer(self): """Return a list of inasafe fields the current layer. :returns: A list where each value represents inasafe field. :rtype: list """ if (self.parent.get_layer_geometry_key() == layer_geometry_raster['key']): retur...
python
{ "resource": "" }
q243346
__if_not_basestring
train
def __if_not_basestring(text_object): """Convert to str""" converted_str = text_object if not isinstance(text_object, str): converted_str = str(text_object) return converted_str
python
{ "resource": "" }
q243347
get_string
train
def get_string(input_text, encoding='utf-8'): """Get byte string representation of an object. :param input_text: The input text. :type input_text: unicode, str, float, int :param encoding: The encoding used to do the conversion, default to utf-8. :type encoding: str :returns: Byte string rep...
python
{ "resource": "" }
q243348
byteify
train
def byteify(input_object): """Recursive function to transform an object to byte. :param input_object: A python object such as unicode, dictionary or list. :type: unicode, list, dict :return: The object with byte only. """ if isinstance(input_object, dict): return {byteify(key): byteify...
python
{ "resource": "" }
q243349
ImpactLayerMetadata.dict
train
def dict(self): """ calls the overridden method and adds provenance and summary data :return: dictionary representation of the metadata :rtype: dict """ metadata = super(ImpactLayerMetadata, self).dict metadata['provenance'] = self.provenance metadata['s...
python
{ "resource": "" }
q243350
ImpactLayerMetadata._read_provenance_from_xml
train
def _read_provenance_from_xml(self, root): """ read metadata provenance from xml. :param root: container in which we search :type root: ElementTree.Element """ path = self._special_properties['provenance'] provenance = root.find(path, XML_NS) for step in ...
python
{ "resource": "" }
q243351
ImpactLayerMetadata.append_provenance_step
train
def append_provenance_step(self, title, description, timestamp=None): """ Add a step to the provenance of the metadata :param title: The title of the step. :type title: str :param description: The content of the step :type description: str :param timestamp: the...
python
{ "resource": "" }
q243352
ImpactLayerMetadata.append_if_provenance_step
train
def append_if_provenance_step( self, title, description, timestamp=None, data=None): """Add a if provenance step to the provenance of the metadata :param title: The title of the step. :type title: str :param description: The content of the step :type description: st...
python
{ "resource": "" }
q243353
ImpactLayerMetadata.update_from_dict
train
def update_from_dict(self, keywords): """Update metadata value from a keywords dictionary. :param keywords: :return: """ super(ImpactLayerMetadata, self).update_from_dict(keywords) if 'if_provenance' in list(keywords.keys()): if_provenance = keywords['if_pro...
python
{ "resource": "" }
q243354
GroupSelectParameterWidget.update_list_widget
train
def update_list_widget(self): """Update list widget when radio button is clicked.""" # Get selected radio button radio_button_checked_id = self.input_button_group.checkedId() # No radio button checked, then default value = None if radio_button_checked_id > -1: selecte...
python
{ "resource": "" }
q243355
GroupSelectParameterWidget.radio_buttons_clicked
train
def radio_buttons_clicked(self): """Handler when selected radio button changed.""" # Disable all spin boxes for spin_box in list(self.spin_boxes.values()): spin_box.setEnabled(False) # Disable list widget self.list_widget.setEnabled(False) # Get selected radi...
python
{ "resource": "" }
q243356
GroupSelectParameterWidget.select_radio_button
train
def select_radio_button(self, key): """Helper to select a radio button with key. :param key: The key of the radio button. :type key: str """ key_index = list(self._parameter.options.keys()).index(key) radio_button = self.input_button_group.button(key_index) radio...
python
{ "resource": "" }
q243357
Brand.to_html
train
def to_html(self): """Render as html. """ uri = resource_url( resources_path('img', 'logos', 'inasafe-logo-white.png')) snippet = ( '<div class="branding">' '<img src="%s" title="%s" alt="%s" %s/></div>') % ( uri, 'InaSA...
python
{ "resource": "" }
q243358
mmi_detail_extractor
train
def mmi_detail_extractor(impact_report, component_metadata): """Extracting MMI-related analysis result. This extractor should only be used for EQ Raster with Population. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report...
python
{ "resource": "" }
q243359
inasafe_field_header
train
def inasafe_field_header(field, feature, parent): """Retrieve a header name of the field name from definitions. For instance: inasafe_field_header('minimum_needs__clean_water') -> 'Clean water' """ _ = feature, parent # NOQA age_fields = [under_5_displaced_count_field, over_60_displaced_count_...
python
{ "resource": "" }
q243360
minimum_needs_unit
train
def minimum_needs_unit(field, feature, parent): """Retrieve units of the given minimum needs field name. For instance: * minimum_needs_unit('minimum_needs__clean_water') -> 'l/weekly' """ _ = feature, parent # NOQA field_definition = definition(field, 'field_name') if field_definition: ...
python
{ "resource": "" }
q243361
infographic_header_element
train
def infographic_header_element(impact_function_name, feature, parent): """Get a formatted infographic header sentence for an impact function. For instance: * infographic_header_element('flood') -> 'Estimated impact of a flood' """ _ = feature, parent # NOQA string_format = infographic_header['...
python
{ "resource": "" }
q243362
map_overview_header_element
train
def map_overview_header_element(feature, parent): """Retrieve map overview header string from definitions.""" _ = feature, parent # NOQA header = map_overview_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243363
population_chart_header_element
train
def population_chart_header_element(feature, parent): """Retrieve population chart header string from definitions.""" _ = feature, parent # NOQA header = population_chart_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243364
people_section_header_element
train
def people_section_header_element(feature, parent): """Retrieve people section header string from definitions.""" _ = feature, parent # NOQA header = people_section_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243365
age_gender_section_header_element
train
def age_gender_section_header_element(feature, parent): """Retrieve age gender section header string from definitions.""" _ = feature, parent # NOQA header = age_gender_section_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243366
vulnerability_section_header_element
train
def vulnerability_section_header_element(feature, parent): """Retrieve vulnerability section header string from definitions.""" _ = feature, parent # NOQA header = vulnerability_section_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243367
female_vulnerability_section_header_element
train
def female_vulnerability_section_header_element(feature, parent): """Retrieve female vulnerability section header string from definitions.""" _ = feature, parent # NOQA header = female_vulnerability_section_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243368
minimum_needs_section_header_element
train
def minimum_needs_section_header_element(feature, parent): """Retrieve minimum needs section header string from definitions.""" _ = feature, parent # NOQA header = minimum_needs_section_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243369
additional_minimum_needs_section_header_element
train
def additional_minimum_needs_section_header_element(feature, parent): """Retrieve additional minimum needs section header string from definitions. """ _ = feature, parent # NOQA header = additional_minimum_needs_section_header['string_format'] return header.capitalize()
python
{ "resource": "" }
q243370
ResourceParameter.serialize
train
def serialize(self): """Convert the parameter into a dictionary. :return: The parameter dictionary. :rtype: dict """ pickle = super(ResourceParameter, self).serialize() pickle['frequency'] = self.frequency pickle['unit'] = self._unit.serialize() return pi...
python
{ "resource": "" }
q243371
NeedsManagerDialog.reject
train
def reject(self): """Overload the base dialog reject event so we can handle state change. If the user is in resource editing mode, clicking close button, window [x] or pressing escape should switch context back to the profile view, not close the whole window. See https://github...
python
{ "resource": "" }
q243372
NeedsManagerDialog.populate_resource_list
train
def populate_resource_list(self): """Populate the list resource list. """ minimum_needs = self.minimum_needs.get_full_needs() for full_resource in minimum_needs["resources"]: self.add_resource(full_resource) self.provenance.setText(minimum_needs["provenance"])
python
{ "resource": "" }
q243373
NeedsManagerDialog.add_resource
train
def add_resource(self, resource): """Add a resource to the minimum needs table. :param resource: The resource to be added :type resource: dict """ updated_sentence = NeedsProfile.format_sentence( resource['Readable sentence'], resource) if self.edit_item: ...
python
{ "resource": "" }
q243374
NeedsManagerDialog.restore_defaults
train
def restore_defaults(self): """Restore defaults profiles.""" title = tr('Restore defaults') msg = tr( 'Restoring defaults will overwrite your changes on profiles ' 'provided by InaSAFE. Do you want to continue ?') # noinspection PyCallByClass reply = QMess...
python
{ "resource": "" }
q243375
NeedsManagerDialog.load_profiles
train
def load_profiles(self, overwrite=False): """Load the profiles into the dropdown list. :param overwrite: If we overwrite existing profiles from the plugin. :type overwrite: bool """ for profile in self.minimum_needs.get_profiles(overwrite): self.profile_combo.addItem...
python
{ "resource": "" }
q243376
NeedsManagerDialog.select_profile
train
def select_profile(self, index): """Select a given profile by index. Slot for when profile is selected. :param index: The selected item's index :type index: int """ new_profile = self.profile_combo.itemText(index) self.resources_list.clear() self.minimum...
python
{ "resource": "" }
q243377
NeedsManagerDialog.mark_current_profile_as_pending
train
def mark_current_profile_as_pending(self): """Mark the current profile as pending by colouring the text red. """ index = self.profile_combo.currentIndex() item = self.profile_combo.model().item(index) item.setForeground(QtGui.QColor('red'))
python
{ "resource": "" }
q243378
NeedsManagerDialog.add_new_resource
train
def add_new_resource(self): """Handle add new resource requests. """ parameters_widget = [ self.parameters_scrollarea.layout().itemAt(i) for i in range(self.parameters_scrollarea.layout().count())][0].widget() parameter_widgets = [ parameters_widget.ve...
python
{ "resource": "" }
q243379
NeedsManagerDialog.edit_resource
train
def edit_resource(self): """Handle edit resource requests. """ self.mark_current_profile_as_pending() resource = None for item in self.resources_list.selectedItems()[:1]: resource = item.resource_full self.edit_item = item if not resource: ...
python
{ "resource": "" }
q243380
NeedsManagerDialog.remove_resource
train
def remove_resource(self): """Remove the currently selected resource. """ self.mark_current_profile_as_pending() for item in self.resources_list.selectedItems(): self.resources_list.takeItem(self.resources_list.row(item))
python
{ "resource": "" }
q243381
NeedsManagerDialog.import_profile
train
def import_profile(self): """ Import minimum needs from an existing json file. The minimum needs are loaded from a file into the table. This state is only saved if the form is accepted. """ # noinspection PyCallByClass,PyTypeChecker file_name_dialog = QFileDialog(self) ...
python
{ "resource": "" }
q243382
NeedsManagerDialog.export_profile
train
def export_profile(self): """ Export minimum needs to a json file. This method will save the current state of the minimum needs setup. Then open a dialog allowing the user to browse to the desired destination location and allow the user to save the needs as a json file. ...
python
{ "resource": "" }
q243383
NeedsManagerDialog.save_profile
train
def save_profile(self): """ Save the current state of the minimum needs widget. The minimum needs widget current state is saved to the QSettings via the appropriate QMinimumNeeds class' method. """ minimum_needs = {'resources': []} for index in range(self.resources_list....
python
{ "resource": "" }
q243384
NeedsManagerDialog.save_profile_as
train
def save_profile_as(self): """Save the minimum needs under a new profile name. """ # noinspection PyCallByClass,PyTypeChecker file_name_dialog = QFileDialog(self) file_name_dialog.setAcceptMode(QFileDialog.AcceptSave) file_name_dialog.setNameFilter(self.tr('JSON files (*....
python
{ "resource": "" }
q243385
NeedsManagerDialog.new_profile
train
def new_profile(self): """Create a new profile by name. """ # noinspection PyCallByClass,PyTypeChecker dir = os.path.join(QgsApplication.qgisSettingsDirPath(), 'inasafe', 'minimum_needs') file_name, __ = QFileDialog.getSaveFileName( self, ...
python
{ "resource": "" }
q243386
NeedsManagerDialog.page_changed
train
def page_changed(self, index): """Slot for when tab changes in the stacked widget changes. :param index: Index of the now active tab. :type index: int """ if index == 0: # profile edit page for item in self.resource_editing_buttons: item.hide() ...
python
{ "resource": "" }
q243387
NeedsManagerDialog.switch_context
train
def switch_context(self, page): """Switch context tabs by tab widget name. :param page: The page should be focussed. :type page: QWidget """ # noinspection PyUnresolvedReferences if page.objectName() == 'profile_edit_page': self.stacked_widget.setCurrentIndex...
python
{ "resource": "" }
q243388
NeedsManagerDialog.remove_profile
train
def remove_profile(self): """Remove the current profile. Make sure the user is sure. """ profile_name = self.profile_combo.currentText() # noinspection PyTypeChecker button_selected = QMessageBox.warning( None, 'Remove Profile', self.t...
python
{ "resource": "" }
q243389
logo_element
train
def logo_element(): """Create a sanitised local url to the logo for insertion into html. :returns: A sanitised local url to the logo prefixed with file://. :rtype: str ..note:: We are not using QUrl here because on Windows 10 it returns an empty path if using QUrl.toLocalPath """ path...
python
{ "resource": "" }
q243390
Image.to_text
train
def to_text(self): """Render as plain text. """ if self.text == '': return '::%s' % self.uri return '::%s [%s]' % (self.text, self.uri)
python
{ "resource": "" }
q243391
display_information_message_bar
train
def display_information_message_bar( title=None, message=None, more_details=None, button_text=tr('Show details ...'), duration=8, iface_object=iface): """ Display an information message bar. :param iface_object: The QGIS IFace instance. Note that we cannot ...
python
{ "resource": "" }
q243392
display_warning_message_bar
train
def display_warning_message_bar( title=None, message=None, more_details=None, button_text=tr('Show details ...'), duration=8, iface_object=iface): """ Display a warning message bar. :param title: The title of the message bar. :type title: basestring ...
python
{ "resource": "" }
q243393
display_critical_message_bar
train
def display_critical_message_bar( title=None, message=None, more_details=None, button_text=tr('Show details ...'), duration=8, iface_object=iface ): """ Display a critical message bar. :param title: The title of the message bar. :type title: basestring ...
python
{ "resource": "" }
q243394
hazard_class_style
train
def hazard_class_style(layer, classification, display_null=False): """Set colors to the layer according to the hazard. :param layer: The layer to style. :type layer: QgsVectorLayer :param display_null: If we should display the null hazard zone. Default to False. :type display_null: bool ...
python
{ "resource": "" }
q243395
layer_title
train
def layer_title(layer): """Set the layer title according to the standards. :param layer: The layer to style. :type layer: QgsVectorLayer """ exposure_type = layer.keywords['exposure_keywords']['exposure'] exposure_definitions = definition(exposure_type) title = exposure_definitions['layer_l...
python
{ "resource": "" }
q243396
generate_classified_legend
train
def generate_classified_legend( analysis, exposure, hazard, use_rounding, debug_mode): """Generate an ordered python structure with the classified symbology. :param analysis: The analysis layer. :type analysis: QgsVectorLayer :param exposure: The exposure layer....
python
{ "resource": "" }
q243397
_add_not_exposed
train
def _add_not_exposed( analysis_row, enable_rounding, is_population, exposure_unit, coefficient): """Helper to add the `not exposed` item to the legend. :param analysis_row: The analysis row as a list. :type analysis_row: list :param enable_rounding: If we need t...
python
{ "resource": "" }
q243398
_format_label
train
def _format_label( hazard_class, value, exposure_unit, hazard_unit=None, minimum=None, maximum=None): """Helper function to format the label in the legend. :param hazard_class: The main name of the label. :type hazard_class: basestring :param value: The ...
python
{ "resource": "" }
q243399
simple_polygon_without_brush
train
def simple_polygon_without_brush(layer, width='0.26', color=QColor('black')): """Simple style to apply a border line only to a polygon layer. :param layer: The layer to style. :type layer: QgsVectorLayer :param color: Color to use for the line. Default to black. :type color: QColor :param wid...
python
{ "resource": "" }