_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q243500
get_fields
train
def get_fields( layer_purpose, layer_subcategory=None, replace_null=None, in_group=True): """Get all field based on the layer purpose. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str ...
python
{ "resource": "" }
q243501
get_compulsory_fields
train
def get_compulsory_fields(layer_purpose, layer_subcategory=None): """Get compulsory field based on layer_purpose and layer_subcategory :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: C...
python
{ "resource": "" }
q243502
get_non_compulsory_fields
train
def get_non_compulsory_fields(layer_purpose, layer_subcategory=None): """Get non compulsory field based on layer_purpose and layer_subcategory. Used for get field in InaSAFE Fields step in wizard. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure...
python
{ "resource": "" }
q243503
get_name
train
def get_name(key): """Given a keyword, try to get the name of it. .. versionadded:: 4.2 Definition dicts are defined in keywords.py. We try to return the name if present, otherwise we return none. keyword = 'layer_purpose' kio = safe.utilities.keyword_io.Keyword_IO() name = kio.get_name(k...
python
{ "resource": "" }
q243504
get_class_name
train
def get_class_name(class_key, classification_key): """Helper to get class name from a class_key of a classification. :param class_key: The key of the class. :type class_key: str :type classification_key: The key of a classification. :param classification_key: str :returns: The name of the cla...
python
{ "resource": "" }
q243505
get_allowed_geometries
train
def get_allowed_geometries(layer_purpose_key): """Helper function to get all possible geometry :param layer_purpose_key: A layer purpose key. :type layer_purpose_key: str :returns: List of all allowed geometries. :rtype: list """ preferred_order = [ 'point', 'line', ...
python
{ "resource": "" }
q243506
all_default_fields
train
def all_default_fields(): """Helper to retrieve all fields which has default value. :returns: List of default fields. :rtype: list """ default_fields = [] for item in dir(fields): if not item.startswith("__"): var = getattr(definitions, item) if isinstance(var, d...
python
{ "resource": "" }
q243507
default_classification_thresholds
train
def default_classification_thresholds(classification, unit=None): """Helper to get default thresholds from classification and unit. :param classification: Classification definition. :type classification: dict :param unit: Unit key definition. :type unit: basestring :returns: Dictionary with k...
python
{ "resource": "" }
q243508
default_classification_value_maps
train
def default_classification_value_maps(classification): """Helper to get default value maps from classification. :param classification: Classification definition. :type classification: dict :returns: Dictionary with key = the class key and value = default strings. :rtype: dict """ value_map...
python
{ "resource": "" }
q243509
get_field_groups
train
def get_field_groups(layer_purpose, layer_subcategory=None): """Obtain list of field groups from layer purpose and subcategory. :param layer_purpose: The layer purpose. :type layer_purpose: str :param layer_subcategory: Exposure or hazard value. :type layer_subcategory: str :returns: List of ...
python
{ "resource": "" }
q243510
override_component_template
train
def override_component_template(component, template_path): """Override a default component with a new component with given template. :param component: Component as dictionary. :type component: dict :param template_path: Custom template path that will be used. :type template_path: str :returns...
python
{ "resource": "" }
q243511
update_template_component
train
def update_template_component( component, custom_template_dir=None, hazard=None, exposure=None): """Get a component based on custom qpt if exists :param component: Component as dictionary. :type component: dict :param custom_template_dir: The directory where the custom template stored. :ty...
python
{ "resource": "" }
q243512
get_displacement_rate
train
def get_displacement_rate( hazard, classification, hazard_class, qsettings=None): """Get displacement rate for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring ...
python
{ "resource": "" }
q243513
is_affected
train
def is_affected(hazard, classification, hazard_class, qsettings=None): """Get affected flag for hazard in classification in hazard class. :param hazard: The hazard key. :type hazard: basestring :param classification: The classification key. :type classification: basestring :param hazard_class...
python
{ "resource": "" }
q243514
safe_dir
train
def safe_dir(sub_dir=None): """Absolute path from safe package directory. :param sub_dir: Sub directory relative to safe package directory. :type sub_dir: str :return: The Absolute path. :rtype: str """ safe_relative_path = os.path.join( os.path.dirname(__file__), '../') return...
python
{ "resource": "" }
q243515
temp_dir
train
def temp_dir(sub_dir='work'): """Obtain the temporary working directory for the operating system. An inasafe subdirectory will automatically be created under this and if specified, a user subdirectory under that. .. note:: You can use this together with unique_filename to create a file in a tem...
python
{ "resource": "" }
q243516
unique_filename
train
def unique_filename(**kwargs): """Create new filename guaranteed not to exist previously Use mkstemp to create the file, then remove it and return the name If dir is specified, the tempfile will be created in the path specified otherwise the file will be created in a directory following this scheme: ...
python
{ "resource": "" }
q243517
get_free_memory
train
def get_free_memory(): """Return current free memory on the machine. Currently supported for Windows, Linux, MacOS. :returns: Free memory in MB unit :rtype: int """ if 'win32' in sys.platform: # windows return get_free_memory_win() elif 'linux' in sys.platform: # li...
python
{ "resource": "" }
q243518
get_free_memory_win
train
def get_free_memory_win(): """Return current free memory on the machine for windows. Warning : this script is really not robust Return in MB unit """ stat = MEMORYSTATUSEX() ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) return int(stat.ullAvailPhys / 1024 / 1024)
python
{ "resource": "" }
q243519
get_free_memory_linux
train
def get_free_memory_linux(): """Return current free memory on the machine for linux. Warning : this script is really not robust Return in MB unit """ try: p = Popen('free -m', shell=True, stdout=PIPE, encoding='utf8') stdout_string = p.communicate()[0].split('\n')[2] except OSEr...
python
{ "resource": "" }
q243520
get_free_memory_osx
train
def get_free_memory_osx(): """Return current free memory on the machine for mac os. Warning : this script is really not robust Return in MB unit """ try: p = Popen('echo -e "\n$(top -l 1 | awk \'/PhysMem/\';)\n"', shell=True, stdout=PIPE, encoding='utf8') stdout_st...
python
{ "resource": "" }
q243521
humanize_min_max
train
def humanize_min_max(min_value, max_value, interval): """Return humanize value format for max and min. If the range between the max and min is less than one, the original value will be returned. :param min_value: Minimum value :type min_value: int, float :param max_value: Maximim value :t...
python
{ "resource": "" }
q243522
format_decimal
train
def format_decimal(interval, value): """Return formatted decimal according to interval decimal place For example: interval = 0.33 (two decimal places) my_float = 1.1215454 Return 1.12 (return only two decimal places as string) If interval is an integer return integer part of my_number If my...
python
{ "resource": "" }
q243523
get_significant_decimal
train
def get_significant_decimal(my_decimal): """Return a truncated decimal by last three digit after leading zero.""" if isinstance(my_decimal, Integral): return my_decimal if my_decimal != my_decimal: # nan return my_decimal my_int_part = str(my_decimal).split('.')[0] my_decima...
python
{ "resource": "" }
q243524
humanize_class
train
def humanize_class(my_classes): """Return humanize interval of an array. For example:: Original Array: Result: 1.1 - 5754.1 0 - 1 5754.1 - 11507.1 1 - 5,754 5,754 - 11,507 ...
python
{ "resource": "" }
q243525
unhumanize_class
train
def unhumanize_class(my_classes): """Return class as interval without formatting.""" result = [] interval = my_classes[-1] - my_classes[-2] min_value = 0 for max_value in my_classes: result.append((format_decimal(interval, min_value), format_decimal(interval, max_value...
python
{ "resource": "" }
q243526
unhumanize_number
train
def unhumanize_number(number): """Return number without formatting. If something goes wrong in the conversion just return the passed number We catch AttributeError in case the number has no replace method which means it is not a string but already an int or float We catch ValueError if number is a ...
python
{ "resource": "" }
q243527
get_utm_zone
train
def get_utm_zone(longitude): """Return utm zone.""" zone = int((math.floor((longitude + 180.0) / 6.0) + 1) % 60) if zone == 0: zone = 60 return zone
python
{ "resource": "" }
q243528
get_utm_epsg
train
def get_utm_epsg(longitude, latitude, crs=None): """Return epsg code of the utm zone according to X, Y coordinates. By default, the CRS is EPSG:4326. If the CRS is provided, first X,Y will be reprojected from the input CRS to WGS84. The code is based on the code: http://gis.stackexchange.com/quest...
python
{ "resource": "" }
q243529
color_ramp
train
def color_ramp(number_of_colour): """Generate list of color in hexadecimal. This will generate colors using hsl model by playing around with the hue see: https://coderwall.com/p/dvsxwg/smoothly-transition-from-green-to-red :param number_of_colour: The number of intervals between R and G spectrum. ...
python
{ "resource": "" }
q243530
romanise
train
def romanise(number): """Return the roman numeral for a number. Note that this only works for number in interval range [0, 12] since at the moment we only use it on realtime earthquake to conver MMI value. :param number: The number that will be romanised :type number: float :return Roman nume...
python
{ "resource": "" }
q243531
add_to_list
train
def add_to_list(my_list, my_element): """Helper function to add new my_element to my_list based on its type. Add as new element if it's not a list, otherwise extend to the list if it's a list. It's also guarantee that all elements are unique :param my_list: A list :type my_list: list :par...
python
{ "resource": "" }
q243532
action_checklist_extractor
train
def action_checklist_extractor(impact_report, component_metadata): """Extracting action checklist of the exposure layer. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param c...
python
{ "resource": "" }
q243533
LayerBrowserProxyModel.filterAcceptsRow
train
def filterAcceptsRow(self, source_row, source_parent): """The filter method .. note:: This filter hides top-level items of unsupported branches and also leaf items containing xml files. Enabled root items: QgsDirectoryItem, QgsFavouritesItem, QgsPGRootItem. ...
python
{ "resource": "" }
q243534
FieldMappingDialog.save_metadata
train
def save_metadata(self): """Save metadata based on the field mapping state.""" metadata = self.field_mapping_widget.get_field_mapping() for key, value in list(metadata['fields'].items()): # Delete the key if it's set to None if key in self.metadata['inasafe_default_values...
python
{ "resource": "" }
q243535
add_impact_layers_to_canvas
train
def add_impact_layers_to_canvas(impact_function, group=None, iface=None): """Helper method to add impact layer to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction :param group: An existing group as a parent, optional. :type group: Q...
python
{ "resource": "" }
q243536
add_debug_layers_to_canvas
train
def add_debug_layers_to_canvas(impact_function): """Helper method to add debug layers to QGIS from impact function. :param impact_function: The impact function used. :type impact_function: ImpactFunction """ name = 'DEBUG %s' % impact_function.name root = QgsProject.instance().layerTreeRoot() ...
python
{ "resource": "" }
q243537
add_layers_to_canvas_with_custom_orders
train
def add_layers_to_canvas_with_custom_orders( order, impact_function, iface=None): """Helper to add layers to the map canvas following a specific order. From top to bottom in the legend: [ ('FromCanvas', layer name, full layer URI, QML), ('FromAnalysis', layer purpose, la...
python
{ "resource": "" }
q243538
add_layer_to_canvas
train
def add_layer_to_canvas(layer, name): """Helper method to add layer to QGIS. :param layer: The layer. :type layer: QgsMapLayer :param name: Layer name. :type name: str """ if qgis_version() >= 21800: layer.setName(name) else: layer.setLayerName(name) QgsProject.in...
python
{ "resource": "" }
q243539
summarize_result
train
def summarize_result(exposure_summary): """Extract result based on summarizer field value and sum by exposure type. :param exposure_summary: The layer impact layer. :type exposure_summary: QgsVectorLayer :return: Dictionary of attributes per exposure per summarizer field. :rtype: dict .. vers...
python
{ "resource": "" }
q243540
prettify_xml
train
def prettify_xml(xml_str): """ returns prettified XML without blank lines based on http://stackoverflow.com/questions/14479656/ :param xml_str: the XML to be prettified :type xml_str: str :return: the prettified XML :rtype: str """ parsed_xml = parseString(get_string(xml_str)) p...
python
{ "resource": "" }
q243541
serialize_dictionary
train
def serialize_dictionary(dictionary): """Function to stringify a dictionary recursively. :param dictionary: The dictionary. :type dictionary: dict :return: The string. :rtype: basestring """ string_value = {} for k, v in list(dictionary.items()): if isinstance(v, QUrl): ...
python
{ "resource": "" }
q243542
create_virtual_aggregation
train
def create_virtual_aggregation(geometry, crs): """Function to create aggregation layer based on extent. :param geometry: The geometry to use as an extent. :type geometry: QgsGeometry :param crs: The Coordinate Reference System to use for the layer. :type crs: QgsCoordinateReferenceSystem :ret...
python
{ "resource": "" }
q243543
create_analysis_layer
train
def create_analysis_layer(analysis_extent, crs, name): """Create the analysis layer. :param analysis_extent: The analysis extent. :type analysis_extent: QgsGeometry :param crs: The CRS to use. :type crs: QgsCoordinateReferenceSystem :param name: The name of the analysis. :type name: bases...
python
{ "resource": "" }
q243544
create_profile_layer
train
def create_profile_layer(profiling): """Create a tabular layer with the profiling. :param profiling: A dict containing benchmarking data. :type profiling: safe.messaging.message.Message :return: A tabular layer. :rtype: QgsVectorLayer """ fields = [ create_field_from_definition(pro...
python
{ "resource": "" }
q243545
create_valid_aggregation
train
def create_valid_aggregation(layer): """Create a local copy of the aggregation layer and try to make it valid. We need to make the layer valid if we can. We got some issues with DKI Jakarta dataset : Districts and Subdistricts layers. See issue : https://github.com/inasafe/inasafe/issues/3713 :par...
python
{ "resource": "" }
q243546
StepFcExtent.stop_capture_coordinates
train
def stop_capture_coordinates(self): """Exit the coordinate capture mode.""" self.extent_dialog._populate_coordinates() self.extent_dialog.canvas.setMapTool( self.extent_dialog.previous_map_tool) self.parent.show()
python
{ "resource": "" }
q243547
StepFcExtent.write_extent
train
def write_extent(self): """After the extent selection, save the extent and disconnect signals. """ self.extent_dialog.accept() self.extent_dialog.clear_extent.disconnect( self.parent.dock.extent.clear_user_analysis_extent) self.extent_dialog.extent_defined.disconnect(...
python
{ "resource": "" }
q243548
StepFcExtent.set_widgets
train
def set_widgets(self): """Set widgets on the Extent tab.""" self.extent_dialog = ExtentSelectorDialog( self.parent.iface, self.parent.iface.mainWindow(), extent=self.parent.dock.extent.user_extent, crs=self.parent.dock.extent.crs) self.extent_dialo...
python
{ "resource": "" }
q243549
clip_by_extent
train
def clip_by_extent(layer, extent): """Clip a raster using a bounding box using processing. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to clip. :type layer: QgsRasterLayer :param extent: The extent. :type extent: QgsRectangle :return: Clipped layer. :...
python
{ "resource": "" }
q243550
get_elements
train
def get_elements(nodelist): """Return list of nodes that are ELEMENT_NODE """ element_list = [] for node in nodelist: if node.nodeType == Node.ELEMENT_NODE: element_list.append(node) return element_list
python
{ "resource": "" }
q243551
get_text
train
def get_text(nodelist): """Return a concatenation of text fields from list of nodes """ s = '' for node in nodelist: if node.nodeType == Node.TEXT_NODE: s += node.nodeValue + ', ' if len(s)>0: s = s[:-2] return s
python
{ "resource": "" }
q243552
xml2object
train
def xml2object(xml, verbose=False): """Generate XML object model from XML file or XML text This is the inverse operation to the __str__ representation (up to whitespace). Input xml can be either an * xml file * open xml file object Return XML_document instance. """ # FIXME - can ...
python
{ "resource": "" }
q243553
dom2object
train
def dom2object(node): """Convert DOM representation to XML_object hierarchy. """ value = [] textnode_encountered = None for n in node.childNodes: if n.nodeType == 3: # Child is a text element - omit the dom tag #text and # go straight to the text value. ...
python
{ "resource": "" }
q243554
XML_element.pretty_print
train
def pretty_print(self, indent=0): """Print the document without tags using indentation """ s = tab = ' '*indent s += '%s: ' %self.tag if isinstance(self.value, basestring): s += self.value else: s += '\n' for e in self.value: ...
python
{ "resource": "" }
q243555
StepKwHazardCategory.on_lstHazardCategories_itemSelectionChanged
train
def on_lstHazardCategories_itemSelectionChanged(self): """Update hazard category description label. .. note:: This is an automatic Qt slot executed when the category selection changes. """ self.clear_further_steps() # Set widgets hazard_category = self.selecte...
python
{ "resource": "" }
q243556
StepKwHazardCategory.selected_hazard_category
train
def selected_hazard_category(self): """Obtain the hazard category selected by user. :returns: Metadata of the selected hazard category. :rtype: dict, None """ item = self.lstHazardCategories.currentItem() try: return definition(item.data(QtCore.Qt.UserRole)) ...
python
{ "resource": "" }
q243557
StepKwHazardCategory.set_widgets
train
def set_widgets(self): """Set widgets on the Hazard Category tab.""" self.clear_further_steps() # Set widgets self.lstHazardCategories.clear() self.lblDescribeHazardCategory.setText('') self.lblSelectHazardCategory.setText( hazard_category_question) ha...
python
{ "resource": "" }
q243558
polygonize
train
def polygonize(layer): """Polygonize a raster layer into a vector layer using GDAL. Issue https://github.com/inasafe/inasafe/issues/3183 :param layer: The layer to reproject. :type layer: QgsRasterLayer :return: Reprojected memory layer. :rtype: QgsRasterLayer .. versionadded:: 4.0 "...
python
{ "resource": "" }
q243559
DefaultValueParameter.value
train
def value(self, value): """Setter for value. :param value: The value. :type value: object """ # For custom value if value not in self.options: if len(self.labels) == len(self.options): self.options[-1] = value else: ...
python
{ "resource": "" }
q243560
mmi_ramp_roman
train
def mmi_ramp_roman(raster_layer): """Generate an mmi ramp using range of 1-10 on roman. A standarised range is used so that two shakemaps of different intensities can be properly compared visually with colours stretched accross the same range. The colours used are the 'standard' colours commonly s...
python
{ "resource": "" }
q243561
load_layer_from_registry
train
def load_layer_from_registry(layer_path): """Helper method to load a layer from registry if its already there. If the layer is not loaded yet, it will create the QgsMapLayer on the fly. :param layer_path: Layer source path. :type layer_path: str :return: Vector layer :rtype: QgsVectorLayer ...
python
{ "resource": "" }
q243562
reclassify_value
train
def reclassify_value(one_value, ranges): """This function will return the classified value according to ranges. The algorithm will return None if the continuous value has not any class. :param one_value: The continuous value to classify. :type one_value: float :param ranges: Classes, following th...
python
{ "resource": "" }
q243563
decode_full_layer_uri
train
def decode_full_layer_uri(full_layer_uri_string): """Decode the full layer URI. :param full_layer_uri_string: The full URI provided by our helper. :type full_layer_uri_string: basestring :return: A tuple with the QGIS URI and the provider key. :rtype: tuple """ if not full_layer_uri_string...
python
{ "resource": "" }
q243564
load_layer
train
def load_layer(full_layer_uri_string, name=None, provider=None): """Helper to load and return a single QGIS layer based on our layer URI. :param provider: The provider name to use if known to open the layer. Default to None, we will try to guess it, but it's much better if you can provide it. ...
python
{ "resource": "" }
q243565
load_layer_with_provider
train
def load_layer_with_provider(layer_uri, provider, layer_name='tmp'): """Load a layer with a specific driver. :param layer_uri: Layer URI that will be used by QGIS to load the layer. :type layer_uri: basestring :param provider: Provider name to use. :type provider: basestring :param layer_name...
python
{ "resource": "" }
q243566
load_layer_without_provider
train
def load_layer_without_provider(layer_uri, layer_name='tmp'): """Helper to load a layer when don't know the driver. Don't use it, it's an empiric function to try each provider one per one. OGR/GDAL is printing a lot of error saying that the layer is not valid. :param layer_uri: Layer URI that will be...
python
{ "resource": "" }
q243567
clip
train
def clip(layer_to_clip, mask_layer): """Clip a vector layer with another. Issue https://github.com/inasafe/inasafe/issues/3186 :param layer_to_clip: The vector layer to clip. :type layer_to_clip: QgsVectorLayer :param mask_layer: The vector layer to use for clipping. :type mask_layer: QgsVect...
python
{ "resource": "" }
q243568
download
train
def download( feature_type, output_base_path, extent, progress_dialog=None, server_url=None): """Download shapefiles from Kartoza server. .. versionadded:: 3.2 :param feature_type: What kind of features should be downloaded. Currently 'buildings', 'building-...
python
{ "resource": "" }
q243569
fetch_zip
train
def fetch_zip(url, output_path, feature_type, progress_dialog=None): """Download zip containing shp file and write to output_path. .. versionadded:: 3.2 :param url: URL of the zip bundle. :type url: str :param output_path: Path of output file, :type output_path: str :param feature_type: ...
python
{ "resource": "" }
q243570
extract_zip
train
def extract_zip(zip_path, destination_base_path): """Extract different extensions to the destination base path. Example : test.zip contains a.shp, a.dbf, a.prj and destination_base_path = '/tmp/CT-buildings Expected result : - /tmp/CT-buildings.shp - /tmp/CT-buildings.dbf - /tmp...
python
{ "resource": "" }
q243571
get_question_text
train
def get_question_text(constant): """Find a constant by name and return its value. :param constant: The name of the constant to look for. :type constant: string :returns: The value of the constant or red error message. :rtype: string """ if constant in dir(safe.gui.tools.wizard.wizard_strin...
python
{ "resource": "" }
q243572
layers_intersect
train
def layers_intersect(layer_a, layer_b): """Check if extents of two layers intersect. :param layer_a: One of the two layers to test overlapping :type layer_a: QgsMapLayer :param layer_b: The second of the two layers to test overlapping :type layer_b: QgsMapLayer :returns: true if the layers in...
python
{ "resource": "" }
q243573
get_inasafe_default_value_fields
train
def get_inasafe_default_value_fields(qsetting, field_key): """Obtain default value for a field with default value. By default it will return label list and default value list label: [Setting, Do not report, Custom] values: [Value from setting, None, Value from QSetting (if exist)] :param qsetting:...
python
{ "resource": "" }
q243574
clear_layout
train
def clear_layout(layout): """Clear layout content. :param layout: A layout. :type layout: QLayout """ # Different platform has different treatment # If InaSAFE running on Windows or Linux # Adapted from http://stackoverflow.com/a/9383780 if layout is not None: while layout.coun...
python
{ "resource": "" }
q243575
skip_inasafe_field
train
def skip_inasafe_field(layer, inasafe_fields): """Check if it possible to skip inasafe field step. The function will check if the layer has a specified field type. :param layer: A Qgis Vector Layer. :type layer: QgsVectorLayer :param inasafe_fields: List of non compulsory InaSAFE fields default. ...
python
{ "resource": "" }
q243576
get_image_path
train
def get_image_path(definition): """Helper to get path of image from a definition in resource directory. :param definition: A definition (hazard, exposure). :type definition: dict :returns: The definition's image path. :rtype: str """ path = resources_path( 'img', 'wizard', 'keyword...
python
{ "resource": "" }
q243577
recompute_counts
train
def recompute_counts(layer): """Recompute counts according to the size field and the new size. This function will also take care of updating the size field. The size post processor won't run after this function again. :param layer: The vector layer. :type layer: QgsVectorLayer :return: The la...
python
{ "resource": "" }
q243578
multi_exposure_aggregation_summary
train
def multi_exposure_aggregation_summary(aggregation, intermediate_layers): """Merge intermediate aggregations into one aggregation summary. Source layer : | aggr_id | aggr_name | count of affected features per exposure type Target layer : | aggregation_id | aggregation_name | Output layer : ...
python
{ "resource": "" }
q243579
ShakemapConverterDialog.on_output_path_textChanged
train
def on_output_path_textChanged(self): """Action when output file name is changed.""" output_path = self.output_path.text() output_not_xml_msg = tr('output file is not .tif') if output_path and not output_path.endswith('.tif'): self.warning_text.add(output_not_xml_msg) ...
python
{ "resource": "" }
q243580
ShakemapConverterDialog.on_input_path_textChanged
train
def on_input_path_textChanged(self): """Action when input file name is changed.""" input_path = self.input_path.text() input_not_grid_msg = tr('input file is not .xml') if input_path and not input_path.endswith('.xml'): self.warning_text.add(input_not_grid_msg) elif ...
python
{ "resource": "" }
q243581
ShakemapConverterDialog.prepare_place_layer
train
def prepare_place_layer(self): """Action when input place layer name is changed.""" if os.path.exists(self.input_place.text()): self.place_layer = QgsVectorLayer( self.input_place.text(), tr('Nearby Cities'), 'ogr' ) if ...
python
{ "resource": "" }
q243582
ShakemapConverterDialog.get_output_from_input
train
def get_output_from_input(self): """Create default output location based on input location.""" input_path = self.input_path.text() if input_path.endswith('.xml'): output_path = input_path[:-3] + 'tif' elif input_path == '': output_path = '' else: ...
python
{ "resource": "" }
q243583
ShakemapConverterDialog.accept
train
def accept(self): """Handler for when OK is clicked.""" input_path = self.input_path.text() input_title = self.line_edit_title.text() input_source = self.line_edit_source.text() output_path = self.output_path.text() if not output_path.endswith('.tif'): # noins...
python
{ "resource": "" }
q243584
ShakemapConverterDialog.on_open_input_tool_clicked
train
def on_open_input_tool_clicked(self): """Autoconnect slot activated when open input tool button is clicked. """ input_path = self.input_path.text() if not input_path: input_path = os.path.expanduser('~') # noinspection PyCallByClass,PyTypeChecker filename, __ ...
python
{ "resource": "" }
q243585
ShakemapConverterDialog.on_open_output_tool_clicked
train
def on_open_output_tool_clicked(self): """Autoconnect slot activated when open output tool button is clicked. """ output_path = self.output_path.text() if not output_path: output_path = os.path.expanduser('~') # noinspection PyCallByClass,PyTypeChecker filenam...
python
{ "resource": "" }
q243586
ShakemapConverterDialog.launch_keyword_wizard
train
def launch_keyword_wizard(self): """Launch keyword creation wizard.""" # make sure selected layer is the output layer if self.iface.activeLayer() != self.output_layer: return # launch wizard dialog keyword_wizard = WizardDialog( self.iface.mainWindow(), s...
python
{ "resource": "" }
q243587
union
train
def union(union_a, union_b): """Union of two vector layers. Issue https://github.com/inasafe/inasafe/issues/3186 :param union_a: The vector layer for the union. :type union_a: QgsVectorLayer :param union_b: The vector layer for the union. :type union_b: QgsVectorLayer :return: The clip v...
python
{ "resource": "" }
q243588
fill_hazard_class
train
def fill_hazard_class(layer): """We need to fill hazard class when it's empty. :param layer: The vector layer. :type layer: QgsVectorLayer :return: The updated vector layer. :rtype: QgsVectorLayer .. versionadded:: 4.0 """ hazard_field = layer.keywords['inasafe_fields'][hazard_class_f...
python
{ "resource": "" }
q243589
function
train
def function( receiver ): """Get function-like callable object for given receiver returns (function_or_method, codeObject, fromMethod) If fromMethod is true, then the callable already has its first argument bound """ if hasattr(receiver, '__call__'): # Reassign receiver to the actual m...
python
{ "resource": "" }
q243590
PrintReportDialog.populate_template_combobox
train
def populate_template_combobox(self, path, unwanted_templates=None): """Helper method for populating template combobox. :param unwanted_templates: List of templates that isn't an option. :type unwanted_templates: list .. versionadded: 4.3.0 """ templates_dir = QtCore.QD...
python
{ "resource": "" }
q243591
PrintReportDialog.retrieve_paths
train
def retrieve_paths(self, products, report_path, suffix=None): """Helper method to retrieve path from particular report metadata. :param products: Report products. :type products: list :param report_path: Path of the IF output. :type report_path: str :param suffix: Expe...
python
{ "resource": "" }
q243592
PrintReportDialog.open_as_pdf
train
def open_as_pdf(self): """Print the selected report as a PDF product. .. versionadded: 4.3.0 """ # Get output path from datastore report_urls_dict = report_urls(self.impact_function) # get report urls for each product tag as list for key, value in list(report_ur...
python
{ "resource": "" }
q243593
PrintReportDialog.open_in_composer
train
def open_in_composer(self): """Open in layout designer a given MapReport instance. .. versionadded: 4.3.0 """ impact_layer = self.impact_function.analysis_impacted report_path = dirname(impact_layer.source()) impact_report = self.impact_function.impact_report cu...
python
{ "resource": "" }
q243594
PrintReportDialog.prepare_components
train
def prepare_components(self): """Prepare components that are going to be generated based on user options. :return: Updated list of components. :rtype: dict """ # Register the components based on user option # First, tabular report generated_components = d...
python
{ "resource": "" }
q243595
PrintReportDialog.template_chooser_clicked
train
def template_chooser_clicked(self): """Slot activated when report file tool button is clicked. .. versionadded: 4.3.0 """ path = self.template_path.text() if not path: path = setting('lastCustomTemplate', '', str) if path: directory = dirname(path...
python
{ "resource": "" }
q243596
PrintReportDialog.toggle_template_selector
train
def toggle_template_selector(self): """Slot for template selector elements behaviour. .. versionadded: 4.3.0 """ if self.search_directory_radio.isChecked(): self.template_combo.setEnabled(True) else: self.template_combo.setEnabled(False) if self....
python
{ "resource": "" }
q243597
PrintReportDialog.show_help
train
def show_help(self): """Show usage info to the user. .. versionadded: 4.3.0 """ # Read the header and footer html snippets self.main_stacked_widget.setCurrentIndex(0) header = html_header() footer = html_footer() string = header message = impact...
python
{ "resource": "" }
q243598
limitations
train
def limitations(): """Get InaSAFE limitations. :return: All limitations on current InaSAFE. :rtype: list """ limitation_list = list() limitation_list.append(tr('InaSAFE is not a hazard modelling tool.')) limitation_list.append( tr('InaSAFE is a Free and Open Source Software (FOSS) p...
python
{ "resource": "" }
q243599
OsmDownloaderDialog.update_helper_political_level
train
def update_helper_political_level(self): """To update the helper about the country and the admin_level.""" current_country = self.country_comboBox.currentText() index = self.admin_level_comboBox.currentIndex() current_level = self.admin_level_comboBox.itemData(index) content = No...
python
{ "resource": "" }