idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
26,700
def _create_keywords_wizard_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-keyword-wizard.svg' ) self . action_keywords_wizard = QAction ( QIcon ( icon ) , self . tr ( 'Keywords Creation Wizard' ) , self . iface . mainWindow ( ) ) self . action_keywords_wizard . setStatusTip ( self . tr ( 'Open InaSA...
Create action for keywords creation wizard .
26,701
def _create_analysis_wizard_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-wizard.svg' ) self . action_function_centric_wizard = QAction ( QIcon ( icon ) , self . tr ( 'Impact Function Centric Wizard' ) , self . iface . mainWindow ( ) ) self . action_function_centric_wizard . setStatusTip ( self . tr...
Create action for IF - centric wizard .
26,702
def _create_options_dialog_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'configure-inasafe.svg' ) self . action_options = QAction ( QIcon ( icon ) , self . tr ( 'Options' ) , self . iface . mainWindow ( ) ) self . action_options . setStatusTip ( self . tr ( 'Open InaSAFE options dialog' ) ) self . action...
Create action for options dialog .
26,703
def _create_minimum_needs_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-minimum-needs.svg' ) self . action_minimum_needs = QAction ( QIcon ( icon ) , self . tr ( 'Minimum Needs Calculator' ) , self . iface . mainWindow ( ) ) self . action_minimum_needs . setStatusTip ( self . tr ( 'Open InaSAFE mini...
Create action for minimum needs dialog .
26,704
def _create_multi_buffer_action ( self ) : 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_buffer . setStatusTip ( self . tr ( 'Open InaSAFE multi buffer' ) ) se...
Create action for multi buffer dialog .
26,705
def _create_minimum_needs_options_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-global-minimum-needs.svg' ) self . action_minimum_needs_config = QAction ( QIcon ( icon ) , self . tr ( 'Minimum Needs Configuration' ) , self . iface . mainWindow ( ) ) self . action_minimum_needs_config . setStatusTip ...
Create action for global minimum needs dialog .
26,706
def _create_shakemap_converter_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-converter-tool.svg' ) self . action_shake_converter = QAction ( QIcon ( icon ) , self . tr ( 'Shakemap Converter' ) , self . iface . mainWindow ( ) ) self . action_shake_converter . setStatusTip ( self . tr ( 'Open InaSAFE ...
Create action for converter dialog .
26,707
def _create_batch_runner_action ( self ) : 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_runner . setStatusTip ( self . tr ( 'Open Batch Runner' ) ) self . act...
Create action for batch runner dialog .
26,708
def _create_save_scenario_action ( self ) : 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 = self . tr ( 'Save current scenario to text file' ) self . action_save_...
Create action for save scenario dialog .
26,709
def _create_geonode_uploader_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'geonode.png' ) label = tr ( 'Geonode Uploader' ) self . action_geonode = QAction ( QIcon ( icon ) , label , self . iface . mainWindow ( ) ) self . action_geonode . setStatusTip ( label ) self . action_geonode . setWhatsThis ( labe...
Create action for Geonode uploader dialog .
26,710
def _create_metadata_converter_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-metadata-converter.svg' ) self . action_metadata_converter = QAction ( QIcon ( icon ) , self . tr ( 'InaSAFE Metadata Converter' ) , self . iface . mainWindow ( ) ) self . action_metadata_converter . setStatusTip ( self . t...
Create action for showing metadata converter dialog .
26,711
def _create_field_mapping_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'show-mapping-tool.svg' ) self . action_field_mapping = QAction ( QIcon ( icon ) , self . tr ( 'InaSAFE Field Mapping Tool' ) , self . iface . mainWindow ( ) ) self . action_field_mapping . setStatusTip ( self . tr ( 'Assign field map...
Create action for showing field mapping dialog .
26,712
def _create_multi_exposure_action ( self ) : self . action_multi_exposure = QAction ( QIcon ( resources_path ( 'img' , 'icons' , 'show-multi-exposure.svg' ) ) , self . tr ( 'InaSAFE Multi Exposure Tool' ) , self . iface . mainWindow ( ) ) self . action_multi_exposure . setStatusTip ( self . tr ( 'Open the multi exposur...
Create action for showing the multi exposure tool .
26,713
def _create_rubber_bands_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'toggle-rubber-bands.svg' ) self . action_toggle_rubberbands = QAction ( QIcon ( icon ) , self . tr ( 'Toggle Scenario Outlines' ) , self . iface . mainWindow ( ) ) message = self . tr ( 'Toggle rubber bands showing scenario extents.' ...
Create action for toggling rubber bands .
26,714
def _create_analysis_extent_action ( self ) : icon = resources_path ( 'img' , 'icons' , 'set-extents-tool.svg' ) self . action_extent_selector = QAction ( QIcon ( icon ) , self . tr ( 'Set Analysis Area' ) , self . iface . mainWindow ( ) ) self . action_extent_selector . setStatusTip ( self . tr ( 'Set the analysis are...
Create action for analysis extent dialog .
26,715
def _create_dock ( self ) : from safe . gui . widgets . dock import Dock self . dock_widget = Dock ( self . iface ) self . dock_widget . setObjectName ( 'InaSAFE-Dock' ) self . iface . addDockWidget ( Qt . RightDockWidgetArea , self . dock_widget ) legend_tab = self . iface . mainWindow ( ) . findChild ( QApplication ,...
Create dockwidget and tabify it with the legend .
26,716
def _add_spacer_to_menu ( self ) : separator = QAction ( self . iface . mainWindow ( ) ) separator . setSeparator ( True ) self . iface . addPluginToMenu ( self . tr ( 'InaSAFE' ) , separator )
Create a spacer to the menu to separate action groups .
26,717
def clear_modules ( ) : modules = [ ] for module in sys . modules : if 'inasafe' in module : tokens = module . split ( '.' ) path = '' for myToken in tokens : path += os . path . sep + myToken parent = os . path . abspath ( os . path . join ( __file__ , os . path . pardir , os . path . pardir ) ) full_path = os . path ...
Unload inasafe functions and try to return QGIS to before InaSAFE .
26,718
def toggle_dock_visibility ( self ) : if self . dock_widget . isVisible ( ) : self . dock_widget . setVisible ( False ) else : self . dock_widget . setVisible ( True ) self . dock_widget . raise_ ( )
Show or hide the dock widget .
26,719
def show_extent_selector ( self ) : from safe . gui . tools . extent_selector_dialog import ExtentSelectorDialog widget = ExtentSelectorDialog ( self . iface , self . iface . mainWindow ( ) , extent = self . dock_widget . extent . user_extent , crs = self . dock_widget . extent . crs ) widget . clear_extent . connect (...
Show the extent selector widget for defining analysis extents .
26,720
def show_options ( self ) : from safe . gui . tools . options_dialog import OptionsDialog dialog = OptionsDialog ( iface = self . iface , parent = self . iface . mainWindow ( ) ) dialog . show_option_dialog ( ) if dialog . exec_ ( ) : self . dock_widget . read_settings ( ) from safe . gui . widgets . message import get...
Show the options dialog .
26,721
def show_welcome_message ( self ) : from safe . gui . tools . options_dialog import OptionsDialog show_message = False previous_version = StrictVersion ( setting ( 'previous_version' ) ) current_version = StrictVersion ( inasafe_version ) set_setting ( 'previous_version' , inasafe_version ) if setting ( 'always_show_we...
Show the welcome message .
26,722
def show_keywords_wizard ( self ) : from safe . gui . tools . wizard . wizard_dialog import WizardDialog if self . iface . activeLayer ( ) is None : return if self . wizard and self . wizard . isVisible ( ) : return if not self . wizard : self . wizard = WizardDialog ( self . iface . mainWindow ( ) , self . iface , sel...
Show the keywords creation wizard .
26,723
def show_function_centric_wizard ( self ) : from safe . gui . tools . wizard . wizard_dialog import WizardDialog if self . wizard and self . wizard . isVisible ( ) : return if not self . wizard : self . wizard = WizardDialog ( self . iface . mainWindow ( ) , self . iface , self . dock_widget ) self . wizard . set_funct...
Show the function centric wizard .
26,724
def show_shakemap_importer ( self ) : from safe . gui . tools . shake_grid . shakemap_converter_dialog import ( ShakemapConverterDialog ) dialog = ShakemapConverterDialog ( self . iface . mainWindow ( ) , self . iface , self . dock_widget ) dialog . exec_ ( )
Show the converter dialog .
26,725
def show_multi_buffer ( self ) : from safe . gui . tools . multi_buffer_dialog import ( MultiBufferDialog ) dialog = MultiBufferDialog ( self . iface . mainWindow ( ) , self . iface , self . dock_widget ) dialog . exec_ ( )
Show the multi buffer tool .
26,726
def show_osm_downloader ( self ) : from safe . gui . tools . osm_downloader_dialog import OsmDownloaderDialog dialog = OsmDownloaderDialog ( self . iface . mainWindow ( ) , self . iface ) dialog . setAttribute ( Qt . WA_DeleteOnClose , True ) dialog . show ( )
Show the OSM buildings downloader dialog .
26,727
def show_geonode_uploader ( self ) : from safe . gui . tools . geonode_uploader import GeonodeUploaderDialog dialog = GeonodeUploaderDialog ( self . iface . mainWindow ( ) ) dialog . show ( )
Show the Geonode uploader dialog .
26,728
def add_osm_layer ( self ) : path = resources_path ( 'osm' , 'WorldOSM.gdal' ) layer = QgsRasterLayer ( path , self . tr ( 'OpenStreetMap' ) ) project = QgsProject . instance ( ) project . addMapLayer ( layer , False ) root = QgsProject . instance ( ) . layerTreeRoot ( ) index = len ( root . findLayers ( ) ) + 1 root ....
Add OSM tile layer to the map .
26,729
def show_field_mapping ( self ) : from safe . gui . tools . field_mapping_dialog import FieldMappingDialog dialog = FieldMappingDialog ( parent = self . iface . mainWindow ( ) , iface = self . iface , ) if dialog . exec_ ( ) : LOGGER . debug ( 'Show field mapping accepted' ) self . dock_widget . layer_changed ( self . ...
Show InaSAFE Field Mapping .
26,730
def show_metadata_converter ( self ) : from safe . gui . tools . metadata_converter_dialog import ( MetadataConverterDialog ) dialog = MetadataConverterDialog ( parent = self . iface . mainWindow ( ) , iface = self . iface , ) dialog . exec_ ( )
Show InaSAFE Metadata Converter .
26,731
def show_multi_exposure ( self ) : from safe . gui . tools . multi_exposure_dialog import MultiExposureDialog dialog = MultiExposureDialog ( self . iface . mainWindow ( ) , self . iface ) dialog . exec_ ( )
Show InaSAFE Multi Exposure .
26,732
def add_petabencana_layer ( self ) : from safe . gui . tools . peta_bencana_dialog import PetaBencanaDialog dialog = PetaBencanaDialog ( self . iface . mainWindow ( ) , self . iface ) dialog . show ( )
Add petabencana layer to the map .
26,733
def show_batch_runner ( self ) : from safe . gui . tools . batch . batch_dialog import BatchDialog dialog = BatchDialog ( parent = self . iface . mainWindow ( ) , iface = self . iface , dock = self . dock_widget ) dialog . exec_ ( )
Show the batch runner dialog .
26,734
def save_scenario ( self ) : from safe . gui . tools . save_scenario import SaveScenarioDialog dialog = SaveScenarioDialog ( iface = self . iface , dock = self . dock_widget ) dialog . save_scenario ( )
Save current scenario to text file .
26,735
def layer_changed ( self , layer ) : if not layer : enable_keyword_wizard = False elif not hasattr ( layer , 'providerType' ) : enable_keyword_wizard = False elif layer . providerType ( ) == 'wms' : enable_keyword_wizard = False else : enable_keyword_wizard = True try : if layer : if is_raster_layer ( layer ) : enable_...
Enable or disable keywords editor icon when active layer changes .
26,736
def populate_tabs ( self ) : 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 ( layer_name = self . layer . name ( ) ) raise KeywordNotFoundError ( message ) if layer_purpose == la...
Populating tabs based on layer metadata .
26,737
def evaluate_formula ( formula , variables ) : for key , value in list ( variables . items ( ) ) : if value is None or ( hasattr ( value , 'isNull' ) and value . isNull ( ) ) : return value formula = formula . replace ( key , str ( value ) ) result = eval ( formula ) return result
Very simple formula evaluator . Beware the security .
26,738
def enough_input ( layer , post_processor_input ) : impact_fields = list ( layer . keywords [ 'inasafe_fields' ] . keys ( ) ) for input_key , input_values in list ( post_processor_input . items ( ) ) : input_values = ( input_values if isinstance ( input_values , list ) else [ input_values ] ) msg = None for input_value...
Check if the input from impact_fields in enough .
26,739
def set_value_for_key ( self , key , value ) : if key in self . options : self . options [ key ] [ 'value' ] = value
Set the value of key to value .
26,740
def on_lstUnits_itemSelectionChanged ( self ) : self . clear_further_steps ( ) unit = self . selected_unit ( ) if not unit : return self . lblDescribeUnit . setText ( unit [ 'description' ] ) self . parent . pbnNext . setEnabled ( True )
Update unit description label and field widgets .
26,741
def selected_unit ( self ) : item = self . lstUnits . currentItem ( ) try : return definition ( item . data ( QtCore . Qt . UserRole ) ) except ( AttributeError , NameError ) : return None
Obtain the unit selected by user .
26,742
def set_widgets ( self ) : self . clear_further_steps ( ) purpose = self . parent . step_kw_purpose . selected_purpose ( ) subcategory = self . parent . step_kw_subcategory . selected_subcategory ( ) self . lblSelectUnit . setText ( unit_question % ( subcategory [ 'name' ] , purpose [ 'name' ] ) ) self . lblDescribeUni...
Set widgets on the Unit tab .
26,743
def get_report_section ( html_report , component_id , container_wrapper_format = container_format ) : no_element_error = tr ( 'No element match the tag or component id.' ) root_element , dict_of_elements = ET . XMLID ( html_report ) section_element = dict_of_elements . get ( component_id ) if section_element : requeste...
Get specific report section from InaSAFE analysis summary report .
26,744
def analysis_summary_report ( feature , parent ) : _ = feature , parent project_context_scope = QgsExpressionContextUtils . projectScope ( QgsProject . instance ( ) ) key = provenance_layer_analysis_impacted [ 'provenance_key' ] if not project_context_scope . hasVariable ( key ) : return None analysis_dir = dirname ( p...
Retrieve an HTML table report of current selected analysis .
26,745
def analysis_question_report ( feature , parent ) : _ = feature , parent project_context_scope = QgsExpressionContextUtils . projectScope ( ) key = provenance_layer_analysis_impacted [ 'provenance_key' ] if not project_context_scope . hasVariable ( key ) : return None analysis_dir = dirname ( project_context_scope . va...
Retrieve the analysis question section from InaSAFE report .
26,746
def population_analysis_summary_report ( feature , parent ) : _ = feature , parent analysis_dir = get_analysis_dir ( exposure_population [ 'key' ] ) if analysis_dir : return get_impact_report_as_string ( analysis_dir ) return None
Retrieve an HTML population analysis table report from a multi exposure analysis .
26,747
def road_analysis_summary_report ( feature , parent ) : _ = feature , parent analysis_dir = get_analysis_dir ( exposure_road [ 'key' ] ) if analysis_dir : return get_impact_report_as_string ( analysis_dir ) return None
Retrieve an HTML road analysis table report from a multi exposure analysis .
26,748
def structure_analysis_summary_report ( feature , parent ) : _ = feature , parent analysis_dir = get_analysis_dir ( exposure_structure [ 'key' ] ) if analysis_dir : return get_impact_report_as_string ( analysis_dir ) return None
Retrieve an HTML structure analysis table report from a multi exposure analysis .
26,749
def place_analysis_summary_report ( feature , parent ) : _ = feature , parent analysis_dir = get_analysis_dir ( exposure_place [ 'key' ] ) if analysis_dir : return get_impact_report_as_string ( analysis_dir ) return None
Retrieve an HTML place analysis table report from a multi exposure analysis .
26,750
def land_cover_analysis_summary_report ( feature , parent ) : _ = feature , parent analysis_dir = get_analysis_dir ( exposure_land_cover [ 'key' ] ) if analysis_dir : return get_impact_report_as_string ( analysis_dir ) return None
Retrieve an HTML land cover analysis table report from a multi exposure analysis .
26,751
def multi_exposure_analysis_summary_report ( feature , parent ) : _ = feature , parent analysis_dir = get_analysis_dir ( ) if analysis_dir : return get_impact_report_as_string ( analysis_dir ) return None
Retrieve an HTML multi exposure analysis table report .
26,752
def show_help ( self , wizard_step ) : self . wizard_step = wizard_step header = html_header ( ) footer = html_footer ( ) content = header message = self . wizard_step . help ( ) content += message . to_html ( ) content += footer self . help_web_view . setHtml ( content ) self . next_button_state = self . parent . pbnN...
Set wizard step and show the help text .
26,753
def restore_button_state ( self ) : self . parent . pbnNext . setEnabled ( self . next_button_state ) self . parent . pbnBack . setEnabled ( self . back_button_state )
Helper to restore button state .
26,754
def html_footer ( ) : file_path = resources_path ( 'footer.html' ) with open ( file_path ) as header_file : content = header_file . read ( ) return content
Get a standard html footer for wrapping content in .
26,755
def html_header ( ) : file_path = resources_path ( 'header.html' ) with codecs . open ( file_path , 'r' , encoding = 'utf8' ) as header_file : content = header_file . read ( ) content = content . replace ( 'PATH' , resources_path ( ) ) return content
Get a standard html header for wrapping content in .
26,756
def resources_path ( * args ) : path = os . path . dirname ( __file__ ) path = os . path . abspath ( os . path . join ( path , os . path . pardir , 'resources' ) ) for item in args : path = os . path . abspath ( os . path . join ( path , item ) ) return path
Get the path to our resources folder .
26,757
def resource_url ( path ) : url = QtCore . QUrl . fromLocalFile ( path ) return str ( url . toString ( ) )
Get the a local filesystem url to a given resource .
26,758
def get_ui_class ( ui_file ) : os . path . sep . join ( ui_file . split ( '/' ) ) ui_file_path = os . path . abspath ( os . path . join ( os . path . dirname ( __file__ ) , os . pardir , 'gui' , 'ui' , ui_file ) ) return uic . loadUiType ( ui_file_path ) [ 0 ]
Get UI Python class from . ui file .
26,759
def set_widgets ( self ) : source = self . parent . get_existing_keyword ( 'source' ) if source or source == 0 : self . leSource . setText ( source ) else : self . leSource . clear ( ) source_scale = self . parent . get_existing_keyword ( 'scale' ) if source_scale or source_scale == 0 : self . leSource_scale . setText ...
Set widgets on the Source tab .
26,760
def welcome_message ( ) : message = m . Message ( ) message . add ( m . Brand ( ) ) message . add ( heading ( ) ) message . add ( content ( ) ) return message
Welcome message for first running users .
26,761
def read_scenarios ( filename ) : filename = os . path . abspath ( filename ) blocks = { } parser = ConfigParser ( ) try : parser . read ( filename ) except MissingSectionHeaderError : base_name = os . path . basename ( filename ) name = os . path . splitext ( base_name ) [ 0 ] section = '[%s]\n' % name content = secti...
Read keywords dictionary from file .
26,762
def validate_scenario ( blocks , scenario_directory ) : blocks_update = { } for section , section_item in list ( blocks . items ( ) ) : ready = True for item in section_item : if item in [ 'hazard' , 'exposure' , 'aggregation' ] : rel_path = section_item [ item ] full_path = os . path . join ( scenario_directory , rel_...
Function to validate input layer stored in scenario file .
26,763
def append_row ( table , label , data ) : count = table . rowCount ( ) table . insertRow ( table . rowCount ( ) ) items = QTableWidgetItem ( label ) variant = ( data , ) items . setData ( Qt . UserRole , variant ) table . setItem ( count , 0 , items ) table . setItem ( count , 1 , QTableWidgetItem ( data [ 'status' ] )...
Append new row to table widget .
26,764
def restore_state ( self ) : last_source_path = setting ( 'lastSourceDir' , self . default_directory , expected_type = str ) self . source_directory . setText ( last_source_path ) last_output_dir = setting ( 'lastOutputDir' , self . default_directory , expected_type = str ) self . output_directory . setText ( last_outp...
Restore GUI state from configuration file .
26,765
def save_state ( self ) : set_setting ( 'lastSourceDir' , self . source_directory . text ( ) ) set_setting ( 'lastOutputDir' , self . output_directory . text ( ) ) set_setting ( 'useDefaultOutputDir' , self . scenario_directory_radio . isChecked ( ) )
Save current state of GUI to configuration file .
26,766
def choose_directory ( self , line_edit , title ) : path = line_edit . text ( ) new_path = QFileDialog . getExistingDirectory ( self , title , path , QFileDialog . ShowDirsOnly ) if new_path is not None and os . path . exists ( new_path ) : line_edit . setText ( new_path )
Show a directory selection dialog . This function will show the dialog then set line_edit widget text with output from the dialog .
26,767
def populate_table ( self , scenario_directory ) : parsed_files = [ ] unparsed_files = [ ] self . table . clearContents ( ) self . table . blockSignals ( True ) self . table . setRowCount ( 0 ) if not os . path . exists ( scenario_directory ) : return for current_path in os . listdir ( scenario_directory ) : extension ...
Populate table with files from scenario_directory directory .
26,768
def run_script ( self , filename ) : module , _ = os . path . splitext ( filename ) if module in sys . modules : script = reload ( sys . modules [ module ] ) else : script = __import__ ( module ) function = script . runScript if function . __code__ . co_argcount == 1 : function ( self . iface ) else : function ( )
Run a python script in QGIS to exercise InaSAFE functionality .
26,769
def reset_status ( self ) : for row in range ( self . table . rowCount ( ) ) : status_item = self . table . item ( row , 1 ) status_item . setText ( self . tr ( '' ) )
Set all scenarios status to empty in the table .
26,770
def prepare_task ( self , items ) : status = True message = '' if 'hazard' in items : hazard_path = items [ 'hazard' ] hazard = self . define_layer ( hazard_path ) if not hazard : status = False message = self . tr ( 'Unable to find {hazard_path}' ) . format ( hazard_path = hazard_path ) else : hazard = None LOGGER . w...
Prepare scenario for impact function variable .
26,771
def set_layer_visible ( layer , visible ) : if layer is None : return QgsProject . instance ( ) . layerTreeRoot ( ) . findLayer ( layer . id ( ) ) . setItemVisibilityChecked ( visible )
Sets a layer in the project visible or not
26,772
def run_selected_clicked ( self ) : rows = sorted ( set ( index . row ( ) for index in self . table . selectedIndexes ( ) ) ) self . enable_busy_cursor ( ) for row in rows : current_row = row item = self . table . item ( current_row , 0 ) status_item = self . table . item ( current_row , 1 ) self . run_task ( item , st...
Run the selected scenario .
26,773
def run_all_clicked ( self ) : 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 , 0 ) status_item = self . table . item ( row , 1 ) name_item = item . text ( ) try : index += 1 r...
Run all scenario when pbRunAll is clicked .
26,774
def write_report ( self , report , pass_count , fail_count ) : separator = '-----------------------------\n' current_time = datetime . now ( ) . strftime ( '%Y%m%d%H%M%S' ) report_path = 'batch-report-' + current_time + '.txt' output_path = self . output_directory . text ( ) path = os . path . join ( output_path , repo...
Write a report status of Batch Runner .
26,775
def generate_pdf_report ( self , impact_function , iface , scenario_name ) : output_dir = self . output_directory . text ( ) file_path = os . path . join ( output_dir , scenario_name ) table_report_metadata = ReportMetadata ( metadata_dict = standard_impact_report_metadata_pdf ) impact_table_report = ImpactReport ( ifa...
Generate and store map and impact report from impact function .
26,776
def show_report ( self , report_path ) : if self . show_results_popup : url = QtCore . QUrl . fromLocalFile ( report_path ) QtGui . QDesktopServices . openUrl ( url ) else : pass
Show batch report file in batchReportFileName using an external app .
26,777
def update_default_output_dir ( self ) : if self . scenario_directory_radio . isChecked ( ) : self . output_directory . setText ( self . source_directory . text ( ) )
Update output dir if set to default .
26,778
def enable_busy_cursor ( self ) : QgsApplication . instance ( ) . setOverrideCursor ( QtGui . QCursor ( QtCore . Qt . WaitCursor ) )
Set the hourglass enabled .
26,779
def on_scenario_directory_radio_toggled ( self , flag ) : if flag : self . output_directory . setText ( self . source_directory . text ( ) ) self . output_directory_chooser . setEnabled ( not flag )
Autoconnect slot activated when scenario_directory_radio is checked .
26,780
def on_source_directory_chooser_clicked ( self ) : title = self . tr ( 'Set the source directory for script and scenario' ) self . choose_directory ( self . source_directory , title )
Autoconnect slot activated when tbSourceDir is clicked .
26,781
def on_output_directory_chooser_clicked ( self ) : title = self . tr ( 'Set the output directory for pdf report files' ) self . choose_directory ( self . output_directory , title )
Auto connect slot activated when tbOutputDiris clicked .
26,782
def to_html ( self ) : if self . align is 'left' : if self . style_class is None : self . style_class = 'text-left' else : self . style_class += ' text-left' elif self . align is 'right' : if self . style_class is None : self . style_class = 'text-right' else : self . style_class += ' text-right' elif self . align is '...
Render a Cell MessageElement as html
26,783
def error_creator5 ( ) : try : error_creator4 ( ) except SafeError as e4 : message = ErrorMessage ( 'Creator 5 problem' , detail = Message ( Paragraph ( 'Could not' , ImportantText ( 'call' ) , 'function.' ) , Paragraph ( 'Try reinstalling your computer with windows.' ) ) , suggestion = Message ( ImportantText ( 'Impor...
Raise a safe style error and append a full message .
26,784
def qgis_composer_infographic_extractor ( impact_report , component_metadata ) : qgis_context = impact_report . qgis_composition_context extra_args = component_metadata . extra_args context = QGISComposerContext ( ) image_elements = deepcopy ( image_item_elements ) image_elements . remove ( inasafe_logo_white ) image_e...
Extract composer context specific for infographic template .
26,785
def inasafe_fields_for_the_layer ( self ) : if ( self . parent . get_layer_geometry_key ( ) == layer_geometry_raster [ 'key' ] ) : return [ ] layer_purpose_key = self . parent . step_kw_purpose . selected_purpose ( ) [ 'key' ] if layer_purpose_key != layer_purpose_aggregation [ 'key' ] : subcategory_key = self . parent...
Return a list of inasafe fields the current layer .
26,786
def __if_not_basestring ( text_object ) : converted_str = text_object if not isinstance ( text_object , str ) : converted_str = str ( text_object ) return converted_str
Convert to str
26,787
def get_string ( input_text , encoding = 'utf-8' ) : if isinstance ( input_text , str ) : return input_text . encode ( encoding ) return input_text
Get byte string representation of an object .
26,788
def byteify ( input_object ) : if isinstance ( input_object , dict ) : return { byteify ( key ) : byteify ( value ) for key , value in list ( input_object . items ( ) ) } elif isinstance ( input_object , list ) : return [ byteify ( element ) for element in input_object ] elif isinstance ( input_object , str ) : return ...
Recursive function to transform an object to byte .
26,789
def dict ( self ) : metadata = super ( ImpactLayerMetadata , self ) . dict metadata [ 'provenance' ] = self . provenance metadata [ 'summary_data' ] = self . summary_data return metadata
calls the overridden method and adds provenance and summary data
26,790
def _read_provenance_from_xml ( self , root ) : path = self . _special_properties [ 'provenance' ] provenance = root . find ( path , XML_NS ) for step in provenance . iter ( 'provenance_step' ) : title = step . find ( 'title' ) . text description = step . find ( 'description' ) . text timestamp = step . get ( 'timestam...
read metadata provenance from xml .
26,791
def append_provenance_step ( self , title , description , timestamp = None ) : step_time = self . _provenance . append_step ( title , description , timestamp ) if step_time > self . last_update : self . last_update = step_time
Add a step to the provenance of the metadata
26,792
def append_if_provenance_step ( self , title , description , timestamp = None , data = None ) : step_time = self . _provenance . append_if_provenance_step ( title , description , timestamp , data ) if step_time > self . last_update : self . last_update = step_time
Add a if provenance step to the provenance of the metadata
26,793
def update_from_dict ( self , keywords ) : super ( ImpactLayerMetadata , self ) . update_from_dict ( keywords ) if 'if_provenance' in list ( keywords . keys ( ) ) : if_provenance = keywords [ 'if_provenance' ] for provenance_step in if_provenance : self . provenance . append_provenance_step ( provenance_step )
Update metadata value from a keywords dictionary .
26,794
def update_list_widget ( self ) : radio_button_checked_id = self . input_button_group . checkedId ( ) if radio_button_checked_id > - 1 : selected_dict = list ( self . _parameter . options . values ( ) ) [ radio_button_checked_id ] if selected_dict . get ( 'type' ) == MULTIPLE_DYNAMIC : for field in selected_dict . get ...
Update list widget when radio button is clicked .
26,795
def radio_buttons_clicked ( self ) : for spin_box in list ( self . spin_boxes . values ( ) ) : spin_box . setEnabled ( False ) self . list_widget . setEnabled ( False ) radio_button_checked_id = self . input_button_group . checkedId ( ) if radio_button_checked_id > - 1 : selected_value = list ( self . _parameter . opti...
Handler when selected radio button changed .
26,796
def select_radio_button ( self , key ) : key_index = list ( self . _parameter . options . keys ( ) ) . index ( key ) radio_button = self . input_button_group . button ( key_index ) radio_button . click ( )
Helper to select a radio button with key .
26,797
def to_html ( self ) : 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 , 'InaSAFE' , 'InaSAFE' , self . html_attributes ( ) ) return snippet
Render as html .
26,798
def mmi_detail_extractor ( impact_report , component_metadata ) : context = { } analysis_layer = impact_report . analysis analysis_layer_keywords = analysis_layer . keywords extra_args = component_metadata . extra_args use_rounding = impact_report . impact_function . use_rounding provenance = impact_report . impact_fun...
Extracting MMI - related analysis result .
26,799
def inasafe_field_header ( field , feature , parent ) : _ = feature , parent age_fields = [ under_5_displaced_count_field , over_60_displaced_count_field ] symbol_mapping = { 'over' : '>' , 'under' : '<' } field_definition = definition ( field , 'field_name' ) if field_definition : if field_definition in age_fields : h...
Retrieve a header name of the field name from definitions .