repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
inasafe/inasafe
safe/report/expressions/infographic.py
minimum_needs_unit
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
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: ...
[ "def", "minimum_needs_unit", "(", "field", ",", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "field_definition", "=", "definition", "(", "field", ",", "'field_name'", ")", "if", "field_definition", ":", "unit_abbreviation", ...
Retrieve units of the given minimum needs field name. For instance: * minimum_needs_unit('minimum_needs__clean_water') -> 'l/weekly'
[ "Retrieve", "units", "of", "the", "given", "minimum", "needs", "field", "name", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L101-L138
train
26,800
inasafe/inasafe
safe/report/expressions/infographic.py
infographic_header_element
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
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['...
[ "def", "infographic_header_element", "(", "impact_function_name", ",", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "string_format", "=", "infographic_header", "[", "'string_format'", "]", "if", "impact_function_name", ":", "head...
Get a formatted infographic header sentence for an impact function. For instance: * infographic_header_element('flood') -> 'Estimated impact of a flood'
[ "Get", "a", "formatted", "infographic", "header", "sentence", "for", "an", "impact", "function", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L152-L164
train
26,801
inasafe/inasafe
safe/report/expressions/infographic.py
map_overview_header_element
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
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()
[ "def", "map_overview_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "map_overview_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve map overview header string from definitions.
[ "Retrieve", "map", "overview", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L177-L181
train
26,802
inasafe/inasafe
safe/report/expressions/infographic.py
population_chart_header_element
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
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()
[ "def", "population_chart_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "population_chart_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve population chart header string from definitions.
[ "Retrieve", "population", "chart", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L194-L198
train
26,803
inasafe/inasafe
safe/report/expressions/infographic.py
people_section_header_element
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
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()
[ "def", "people_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "people_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve people section header string from definitions.
[ "Retrieve", "people", "section", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L211-L215
train
26,804
inasafe/inasafe
safe/report/expressions/infographic.py
age_gender_section_header_element
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
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()
[ "def", "age_gender_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "age_gender_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve age gender section header string from definitions.
[ "Retrieve", "age", "gender", "section", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L228-L232
train
26,805
inasafe/inasafe
safe/report/expressions/infographic.py
vulnerability_section_header_element
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
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()
[ "def", "vulnerability_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "vulnerability_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve vulnerability section header string from definitions.
[ "Retrieve", "vulnerability", "section", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L263-L267
train
26,806
inasafe/inasafe
safe/report/expressions/infographic.py
female_vulnerability_section_header_element
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
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()
[ "def", "female_vulnerability_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "female_vulnerability_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ...
Retrieve female vulnerability section header string from definitions.
[ "Retrieve", "female", "vulnerability", "section", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L281-L285
train
26,807
inasafe/inasafe
safe/report/expressions/infographic.py
minimum_needs_section_header_element
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
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()
[ "def", "minimum_needs_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "minimum_needs_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize", "(", ")" ]
Retrieve minimum needs section header string from definitions.
[ "Retrieve", "minimum", "needs", "section", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L299-L303
train
26,808
inasafe/inasafe
safe/report/expressions/infographic.py
additional_minimum_needs_section_header_element
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
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()
[ "def", "additional_minimum_needs_section_header_element", "(", "feature", ",", "parent", ")", ":", "_", "=", "feature", ",", "parent", "# NOQA", "header", "=", "additional_minimum_needs_section_header", "[", "'string_format'", "]", "return", "header", ".", "capitalize",...
Retrieve additional minimum needs section header string from definitions.
[ "Retrieve", "additional", "minimum", "needs", "section", "header", "string", "from", "definitions", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/infographic.py#L317-L323
train
26,809
inasafe/inasafe
safe/common/parameters/resource_parameter.py
ResourceParameter.serialize
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
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...
[ "def", "serialize", "(", "self", ")", ":", "pickle", "=", "super", "(", "ResourceParameter", ",", "self", ")", ".", "serialize", "(", ")", "pickle", "[", "'frequency'", "]", "=", "self", ".", "frequency", "pickle", "[", "'unit'", "]", "=", "self", ".",...
Convert the parameter into a dictionary. :return: The parameter dictionary. :rtype: dict
[ "Convert", "the", "parameter", "into", "a", "dictionary", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/resource_parameter.py#L55-L64
train
26,810
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.reject
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
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...
[ "def", "reject", "(", "self", ")", ":", "if", "self", ".", "stacked_widget", ".", "currentWidget", "(", ")", "==", "self", ".", "resource_edit_page", ":", "self", ".", "edit_item", "=", "None", "self", ".", "switch_context", "(", "self", ".", "profile_edit...
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.com/AIFDR/inasafe/issues/138...
[ "Overload", "the", "base", "dialog", "reject", "event", "so", "we", "can", "handle", "state", "change", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L219-L232
train
26,811
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.populate_resource_list
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
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"])
[ "def", "populate_resource_list", "(", "self", ")", ":", "minimum_needs", "=", "self", ".", "minimum_needs", ".", "get_full_needs", "(", ")", "for", "full_resource", "in", "minimum_needs", "[", "\"resources\"", "]", ":", "self", ".", "add_resource", "(", "full_re...
Populate the list resource list.
[ "Populate", "the", "list", "resource", "list", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L234-L240
train
26,812
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.add_resource
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
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: ...
[ "def", "add_resource", "(", "self", ",", "resource", ")", ":", "updated_sentence", "=", "NeedsProfile", ".", "format_sentence", "(", "resource", "[", "'Readable sentence'", "]", ",", "resource", ")", "if", "self", ".", "edit_item", ":", "item", "=", "self", ...
Add a resource to the minimum needs table. :param resource: The resource to be added :type resource: dict
[ "Add", "a", "resource", "to", "the", "minimum", "needs", "table", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L247-L262
train
26,813
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.restore_defaults
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
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...
[ "def", "restore_defaults", "(", "self", ")", ":", "title", "=", "tr", "(", "'Restore defaults'", ")", "msg", "=", "tr", "(", "'Restoring defaults will overwrite your changes on profiles '", "'provided by InaSAFE. Do you want to continue ?'", ")", "# noinspection PyCallByClass",...
Restore defaults profiles.
[ "Restore", "defaults", "profiles", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L264-L284
train
26,814
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.load_profiles
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
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...
[ "def", "load_profiles", "(", "self", ",", "overwrite", "=", "False", ")", ":", "for", "profile", "in", "self", ".", "minimum_needs", ".", "get_profiles", "(", "overwrite", ")", ":", "self", ".", "profile_combo", ".", "addItem", "(", "profile", ")", "minimu...
Load the profiles into the dropdown list. :param overwrite: If we overwrite existing profiles from the plugin. :type overwrite: bool
[ "Load", "the", "profiles", "into", "the", "dropdown", "list", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L286-L296
train
26,815
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.select_profile
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
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...
[ "def", "select_profile", "(", "self", ",", "index", ")", ":", "new_profile", "=", "self", ".", "profile_combo", ".", "itemText", "(", "index", ")", "self", ".", "resources_list", ".", "clear", "(", ")", "self", ".", "minimum_needs", ".", "load_profile", "(...
Select a given profile by index. Slot for when profile is selected. :param index: The selected item's index :type index: int
[ "Select", "a", "given", "profile", "by", "index", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L298-L311
train
26,816
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.mark_current_profile_as_pending
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
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'))
[ "def", "mark_current_profile_as_pending", "(", "self", ")", ":", "index", "=", "self", ".", "profile_combo", ".", "currentIndex", "(", ")", "item", "=", "self", ".", "profile_combo", ".", "model", "(", ")", ".", "item", "(", "index", ")", "item", ".", "s...
Mark the current profile as pending by colouring the text red.
[ "Mark", "the", "current", "profile", "as", "pending", "by", "colouring", "the", "text", "red", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L321-L326
train
26,817
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.add_new_resource
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
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...
[ "def", "add_new_resource", "(", "self", ")", ":", "parameters_widget", "=", "[", "self", ".", "parameters_scrollarea", ".", "layout", "(", ")", ".", "itemAt", "(", "i", ")", "for", "i", "in", "range", "(", "self", ".", "parameters_scrollarea", ".", "layout...
Handle add new resource requests.
[ "Handle", "add", "new", "resource", "requests", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L335-L370
train
26,818
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.edit_resource
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
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: ...
[ "def", "edit_resource", "(", "self", ")", ":", "self", ".", "mark_current_profile_as_pending", "(", ")", "resource", "=", "None", "for", "item", "in", "self", ".", "resources_list", ".", "selectedItems", "(", ")", "[", ":", "1", "]", ":", "resource", "=", ...
Handle edit resource requests.
[ "Handle", "edit", "resource", "requests", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L372-L398
train
26,819
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.remove_resource
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
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))
[ "def", "remove_resource", "(", "self", ")", ":", "self", ".", "mark_current_profile_as_pending", "(", ")", "for", "item", "in", "self", ".", "resources_list", ".", "selectedItems", "(", ")", ":", "self", ".", "resources_list", ".", "takeItem", "(", "self", "...
Remove the currently selected resource.
[ "Remove", "the", "currently", "selected", "resource", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L569-L574
train
26,820
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.import_profile
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
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) ...
[ "def", "import_profile", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "file_name_dialog", "=", "QFileDialog", "(", "self", ")", "file_name_dialog", ".", "setAcceptMode", "(", "QFileDialog", ".", "AcceptOpen", ")", "file_name_dialog", ".", "setNam...
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.
[ "Import", "minimum", "needs", "from", "an", "existing", "json", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L642-L665
train
26,821
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.export_profile
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
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. ...
[ "def", "export_profile", "(", "self", ")", ":", "file_name_dialog", "=", "QFileDialog", "(", "self", ")", "file_name_dialog", ".", "setAcceptMode", "(", "QFileDialog", ".", "AcceptSave", ")", "file_name_dialog", ".", "setNameFilter", "(", "self", ".", "tr", "(",...
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.
[ "Export", "minimum", "needs", "to", "a", "json", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L667-L683
train
26,822
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.save_profile
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
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....
[ "def", "save_profile", "(", "self", ")", ":", "minimum_needs", "=", "{", "'resources'", ":", "[", "]", "}", "for", "index", "in", "range", "(", "self", ".", "resources_list", ".", "count", "(", ")", ")", ":", "item", "=", "self", ".", "resources_list",...
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.
[ "Save", "the", "current", "state", "of", "the", "minimum", "needs", "widget", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L685-L702
train
26,823
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.save_profile_as
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
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 (*....
[ "def", "save_profile_as", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "file_name_dialog", "=", "QFileDialog", "(", "self", ")", "file_name_dialog", ".", "setAcceptMode", "(", "QFileDialog", ".", "AcceptSave", ")", "file_name_dialog", ".", "setNa...
Save the minimum needs under a new profile name.
[ "Save", "the", "minimum", "needs", "under", "a", "new", "profile", "name", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L704-L734
train
26,824
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.new_profile
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
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, ...
[ "def", "new_profile", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "dir", "=", "os", ".", "path", ".", "join", "(", "QgsApplication", ".", "qgisSettingsDirPath", "(", ")", ",", "'inasafe'", ",", "'minimum_needs'", ")", "file_name", ",", "...
Create a new profile by name.
[ "Create", "a", "new", "profile", "by", "name", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L736-L763
train
26,825
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.page_changed
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
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() ...
[ "def", "page_changed", "(", "self", ",", "index", ")", ":", "if", "index", "==", "0", ":", "# profile edit page", "for", "item", "in", "self", ".", "resource_editing_buttons", ":", "item", ".", "hide", "(", ")", "for", "item", "in", "self", ".", "profile...
Slot for when tab changes in the stacked widget changes. :param index: Index of the now active tab. :type index: int
[ "Slot", "for", "when", "tab", "changes", "in", "the", "stacked", "widget", "changes", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L765-L784
train
26,826
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.switch_context
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
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...
[ "def", "switch_context", "(", "self", ",", "page", ")", ":", "# noinspection PyUnresolvedReferences", "if", "page", ".", "objectName", "(", ")", "==", "'profile_edit_page'", ":", "self", ".", "stacked_widget", ".", "setCurrentIndex", "(", "0", ")", "self", ".", ...
Switch context tabs by tab widget name. :param page: The page should be focussed. :type page: QWidget
[ "Switch", "context", "tabs", "by", "tab", "widget", "name", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L786-L799
train
26,827
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
NeedsManagerDialog.remove_profile
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
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...
[ "def", "remove_profile", "(", "self", ")", ":", "profile_name", "=", "self", ".", "profile_combo", ".", "currentText", "(", ")", "# noinspection PyTypeChecker", "button_selected", "=", "QMessageBox", ".", "warning", "(", "None", ",", "'Remove Profile'", ",", "self...
Remove the current profile. Make sure the user is sure.
[ "Remove", "the", "current", "profile", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L801-L820
train
26,828
inasafe/inasafe
safe/messaging/styles.py
logo_element
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
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...
[ "def", "logo_element", "(", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "resources_path", "(", ")", ",", "'img'", ",", "'logos'", ",", "'inasafe-logo.png'", ")", "url", "=", "urllib", ".", "parse", ".", "urljoin", "(", "'file:'", ",", ...
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
[ "Create", "a", "sanitised", "local", "url", "to", "the", "logo", "for", "insertion", "into", "html", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/styles.py#L116-L128
train
26,829
inasafe/inasafe
safe/messaging/item/image.py
Image.to_text
def to_text(self): """Render as plain text. """ if self.text == '': return '::%s' % self.uri return '::%s [%s]' % (self.text, self.uri)
python
def to_text(self): """Render as plain text. """ if self.text == '': return '::%s' % self.uri return '::%s [%s]' % (self.text, self.uri)
[ "def", "to_text", "(", "self", ")", ":", "if", "self", ".", "text", "==", "''", ":", "return", "'::%s'", "%", "self", ".", "uri", "return", "'::%s [%s]'", "%", "(", "self", ".", "text", ",", "self", ".", "uri", ")" ]
Render as plain text.
[ "Render", "as", "plain", "text", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/image.py#L56-L61
train
26,830
inasafe/inasafe
safe/utilities/qgis_utilities.py
display_information_message_bar
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
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 ...
[ "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 use qgis.utils.iface since it is not available in our test environment. :type iface_object: QgisInterface :param title: The title of the message bar. :type title: basestring :para...
[ "Display", "an", "information", "message", "bar", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/qgis_utilities.py#L30-L71
train
26,831
inasafe/inasafe
safe/utilities/qgis_utilities.py
display_warning_message_bar
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
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 ...
[ "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 :param message: The message inside the message bar. :type message: basestring :param more_details: The message inside the 'Show details' button. :type more_details: basestring :param button...
[ "Display", "a", "warning", "message", "bar", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/qgis_utilities.py#L132-L174
train
26,832
inasafe/inasafe
safe/utilities/qgis_utilities.py
display_critical_message_bar
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
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 ...
[ "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 :param message: The message inside the message bar. :type message: basestring :param more_details: The message inside the 'Show details' button. :type more_details: basestring :param butto...
[ "Display", "a", "critical", "message", "bar", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/qgis_utilities.py#L190-L233
train
26,833
inasafe/inasafe
safe/impact_function/style.py
hazard_class_style
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
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 ...
[ "def", "hazard_class_style", "(", "layer", ",", "classification", ",", "display_null", "=", "False", ")", ":", "categories", "=", "[", "]", "# Conditional styling", "attribute_table_styles", "=", "[", "]", "for", "hazard_class", ",", "(", "color", ",", "label", ...
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 :param classification: The hazard classification to use. :type clas...
[ "Set", "colors", "to", "the", "layer", "according", "to", "the", "hazard", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/style.py#L38-L83
train
26,834
inasafe/inasafe
safe/impact_function/style.py
layer_title
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
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...
[ "def", "layer_title", "(", "layer", ")", ":", "exposure_type", "=", "layer", ".", "keywords", "[", "'exposure_keywords'", "]", "[", "'exposure'", "]", "exposure_definitions", "=", "definition", "(", "exposure_type", ")", "title", "=", "exposure_definitions", "[", ...
Set the layer title according to the standards. :param layer: The layer to style. :type layer: QgsVectorLayer
[ "Set", "the", "layer", "title", "according", "to", "the", "standards", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/style.py#L86-L96
train
26,835
inasafe/inasafe
safe/impact_function/style.py
generate_classified_legend
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
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....
[ "def", "generate_classified_legend", "(", "analysis", ",", "exposure", ",", "hazard", ",", "use_rounding", ",", "debug_mode", ")", ":", "# We need to read the analysis layer to get the number of features.", "analysis_row", "=", "next", "(", "analysis", ".", "getFeatures", ...
Generate an ordered python structure with the classified symbology. :param analysis: The analysis layer. :type analysis: QgsVectorLayer :param exposure: The exposure layer. :type exposure: QgsVectorLayer :param hazard: The hazard layer. :type hazard: QgsVectorLayer :param use_rounding: B...
[ "Generate", "an", "ordered", "python", "structure", "with", "the", "classified", "symbology", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/style.py#L99-L220
train
26,836
inasafe/inasafe
safe/impact_function/style.py
_add_not_exposed
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
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...
[ "def", "_add_not_exposed", "(", "analysis_row", ",", "enable_rounding", ",", "is_population", ",", "exposure_unit", ",", "coefficient", ")", ":", "# We add the not exposed class at the end.", "not_exposed_field", "=", "(", "hazard_count_field", "[", "'field_name'", "]", "...
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 to do a rounding. :type enable_rounding: bool :param is_population: Flag if the number is population. It needs to be used with e...
[ "Helper", "to", "add", "the", "not", "exposed", "item", "to", "the", "legend", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/style.py#L223-L264
train
26,837
inasafe/inasafe
safe/impact_function/style.py
_format_label
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
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 ...
[ "def", "_format_label", "(", "hazard_class", ",", "value", ",", "exposure_unit", ",", "hazard_unit", "=", "None", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ")", ":", "# If the exposure unit is not null, we need to add a space.", "if", "exposure_unit", ...
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 number of features affected by this hazard class. :type value: float :param exposure_unit: The exposure unit. :type exposure_unit: basestring ...
[ "Helper", "function", "to", "format", "the", "label", "in", "the", "legend", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/style.py#L267-L331
train
26,838
inasafe/inasafe
safe/impact_function/style.py
simple_polygon_without_brush
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
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...
[ "def", "simple_polygon_without_brush", "(", "layer", ",", "width", "=", "'0.26'", ",", "color", "=", "QColor", "(", "'black'", ")", ")", ":", "registry", "=", "QgsApplication", ".", "symbolLayerRegistry", "(", ")", "line_metadata", "=", "registry", ".", "symbo...
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 width: Width to use for the line. Default to '0.26'. :type width: str
[ "Simple", "style", "to", "apply", "a", "border", "line", "only", "to", "a", "polygon", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/style.py#L334-L367
train
26,839
inasafe/inasafe
safe/messaging/item/table.py
Table.to_html
def to_html(self): """Render a Table MessageElement as html. :returns: The html representation of the Table MessageElement :rtype: basestring """ table = '<table%s>\n' % self.html_attributes() if self.caption is not None: if isinstance(self.caption, MessageEl...
python
def to_html(self): """Render a Table MessageElement as html. :returns: The html representation of the Table MessageElement :rtype: basestring """ table = '<table%s>\n' % self.html_attributes() if self.caption is not None: if isinstance(self.caption, MessageEl...
[ "def", "to_html", "(", "self", ")", ":", "table", "=", "'<table%s>\\n'", "%", "self", ".", "html_attributes", "(", ")", "if", "self", ".", "caption", "is", "not", "None", ":", "if", "isinstance", "(", "self", ".", "caption", ",", "MessageElement", ")", ...
Render a Table MessageElement as html. :returns: The html representation of the Table MessageElement :rtype: basestring
[ "Render", "a", "Table", "MessageElement", "as", "html", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/table.py#L59-L83
train
26,840
inasafe/inasafe
safe/messaging/item/table.py
Table.to_text
def to_text(self): """Render a Table MessageElement as plain text. :returns: The text representation of the Table MessageElement :rtype: basestring """ table = '' if self.caption is not None: table += '%s</caption>\n' % self.caption table += '\n' ...
python
def to_text(self): """Render a Table MessageElement as plain text. :returns: The text representation of the Table MessageElement :rtype: basestring """ table = '' if self.caption is not None: table += '%s</caption>\n' % self.caption table += '\n' ...
[ "def", "to_text", "(", "self", ")", ":", "table", "=", "''", "if", "self", ".", "caption", "is", "not", "None", ":", "table", "+=", "'%s</caption>\\n'", "%", "self", ".", "caption", "table", "+=", "'\\n'", "for", "row", "in", "self", ".", "rows", ":"...
Render a Table MessageElement as plain text. :returns: The text representation of the Table MessageElement :rtype: basestring
[ "Render", "a", "Table", "MessageElement", "as", "plain", "text", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/table.py#L85-L98
train
26,841
inasafe/inasafe
safe/gui/tools/wizard/step_kw57_extra_keywords.py
extra_keywords_to_widgets
def extra_keywords_to_widgets(extra_keyword_definition): """Create widgets for extra keyword. :param extra_keyword_definition: An extra keyword definition. :type extra_keyword_definition: dict :return: QCheckBox and The input widget :rtype: (QCheckBox, QWidget) """ # Check box check_bo...
python
def extra_keywords_to_widgets(extra_keyword_definition): """Create widgets for extra keyword. :param extra_keyword_definition: An extra keyword definition. :type extra_keyword_definition: dict :return: QCheckBox and The input widget :rtype: (QCheckBox, QWidget) """ # Check box check_bo...
[ "def", "extra_keywords_to_widgets", "(", "extra_keyword_definition", ")", ":", "# Check box", "check_box", "=", "QCheckBox", "(", "extra_keyword_definition", "[", "'name'", "]", ")", "check_box", ".", "setToolTip", "(", "extra_keyword_definition", "[", "'description'", ...
Create widgets for extra keyword. :param extra_keyword_definition: An extra keyword definition. :type extra_keyword_definition: dict :return: QCheckBox and The input widget :rtype: (QCheckBox, QWidget)
[ "Create", "widgets", "for", "extra", "keyword", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw57_extra_keywords.py#L173-L225
train
26,842
inasafe/inasafe
safe/gui/tools/wizard/step_kw57_extra_keywords.py
StepKwExtraKeywords.set_widgets
def set_widgets(self): """Set widgets on the extra keywords tab.""" self.clear() self.description_label.setText( 'In this step you can set some extra keywords for the layer. This ' 'keywords can be used for creating richer reporting or map.') subcategory = self.pa...
python
def set_widgets(self): """Set widgets on the extra keywords tab.""" self.clear() self.description_label.setText( 'In this step you can set some extra keywords for the layer. This ' 'keywords can be used for creating richer reporting or map.') subcategory = self.pa...
[ "def", "set_widgets", "(", "self", ")", ":", "self", ".", "clear", "(", ")", "self", ".", "description_label", ".", "setText", "(", "'In this step you can set some extra keywords for the layer. This '", "'keywords can be used for creating richer reporting or map.'", ")", "sub...
Set widgets on the extra keywords tab.
[ "Set", "widgets", "on", "the", "extra", "keywords", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw57_extra_keywords.py#L64-L87
train
26,843
inasafe/inasafe
safe/gui/tools/wizard/step_kw57_extra_keywords.py
StepKwExtraKeywords.get_extra_keywords
def get_extra_keywords(self): """Obtain extra keywords from the current state.""" extra_keywords = {} for key, widgets in list(self.widgets_dict.items()): if widgets[0].isChecked(): if isinstance(widgets[1], QLineEdit): extra_keywords[key] = widget...
python
def get_extra_keywords(self): """Obtain extra keywords from the current state.""" extra_keywords = {} for key, widgets in list(self.widgets_dict.items()): if widgets[0].isChecked(): if isinstance(widgets[1], QLineEdit): extra_keywords[key] = widget...
[ "def", "get_extra_keywords", "(", "self", ")", ":", "extra_keywords", "=", "{", "}", "for", "key", ",", "widgets", "in", "list", "(", "self", ".", "widgets_dict", ".", "items", "(", ")", ")", ":", "if", "widgets", "[", "0", "]", ".", "isChecked", "("...
Obtain extra keywords from the current state.
[ "Obtain", "extra", "keywords", "from", "the", "current", "state", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw57_extra_keywords.py#L113-L129
train
26,844
inasafe/inasafe
safe/gui/tools/wizard/step_kw57_extra_keywords.py
StepKwExtraKeywords.set_existing_extra_keywords
def set_existing_extra_keywords(self): """Set extra keywords from the value from metadata.""" extra_keywords = self.parent.get_existing_keyword('extra_keywords') for key, widgets in list(self.widgets_dict.items()): value = extra_keywords.get(key) if value is None: ...
python
def set_existing_extra_keywords(self): """Set extra keywords from the value from metadata.""" extra_keywords = self.parent.get_existing_keyword('extra_keywords') for key, widgets in list(self.widgets_dict.items()): value = extra_keywords.get(key) if value is None: ...
[ "def", "set_existing_extra_keywords", "(", "self", ")", ":", "extra_keywords", "=", "self", ".", "parent", ".", "get_existing_keyword", "(", "'extra_keywords'", ")", "for", "key", ",", "widgets", "in", "list", "(", "self", ".", "widgets_dict", ".", "items", "(...
Set extra keywords from the value from metadata.
[ "Set", "extra", "keywords", "from", "the", "value", "from", "metadata", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw57_extra_keywords.py#L131-L163
train
26,845
inasafe/inasafe
safe/gis/vector/tools.py
create_memory_layer
def create_memory_layer( layer_name, geometry, coordinate_reference_system=None, fields=None): """Create a vector memory layer. :param layer_name: The name of the layer. :type layer_name: str :param geometry: The geometry of the layer. :rtype geometry: QgsWkbTypes (note: ...
python
def create_memory_layer( layer_name, geometry, coordinate_reference_system=None, fields=None): """Create a vector memory layer. :param layer_name: The name of the layer. :type layer_name: str :param geometry: The geometry of the layer. :rtype geometry: QgsWkbTypes (note: ...
[ "def", "create_memory_layer", "(", "layer_name", ",", "geometry", ",", "coordinate_reference_system", "=", "None", ",", "fields", "=", "None", ")", ":", "if", "geometry", "==", "QgsWkbTypes", ".", "PointGeometry", ":", "wkb_type", "=", "QgsWkbTypes", ".", "Multi...
Create a vector memory layer. :param layer_name: The name of the layer. :type layer_name: str :param geometry: The geometry of the layer. :rtype geometry: QgsWkbTypes (note: from C++ QgsWkbTypes::GeometryType enum) :param coordinate_reference_system: The CRS of the memory lay...
[ "Create", "a", "vector", "memory", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L99-L153
train
26,846
inasafe/inasafe
safe/gis/vector/tools.py
copy_layer
def copy_layer(source, target): """Copy a vector layer to another one. :param source: The vector layer to copy. :type source: QgsVectorLayer :param target: The destination. :type source: QgsVectorLayer """ out_feature = QgsFeature() target.startEditing() request = QgsFeatureReques...
python
def copy_layer(source, target): """Copy a vector layer to another one. :param source: The vector layer to copy. :type source: QgsVectorLayer :param target: The destination. :type source: QgsVectorLayer """ out_feature = QgsFeature() target.startEditing() request = QgsFeatureReques...
[ "def", "copy_layer", "(", "source", ",", "target", ")", ":", "out_feature", "=", "QgsFeature", "(", ")", "target", ".", "startEditing", "(", ")", "request", "=", "QgsFeatureRequest", "(", ")", "aggregation_layer", "=", "False", "if", "source", ".", "keywords...
Copy a vector layer to another one. :param source: The vector layer to copy. :type source: QgsVectorLayer :param target: The destination. :type source: QgsVectorLayer
[ "Copy", "a", "vector", "layer", "to", "another", "one", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L157-L200
train
26,847
inasafe/inasafe
safe/gis/vector/tools.py
rename_fields
def rename_fields(layer, fields_to_copy): """Rename fields inside an attribute table. Only since QGIS 2.16. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """ for field in fields_to_copy: ...
python
def rename_fields(layer, fields_to_copy): """Rename fields inside an attribute table. Only since QGIS 2.16. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """ for field in fields_to_copy: ...
[ "def", "rename_fields", "(", "layer", ",", "fields_to_copy", ")", ":", "for", "field", "in", "fields_to_copy", ":", "index", "=", "layer", ".", "fields", "(", ")", ".", "lookupField", "(", "field", ")", "if", "index", "!=", "-", "1", ":", "layer", ".",...
Rename fields inside an attribute table. Only since QGIS 2.16. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict
[ "Rename", "fields", "inside", "an", "attribute", "table", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L204-L226
train
26,848
inasafe/inasafe
safe/gis/vector/tools.py
copy_fields
def copy_fields(layer, fields_to_copy): """Copy fields inside an attribute table. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """ for field in fields_to_copy: index = layer.fields().loo...
python
def copy_fields(layer, fields_to_copy): """Copy fields inside an attribute table. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict """ for field in fields_to_copy: index = layer.fields().loo...
[ "def", "copy_fields", "(", "layer", ",", "fields_to_copy", ")", ":", "for", "field", "in", "fields_to_copy", ":", "index", "=", "layer", ".", "fields", "(", ")", ".", "lookupField", "(", "field", ")", "if", "index", "!=", "-", "1", ":", "layer", ".", ...
Copy fields inside an attribute table. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_copy: Dictionary of fields to copy. :type fields_to_copy: dict
[ "Copy", "fields", "inside", "an", "attribute", "table", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L230-L261
train
26,849
inasafe/inasafe
safe/gis/vector/tools.py
remove_fields
def remove_fields(layer, fields_to_remove): """Remove fields from a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_remove: List of fields to remove. :type fields_to_remove: list """ index_to_remove = [] data_provider = layer.dataProvider() ...
python
def remove_fields(layer, fields_to_remove): """Remove fields from a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_remove: List of fields to remove. :type fields_to_remove: list """ index_to_remove = [] data_provider = layer.dataProvider() ...
[ "def", "remove_fields", "(", "layer", ",", "fields_to_remove", ")", ":", "index_to_remove", "=", "[", "]", "data_provider", "=", "layer", ".", "dataProvider", "(", ")", "for", "field", "in", "fields_to_remove", ":", "index", "=", "layer", ".", "fields", "(",...
Remove fields from a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param fields_to_remove: List of fields to remove. :type fields_to_remove: list
[ "Remove", "fields", "from", "a", "vector", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L265-L283
train
26,850
inasafe/inasafe
safe/gis/vector/tools.py
create_spatial_index
def create_spatial_index(layer): """Helper function to create the spatial index on a vector layer. This function is mainly used to see the processing time with the decorator. :param layer: The vector layer. :type layer: QgsVectorLayer :return: The index. :rtype: QgsSpatialIndex """ re...
python
def create_spatial_index(layer): """Helper function to create the spatial index on a vector layer. This function is mainly used to see the processing time with the decorator. :param layer: The vector layer. :type layer: QgsVectorLayer :return: The index. :rtype: QgsSpatialIndex """ re...
[ "def", "create_spatial_index", "(", "layer", ")", ":", "request", "=", "QgsFeatureRequest", "(", ")", ".", "setSubsetOfAttributes", "(", "[", "]", ")", "try", ":", "spatial_index", "=", "QgsSpatialIndex", "(", "layer", ".", "getFeatures", "(", "request", ")", ...
Helper function to create the spatial index on a vector layer. This function is mainly used to see the processing time with the decorator. :param layer: The vector layer. :type layer: QgsVectorLayer :return: The index. :rtype: QgsSpatialIndex
[ "Helper", "function", "to", "create", "the", "spatial", "index", "on", "a", "vector", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L287-L329
train
26,851
inasafe/inasafe
safe/gis/vector/tools.py
read_dynamic_inasafe_field
def read_dynamic_inasafe_field(inasafe_fields, dynamic_field, black_list=None): """Helper to read inasafe_fields using a dynamic field. :param inasafe_fields: inasafe_fields keywords to use. :type inasafe_fields: dict :param dynamic_field: The dynamic field to use. :type dynamic_field: safe.defini...
python
def read_dynamic_inasafe_field(inasafe_fields, dynamic_field, black_list=None): """Helper to read inasafe_fields using a dynamic field. :param inasafe_fields: inasafe_fields keywords to use. :type inasafe_fields: dict :param dynamic_field: The dynamic field to use. :type dynamic_field: safe.defini...
[ "def", "read_dynamic_inasafe_field", "(", "inasafe_fields", ",", "dynamic_field", ",", "black_list", "=", "None", ")", ":", "pattern", "=", "dynamic_field", "[", "'key'", "]", "pattern", "=", "pattern", ".", "replace", "(", "'%s'", ",", "''", ")", "if", "bla...
Helper to read inasafe_fields using a dynamic field. :param inasafe_fields: inasafe_fields keywords to use. :type inasafe_fields: dict :param dynamic_field: The dynamic field to use. :type dynamic_field: safe.definitions.fields :param black_list: A list of fields which are conflicting with the dy...
[ "Helper", "to", "read", "inasafe_fields", "using", "a", "dynamic", "field", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L396-L424
train
26,852
inasafe/inasafe
safe/gis/vector/tools.py
SizeCalculator.measure
def measure(self, geometry): """Measure the length or the area of a geometry. :param geometry: The geometry. :type geometry: QgsGeometry :return: The geometric size in the expected exposure unit. :rtype: float """ message = 'Size with NaN value : geometry valid=...
python
def measure(self, geometry): """Measure the length or the area of a geometry. :param geometry: The geometry. :type geometry: QgsGeometry :return: The geometric size in the expected exposure unit. :rtype: float """ message = 'Size with NaN value : geometry valid=...
[ "def", "measure", "(", "self", ",", "geometry", ")", ":", "message", "=", "'Size with NaN value : geometry valid={valid}, WKT={wkt}'", "feature_size", "=", "0", "if", "geometry", ".", "isMultipart", "(", ")", ":", "# Be careful, the size calculator is not working well on a"...
Measure the length or the area of a geometry. :param geometry: The geometry. :type geometry: QgsGeometry :return: The geometric size in the expected exposure unit. :rtype: float
[ "Measure", "the", "length", "or", "the", "area", "of", "a", "geometry", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L479-L524
train
26,853
inasafe/inasafe
safe/messaging/item/message_element.py
MessageElement._is_qstring
def _is_qstring(message): """Check if its a QString without adding any dep to PyQt5.""" my_class = str(message.__class__) my_class_name = my_class.replace('<class \'', '').replace('\'>', '') if my_class_name == 'PyQt5.QtCore.QString': return True return False
python
def _is_qstring(message): """Check if its a QString without adding any dep to PyQt5.""" my_class = str(message.__class__) my_class_name = my_class.replace('<class \'', '').replace('\'>', '') if my_class_name == 'PyQt5.QtCore.QString': return True return False
[ "def", "_is_qstring", "(", "message", ")", ":", "my_class", "=", "str", "(", "message", ".", "__class__", ")", "my_class_name", "=", "my_class", ".", "replace", "(", "'<class \\''", ",", "''", ")", ".", "replace", "(", "'\\'>'", ",", "''", ")", "if", "...
Check if its a QString without adding any dep to PyQt5.
[ "Check", "if", "its", "a", "QString", "without", "adding", "any", "dep", "to", "PyQt5", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/message_element.py#L57-L64
train
26,854
inasafe/inasafe
safe/messaging/item/message_element.py
MessageElement.html_attributes
def html_attributes(self): """Get extra html attributes such as id and class.""" extra_attributes = '' if self.element_id is not None: extra_attributes = ' id="%s"' % self.element_id if self.style_class is not None: extra_attributes = '%s class="%s"' % ( ...
python
def html_attributes(self): """Get extra html attributes such as id and class.""" extra_attributes = '' if self.element_id is not None: extra_attributes = ' id="%s"' % self.element_id if self.style_class is not None: extra_attributes = '%s class="%s"' % ( ...
[ "def", "html_attributes", "(", "self", ")", ":", "extra_attributes", "=", "''", "if", "self", ".", "element_id", "is", "not", "None", ":", "extra_attributes", "=", "' id=\"%s\"'", "%", "self", ".", "element_id", "if", "self", ".", "style_class", "is", "not",...
Get extra html attributes such as id and class.
[ "Get", "extra", "html", "attributes", "such", "as", "id", "and", "class", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/message_element.py#L119-L129
train
26,855
inasafe/inasafe
safe_extras/pydispatch/saferef.py
BoundMethodWeakref.calculateKey
def calculateKey( cls, target ): """Calculate the reference key for this reference Currently this is a two-tuple of the id()'s of the target object and the target function respectively. """ return (id(getattr(target,im_self)),id(getattr(target,im_func)))
python
def calculateKey( cls, target ): """Calculate the reference key for this reference Currently this is a two-tuple of the id()'s of the target object and the target function respectively. """ return (id(getattr(target,im_self)),id(getattr(target,im_func)))
[ "def", "calculateKey", "(", "cls", ",", "target", ")", ":", "return", "(", "id", "(", "getattr", "(", "target", ",", "im_self", ")", ")", ",", "id", "(", "getattr", "(", "target", ",", "im_func", ")", ")", ")" ]
Calculate the reference key for this reference Currently this is a two-tuple of the id()'s of the target object and the target function respectively.
[ "Calculate", "the", "reference", "key", "for", "this", "reference" ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/saferef.py#L131-L137
train
26,856
inasafe/inasafe
safe/gui/tools/wizard/wizard_step_browser.py
WizardStepBrowser.postgis_path_to_uri
def postgis_path_to_uri(path): """Convert layer path from QgsBrowserModel to full QgsDataSourceUri. :param path: The layer path from QgsBrowserModel :type path: string :returns: layer uri. :rtype: QgsDataSourceUri """ connection_name = path.split('/')[1] ...
python
def postgis_path_to_uri(path): """Convert layer path from QgsBrowserModel to full QgsDataSourceUri. :param path: The layer path from QgsBrowserModel :type path: string :returns: layer uri. :rtype: QgsDataSourceUri """ connection_name = path.split('/')[1] ...
[ "def", "postgis_path_to_uri", "(", "path", ")", ":", "connection_name", "=", "path", ".", "split", "(", "'/'", ")", "[", "1", "]", "schema", "=", "path", ".", "split", "(", "'/'", ")", "[", "2", "]", "table_name", "=", "path", ".", "split", "(", "'...
Convert layer path from QgsBrowserModel to full QgsDataSourceUri. :param path: The layer path from QgsBrowserModel :type path: string :returns: layer uri. :rtype: QgsDataSourceUri
[ "Convert", "layer", "path", "from", "QgsBrowserModel", "to", "full", "QgsDataSourceUri", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_step_browser.py#L88-L146
train
26,857
inasafe/inasafe
safe/gui/tools/wizard/wizard_step_browser.py
WizardStepBrowser.get_layer_description_from_browser
def get_layer_description_from_browser(self, category): """Obtain the description of the browser layer selected by user. :param category: The category of the layer to get the description. :type category: string :returns: Tuple of boolean and string. Boolean is true if layer is ...
python
def get_layer_description_from_browser(self, category): """Obtain the description of the browser layer selected by user. :param category: The category of the layer to get the description. :type category: string :returns: Tuple of boolean and string. Boolean is true if layer is ...
[ "def", "get_layer_description_from_browser", "(", "self", ",", "category", ")", ":", "if", "category", "==", "'hazard'", ":", "browser", "=", "self", ".", "tvBrowserHazard", "elif", "category", "==", "'exposure'", ":", "browser", "=", "self", ".", "tvBrowserExpo...
Obtain the description of the browser layer selected by user. :param category: The category of the layer to get the description. :type category: string :returns: Tuple of boolean and string. Boolean is true if layer is validated as compatible for current role (impact function and ...
[ "Obtain", "the", "description", "of", "the", "browser", "layer", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_step_browser.py#L314-L427
train
26,858
inasafe/inasafe
safe/gis/vector/reclassify.py
reclassify
def reclassify(layer, exposure_key=None): """Reclassify a continuous vector layer. This function will modify the input. For instance if you want to reclassify like this table : Original Value | Class - ∞ < val <= 0 | 1 0 < val <= 0.5 | 2 ...
python
def reclassify(layer, exposure_key=None): """Reclassify a continuous vector layer. This function will modify the input. For instance if you want to reclassify like this table : Original Value | Class - ∞ < val <= 0 | 1 0 < val <= 0.5 | 2 ...
[ "def", "reclassify", "(", "layer", ",", "exposure_key", "=", "None", ")", ":", "output_layer_name", "=", "reclassify_vector_steps", "[", "'output_layer_name'", "]", "output_layer_name", "=", "output_layer_name", "%", "layer", ".", "keywords", "[", "'title'", "]", ...
Reclassify a continuous vector layer. This function will modify the input. For instance if you want to reclassify like this table : Original Value | Class - ∞ < val <= 0 | 1 0 < val <= 0.5 | 2 0.5 < val <= 5 | 3 5 < va...
[ "Reclassify", "a", "continuous", "vector", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/reclassify.py#L24-L119
train
26,859
inasafe/inasafe
safe/gui/tools/wizard/step_kw30_field.py
StepKwField.on_lstFields_itemSelectionChanged
def on_lstFields_itemSelectionChanged(self): """Update field_names description label and unlock the Next button. .. note:: This is an automatic Qt slot executed when the field_names selection changes. """ self.clear_further_steps() field_names = self.selected_fields()...
python
def on_lstFields_itemSelectionChanged(self): """Update field_names description label and unlock the Next button. .. note:: This is an automatic Qt slot executed when the field_names selection changes. """ self.clear_further_steps() field_names = self.selected_fields()...
[ "def", "on_lstFields_itemSelectionChanged", "(", "self", ")", ":", "self", ".", "clear_further_steps", "(", ")", "field_names", "=", "self", ".", "selected_fields", "(", ")", "layer_purpose", "=", "self", ".", "parent", ".", "step_kw_purpose", ".", "selected_purpo...
Update field_names description label and unlock the Next button. .. note:: This is an automatic Qt slot executed when the field_names selection changes.
[ "Update", "field_names", "description", "label", "and", "unlock", "the", "Next", "button", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw30_field.py#L125-L183
train
26,860
inasafe/inasafe
safe/gui/tools/wizard/step_kw30_field.py
StepKwField.selected_fields
def selected_fields(self): """Obtain the fields selected by user. :returns: Keyword of the selected field. :rtype: list, str """ items = self.lstFields.selectedItems() if items and self.mode == MULTI_MODE: return [item.text() for item in items] elif i...
python
def selected_fields(self): """Obtain the fields selected by user. :returns: Keyword of the selected field. :rtype: list, str """ items = self.lstFields.selectedItems() if items and self.mode == MULTI_MODE: return [item.text() for item in items] elif i...
[ "def", "selected_fields", "(", "self", ")", ":", "items", "=", "self", ".", "lstFields", ".", "selectedItems", "(", ")", "if", "items", "and", "self", ".", "mode", "==", "MULTI_MODE", ":", "return", "[", "item", ".", "text", "(", ")", "for", "item", ...
Obtain the fields selected by user. :returns: Keyword of the selected field. :rtype: list, str
[ "Obtain", "the", "fields", "selected", "by", "user", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw30_field.py#L185-L197
train
26,861
inasafe/inasafe
safe/metadata35/provenance/provenance_step.py
ProvenanceStep.dict
def dict(self): """ the dict representation. :return: the dict :rtype: dict """ return { 'title': self.title, 'description': self.description, 'time': self.time.isoformat(), 'data': self.data() }
python
def dict(self): """ the dict representation. :return: the dict :rtype: dict """ return { 'title': self.title, 'description': self.description, 'time': self.time.isoformat(), 'data': self.data() }
[ "def", "dict", "(", "self", ")", ":", "return", "{", "'title'", ":", "self", ".", "title", ",", "'description'", ":", "self", ".", "description", ",", "'time'", ":", "self", ".", "time", ".", "isoformat", "(", ")", ",", "'data'", ":", "self", ".", ...
the dict representation. :return: the dict :rtype: dict
[ "the", "dict", "representation", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/provenance/provenance_step.py#L124-L137
train
26,862
inasafe/inasafe
safe/metadata35/provenance/provenance_step.py
ProvenanceStep._get_xml
def _get_xml(self, close_tag=True): """ generate the xml string representation. :param close_tag: should the '</provenance_step>' tag be added or not. :type close_tag: bool :return: the xml :rtype: str """ provenance_step_element = Element('provenance_s...
python
def _get_xml(self, close_tag=True): """ generate the xml string representation. :param close_tag: should the '</provenance_step>' tag be added or not. :type close_tag: bool :return: the xml :rtype: str """ provenance_step_element = Element('provenance_s...
[ "def", "_get_xml", "(", "self", ",", "close_tag", "=", "True", ")", ":", "provenance_step_element", "=", "Element", "(", "'provenance_step'", ",", "{", "'timestamp'", ":", "self", ".", "time", ".", "isoformat", "(", ")", "}", ")", "title", "=", "SubElement...
generate the xml string representation. :param close_tag: should the '</provenance_step>' tag be added or not. :type close_tag: bool :return: the xml :rtype: str
[ "generate", "the", "xml", "string", "representation", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/provenance/provenance_step.py#L150-L175
train
26,863
inasafe/inasafe
safe/report/processors/default.py
layout_item
def layout_item(layout, item_id, item_class): """Fetch a specific item according to its type in a layout. There's some sip casting conversion issues with QgsLayout::itemById. Don't use it, and use this function instead. See https://github.com/inasafe/inasafe/issues/4271 :param layout: The layout t...
python
def layout_item(layout, item_id, item_class): """Fetch a specific item according to its type in a layout. There's some sip casting conversion issues with QgsLayout::itemById. Don't use it, and use this function instead. See https://github.com/inasafe/inasafe/issues/4271 :param layout: The layout t...
[ "def", "layout_item", "(", "layout", ",", "item_id", ",", "item_class", ")", ":", "item", "=", "layout", ".", "itemById", "(", "item_id", ")", "if", "item", "is", "None", ":", "# no match!", "return", "item", "if", "issubclass", "(", "item_class", ",", "...
Fetch a specific item according to its type in a layout. There's some sip casting conversion issues with QgsLayout::itemById. Don't use it, and use this function instead. See https://github.com/inasafe/inasafe/issues/4271 :param layout: The layout to look in. :type layout: QgsLayout :param it...
[ "Fetch", "a", "specific", "item", "according", "to", "its", "type", "in", "a", "layout", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L60-L90
train
26,864
inasafe/inasafe
safe/report/processors/default.py
jinja2_renderer
def jinja2_renderer(impact_report, component): """Versatile text renderer using Jinja2 Template. Render using Jinja2 template. :param impact_report: ImpactReport contains data about the report that is going to be generated. :type impact_report: safe.report.impact_report.ImpactReport :para...
python
def jinja2_renderer(impact_report, component): """Versatile text renderer using Jinja2 Template. Render using Jinja2 template. :param impact_report: ImpactReport contains data about the report that is going to be generated. :type impact_report: safe.report.impact_report.ImpactReport :para...
[ "def", "jinja2_renderer", "(", "impact_report", ",", "component", ")", ":", "context", "=", "component", ".", "context", "main_template_folder", "=", "impact_report", ".", "metadata", ".", "template_folder", "loader", "=", "FileSystemLoader", "(", "os", ".", "path...
Versatile text renderer using Jinja2 Template. Render using Jinja2 template. :param impact_report: ImpactReport contains data about the report that is going to be generated. :type impact_report: safe.report.impact_report.ImpactReport :param component: Contains the component metadata and conte...
[ "Versatile", "text", "renderer", "using", "Jinja2", "Template", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L93-L143
train
26,865
inasafe/inasafe
safe/report/processors/default.py
create_qgis_pdf_output
def create_qgis_pdf_output( impact_report, output_path, layout, file_format, metadata): """Produce PDF output using QgsLayout. :param output_path: The output path. :type output_path: str :param layout: QGIS Layout object. :type layout: qgis.core.QgsPrintLayo...
python
def create_qgis_pdf_output( impact_report, output_path, layout, file_format, metadata): """Produce PDF output using QgsLayout. :param output_path: The output path. :type output_path: str :param layout: QGIS Layout object. :type layout: qgis.core.QgsPrintLayo...
[ "def", "create_qgis_pdf_output", "(", "impact_report", ",", "output_path", ",", "layout", ",", "file_format", ",", "metadata", ")", ":", "# make sure directory is created", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "output_path", ")", "if", "not", ...
Produce PDF output using QgsLayout. :param output_path: The output path. :type output_path: str :param layout: QGIS Layout object. :type layout: qgis.core.QgsPrintLayout :param qgis_composition_context: QGIS Composition context used by renderer. :type qgis_composition_context: safe.report.imp...
[ "Produce", "PDF", "output", "using", "QgsLayout", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L146-L211
train
26,866
inasafe/inasafe
safe/report/processors/default.py
create_qgis_template_output
def create_qgis_template_output(output_path, layout): """Produce QGIS Template output. :param output_path: The output path. :type output_path: str :param composition: QGIS Composition object to get template. values :type composition: qgis.core.QgsLayout :return: Generated output path....
python
def create_qgis_template_output(output_path, layout): """Produce QGIS Template output. :param output_path: The output path. :type output_path: str :param composition: QGIS Composition object to get template. values :type composition: qgis.core.QgsLayout :return: Generated output path....
[ "def", "create_qgis_template_output", "(", "output_path", ",", "layout", ")", ":", "# make sure directory is created", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "output_path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "dirname", ")...
Produce QGIS Template output. :param output_path: The output path. :type output_path: str :param composition: QGIS Composition object to get template. values :type composition: qgis.core.QgsLayout :return: Generated output path. :rtype: str
[ "Produce", "QGIS", "Template", "output", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L214-L236
train
26,867
inasafe/inasafe
safe/report/processors/default.py
qt_svg_to_png_renderer
def qt_svg_to_png_renderer(impact_report, component): """Render SVG into PNG. :param impact_report: ImpactReport contains data about the report that is going to be generated. :type impact_report: safe.report.impact_report.ImpactReport :param component: Contains the component metadata and conte...
python
def qt_svg_to_png_renderer(impact_report, component): """Render SVG into PNG. :param impact_report: ImpactReport contains data about the report that is going to be generated. :type impact_report: safe.report.impact_report.ImpactReport :param component: Contains the component metadata and conte...
[ "def", "qt_svg_to_png_renderer", "(", "impact_report", ",", "component", ")", ":", "context", "=", "component", ".", "context", "filepath", "=", "context", "[", "'filepath'", "]", "width", "=", "component", ".", "extra_args", "[", "'width'", "]", "height", "="...
Render SVG into PNG. :param impact_report: ImpactReport contains data about the report that is going to be generated. :type impact_report: safe.report.impact_report.ImpactReport :param component: Contains the component metadata and context for rendering the output. :type component: ...
[ "Render", "SVG", "into", "PNG", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L675-L713
train
26,868
inasafe/inasafe
safe/report/processors/default.py
atlas_renderer
def atlas_renderer(layout, coverage_layer, output_path, file_format): """Extract composition using atlas generation. :param layout: QGIS Print Layout object used for producing the report. :type layout: qgis.core.QgsPrintLayout :param coverage_layer: Coverage Layer used for atlas map. :type coverag...
python
def atlas_renderer(layout, coverage_layer, output_path, file_format): """Extract composition using atlas generation. :param layout: QGIS Print Layout object used for producing the report. :type layout: qgis.core.QgsPrintLayout :param coverage_layer: Coverage Layer used for atlas map. :type coverag...
[ "def", "atlas_renderer", "(", "layout", ",", "coverage_layer", ",", "output_path", ",", "file_format", ")", ":", "# set the composer map to be atlas driven", "composer_map", "=", "layout_item", "(", "layout", ",", "'impact-map'", ",", "QgsLayoutItemMap", ")", "composer_...
Extract composition using atlas generation. :param layout: QGIS Print Layout object used for producing the report. :type layout: qgis.core.QgsPrintLayout :param coverage_layer: Coverage Layer used for atlas map. :type coverage_layer: QgsMapLayer :param output_path: The output path of the product....
[ "Extract", "composition", "using", "atlas", "generation", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L716-L781
train
26,869
inasafe/inasafe
safe/gui/tools/geonode_uploader.py
GeonodeUploaderDialog.reset_defaults
def reset_defaults(self): """Reset login and password in QgsSettings.""" self.save_login.setChecked(False) self.save_password.setChecked(False) self.save_url.setChecked(False) set_setting(GEONODE_USER, '') set_setting(GEONODE_PASSWORD, '') set_setting(GEONODE_URL...
python
def reset_defaults(self): """Reset login and password in QgsSettings.""" self.save_login.setChecked(False) self.save_password.setChecked(False) self.save_url.setChecked(False) set_setting(GEONODE_USER, '') set_setting(GEONODE_PASSWORD, '') set_setting(GEONODE_URL...
[ "def", "reset_defaults", "(", "self", ")", ":", "self", ".", "save_login", ".", "setChecked", "(", "False", ")", "self", ".", "save_password", ".", "setChecked", "(", "False", ")", "self", ".", "save_url", ".", "setChecked", "(", "False", ")", "set_setting...
Reset login and password in QgsSettings.
[ "Reset", "login", "and", "password", "in", "QgsSettings", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/geonode_uploader.py#L105-L117
train
26,870
inasafe/inasafe
safe/gui/tools/geonode_uploader.py
GeonodeUploaderDialog.fill_layer_combo
def fill_layer_combo(self): """Fill layer combobox.""" project = QgsProject.instance() # MapLayers returns a QMap<QString id, QgsMapLayer layer> layers = list(project.mapLayers().values()) extensions = tuple(extension_siblings.keys()) for layer in layers: if ...
python
def fill_layer_combo(self): """Fill layer combobox.""" project = QgsProject.instance() # MapLayers returns a QMap<QString id, QgsMapLayer layer> layers = list(project.mapLayers().values()) extensions = tuple(extension_siblings.keys()) for layer in layers: if ...
[ "def", "fill_layer_combo", "(", "self", ")", ":", "project", "=", "QgsProject", ".", "instance", "(", ")", "# MapLayers returns a QMap<QString id, QgsMapLayer layer>", "layers", "=", "list", "(", "project", ".", "mapLayers", "(", ")", ".", "values", "(", ")", ")...
Fill layer combobox.
[ "Fill", "layer", "combobox", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/geonode_uploader.py#L119-L129
train
26,871
inasafe/inasafe
safe/gui/tools/geonode_uploader.py
GeonodeUploaderDialog.check_ok_button
def check_ok_button(self): """Helper to enable or not the OK button.""" login = self.login.text() password = self.password.text() url = self.url.text() if self.layers.count() >= 1 and login and password and url: self.ok_button.setEnabled(True) else: ...
python
def check_ok_button(self): """Helper to enable or not the OK button.""" login = self.login.text() password = self.password.text() url = self.url.text() if self.layers.count() >= 1 and login and password and url: self.ok_button.setEnabled(True) else: ...
[ "def", "check_ok_button", "(", "self", ")", ":", "login", "=", "self", ".", "login", ".", "text", "(", ")", "password", "=", "self", ".", "password", ".", "text", "(", ")", "url", "=", "self", ".", "url", ".", "text", "(", ")", "if", "self", ".",...
Helper to enable or not the OK button.
[ "Helper", "to", "enable", "or", "not", "the", "OK", "button", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/geonode_uploader.py#L131-L139
train
26,872
inasafe/inasafe
safe/gui/tools/geonode_uploader.py
GeonodeUploaderDialog.accept
def accept(self): """Upload the layer to Geonode.""" enable_busy_cursor() self.button_box.setEnabled(False) layer = layer_from_combo(self.layers) login = self.login.text() if self.save_login.isChecked(): set_setting(GEONODE_USER, login) else: ...
python
def accept(self): """Upload the layer to Geonode.""" enable_busy_cursor() self.button_box.setEnabled(False) layer = layer_from_combo(self.layers) login = self.login.text() if self.save_login.isChecked(): set_setting(GEONODE_USER, login) else: ...
[ "def", "accept", "(", "self", ")", ":", "enable_busy_cursor", "(", ")", "self", ".", "button_box", ".", "setEnabled", "(", "False", ")", "layer", "=", "layer_from_combo", "(", "self", ".", "layers", ")", "login", "=", "self", ".", "login", ".", "text", ...
Upload the layer to Geonode.
[ "Upload", "the", "layer", "to", "Geonode", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/geonode_uploader.py#L141-L199
train
26,873
inasafe/inasafe
safe/gis/vector/update_value_map.py
update_value_map
def update_value_map(layer, exposure_key=None): """Assign inasafe values according to definitions for a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param exposure_key: The exposure key. :type exposure_key: str :return: The classified vector layer. :rtype: Qg...
python
def update_value_map(layer, exposure_key=None): """Assign inasafe values according to definitions for a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param exposure_key: The exposure key. :type exposure_key: str :return: The classified vector layer. :rtype: Qg...
[ "def", "update_value_map", "(", "layer", ",", "exposure_key", "=", "None", ")", ":", "output_layer_name", "=", "assign_inasafe_values_steps", "[", "'output_layer_name'", "]", "output_layer_name", "=", "output_layer_name", "%", "layer", ".", "keywords", "[", "'layer_pu...
Assign inasafe values according to definitions for a vector layer. :param layer: The vector layer. :type layer: QgsVectorLayer :param exposure_key: The exposure key. :type exposure_key: str :return: The classified vector layer. :rtype: QgsVectorLayer .. versionadded:: 4.0
[ "Assign", "inasafe", "values", "according", "to", "definitions", "for", "a", "vector", "layer", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/update_value_map.py#L30-L132
train
26,874
inasafe/inasafe
safe/common/minimum_needs.py
MinimumNeeds.get_minimum_needs
def get_minimum_needs(self): """Get the minimum needed information about the minimum needs. That is the resource and the amount. :returns: minimum needs :rtype: OrderedDict """ minimum_needs = OrderedDict() for resource in self.minimum_needs['resources']: ...
python
def get_minimum_needs(self): """Get the minimum needed information about the minimum needs. That is the resource and the amount. :returns: minimum needs :rtype: OrderedDict """ minimum_needs = OrderedDict() for resource in self.minimum_needs['resources']: ...
[ "def", "get_minimum_needs", "(", "self", ")", ":", "minimum_needs", "=", "OrderedDict", "(", ")", "for", "resource", "in", "self", ".", "minimum_needs", "[", "'resources'", "]", ":", "if", "resource", "[", "'Unit abbreviation'", "]", ":", "name", "=", "'%s [...
Get the minimum needed information about the minimum needs. That is the resource and the amount. :returns: minimum needs :rtype: OrderedDict
[ "Get", "the", "minimum", "needed", "information", "about", "the", "minimum", "needs", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/minimum_needs.py#L53-L72
train
26,875
inasafe/inasafe
safe/common/minimum_needs.py
MinimumNeeds.set_need
def set_need(self, resource, amount, units, frequency='weekly'): """Append a single new minimum need entry to the list. :param resource: Minimum need resource name. :type resource: basestring :param amount: Amount per person per time interval :type amount: int, float :...
python
def set_need(self, resource, amount, units, frequency='weekly'): """Append a single new minimum need entry to the list. :param resource: Minimum need resource name. :type resource: basestring :param amount: Amount per person per time interval :type amount: int, float :...
[ "def", "set_need", "(", "self", ",", "resource", ",", "amount", ",", "units", ",", "frequency", "=", "'weekly'", ")", ":", "self", ".", "minimum_needs", "[", "'resources'", "]", ".", "append", "(", "{", "'Resource name'", ":", "resource", ",", "'Default'",...
Append a single new minimum need entry to the list. :param resource: Minimum need resource name. :type resource: basestring :param amount: Amount per person per time interval :type amount: int, float :param units: The unit that the resource is measured in. :type: bases...
[ "Append", "a", "single", "new", "minimum", "need", "entry", "to", "the", "list", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/minimum_needs.py#L83-L103
train
26,876
inasafe/inasafe
safe/common/minimum_needs.py
MinimumNeeds._defaults
def _defaults(cls): """Helper to get the default minimum needs. .. note:: Key names will be translated. """ minimum_needs = { "resources": [ { "Default": "2.8", "Minimum allowed": "0", "Maximum allow...
python
def _defaults(cls): """Helper to get the default minimum needs. .. note:: Key names will be translated. """ minimum_needs = { "resources": [ { "Default": "2.8", "Minimum allowed": "0", "Maximum allow...
[ "def", "_defaults", "(", "cls", ")", ":", "minimum_needs", "=", "{", "\"resources\"", ":", "[", "{", "\"Default\"", ":", "\"2.8\"", ",", "\"Minimum allowed\"", ":", "\"0\"", ",", "\"Maximum allowed\"", ":", "\"100\"", ",", "\"Frequency\"", ":", "\"weekly\"", "...
Helper to get the default minimum needs. .. note:: Key names will be translated.
[ "Helper", "to", "get", "the", "default", "minimum", "needs", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/minimum_needs.py#L125-L207
train
26,877
inasafe/inasafe
safe/common/minimum_needs.py
MinimumNeeds.read_from_file
def read_from_file(self, filename): """Read from an existing json file. :param filename: The file to be written to. :type filename: basestring, str :returns: Success status. -1 for unsuccessful 0 for success :rtype: int """ if not exists(filename): r...
python
def read_from_file(self, filename): """Read from an existing json file. :param filename: The file to be written to. :type filename: basestring, str :returns: Success status. -1 for unsuccessful 0 for success :rtype: int """ if not exists(filename): r...
[ "def", "read_from_file", "(", "self", ",", "filename", ")", ":", "if", "not", "exists", "(", "filename", ")", ":", "return", "-", "1", "with", "open", "(", "filename", ")", "as", "fd", ":", "needs_json", "=", "fd", ".", "read", "(", ")", "try", ":"...
Read from an existing json file. :param filename: The file to be written to. :type filename: basestring, str :returns: Success status. -1 for unsuccessful 0 for success :rtype: int
[ "Read", "from", "an", "existing", "json", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/minimum_needs.py#L209-L230
train
26,878
inasafe/inasafe
safe/common/minimum_needs.py
MinimumNeeds.write_to_file
def write_to_file(self, filename): """Write minimum needs as json to a file. :param filename: The file to be written to. :type filename: basestring, str """ if not exists(dirname(filename)): return -1 with open(filename, 'w') as fd: needs_json = j...
python
def write_to_file(self, filename): """Write minimum needs as json to a file. :param filename: The file to be written to. :type filename: basestring, str """ if not exists(dirname(filename)): return -1 with open(filename, 'w') as fd: needs_json = j...
[ "def", "write_to_file", "(", "self", ",", "filename", ")", ":", "if", "not", "exists", "(", "dirname", "(", "filename", ")", ")", ":", "return", "-", "1", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fd", ":", "needs_json", "=", "json", ...
Write minimum needs as json to a file. :param filename: The file to be written to. :type filename: basestring, str
[ "Write", "minimum", "needs", "as", "json", "to", "a", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/minimum_needs.py#L232-L243
train
26,879
inasafe/inasafe
safe/gui/tools/help/osm_downloader_help.py
osm_downloader_help
def osm_downloader_help(): """Help message for OSM Downloader dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content())...
python
def osm_downloader_help(): """Help message for OSM Downloader dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message """ message = m.Message() message.add(m.Brand()) message.add(heading()) message.add(content())...
[ "def", "osm_downloader_help", "(", ")", ":", "message", "=", "m", ".", "Message", "(", ")", "message", ".", "add", "(", "m", ".", "Brand", "(", ")", ")", "message", ".", "add", "(", "heading", "(", ")", ")", "message", ".", "add", "(", "content", ...
Help message for OSM Downloader dialog. .. versionadded:: 3.2.1 :returns: A message object containing helpful information. :rtype: messaging.message.Message
[ "Help", "message", "for", "OSM", "Downloader", "dialog", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/osm_downloader_help.py#L12-L25
train
26,880
inasafe/inasafe
safe/metadata35/provenance/provenance.py
Provenance.dict
def dict(self): """ the python object for rendering json. It is called dict to be coherent with the other modules but it actually returns a list :return: the python object for rendering json :rtype: list """ json_list = [] for step in self.steps...
python
def dict(self): """ the python object for rendering json. It is called dict to be coherent with the other modules but it actually returns a list :return: the python object for rendering json :rtype: list """ json_list = [] for step in self.steps...
[ "def", "dict", "(", "self", ")", ":", "json_list", "=", "[", "]", "for", "step", "in", "self", ".", "steps", ":", "json_list", ".", "append", "(", "step", ".", "dict", ")", "return", "json_list" ]
the python object for rendering json. It is called dict to be coherent with the other modules but it actually returns a list :return: the python object for rendering json :rtype: list
[ "the", "python", "object", "for", "rendering", "json", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/provenance/provenance.py#L45-L59
train
26,881
inasafe/inasafe
safe/metadata35/provenance/provenance.py
Provenance.append_step
def append_step(self, title, description, timestamp=None, data=None): """ Append a new provenance step. :param title: the title of the ProvenanceStep :type title: str :param description: the description of the ProvenanceStep :type description: str :param timest...
python
def append_step(self, title, description, timestamp=None, data=None): """ Append a new provenance step. :param title: the title of the ProvenanceStep :type title: str :param description: the description of the ProvenanceStep :type description: str :param timest...
[ "def", "append_step", "(", "self", ",", "title", ",", "description", ",", "timestamp", "=", "None", ",", "data", "=", "None", ")", ":", "step", "=", "ProvenanceStep", "(", "title", ",", "description", ",", "timestamp", ",", "data", ")", "self", ".", "_...
Append a new provenance step. :param title: the title of the ProvenanceStep :type title: str :param description: the description of the ProvenanceStep :type description: str :param timestamp: the time of the ProvenanceStep :type timestamp: datetime, None, str ...
[ "Append", "a", "new", "provenance", "step", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/provenance/provenance.py#L116-L137
train
26,882
inasafe/inasafe
safe/metadata35/provenance/provenance.py
Provenance.append_if_provenance_step
def append_if_provenance_step( self, title, description, timestamp=None, data=None): """Append a new IF provenance step. :param title: the title of the IF ProvenanceStep :type title: str :param description: the description of the IF ProvenanceStep :type description:...
python
def append_if_provenance_step( self, title, description, timestamp=None, data=None): """Append a new IF provenance step. :param title: the title of the IF ProvenanceStep :type title: str :param description: the description of the IF ProvenanceStep :type description:...
[ "def", "append_if_provenance_step", "(", "self", ",", "title", ",", "description", ",", "timestamp", "=", "None", ",", "data", "=", "None", ")", ":", "step", "=", "IFProvenanceStep", "(", "title", ",", "description", ",", "timestamp", ",", "data", ")", "se...
Append a new IF provenance step. :param title: the title of the IF ProvenanceStep :type title: str :param description: the description of the IF ProvenanceStep :type description: str :param timestamp: the time of the IF ProvenanceStep :type timestamp: datetime, None ...
[ "Append", "a", "new", "IF", "provenance", "step", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/provenance/provenance.py#L139-L160
train
26,883
inasafe/inasafe
safe/gis/vector/assign_highest_value.py
assign_highest_value
def assign_highest_value(exposure, hazard): """Assign the highest hazard value to an indivisible feature. For indivisible polygon exposure layers such as buildings, we need to assigned the greatest hazard that each polygon touches and use that as the effective hazard class. Issue https://github.co...
python
def assign_highest_value(exposure, hazard): """Assign the highest hazard value to an indivisible feature. For indivisible polygon exposure layers such as buildings, we need to assigned the greatest hazard that each polygon touches and use that as the effective hazard class. Issue https://github.co...
[ "def", "assign_highest_value", "(", "exposure", ",", "hazard", ")", ":", "output_layer_name", "=", "assign_highest_value_steps", "[", "'output_layer_name'", "]", "hazard_inasafe_fields", "=", "hazard", ".", "keywords", "[", "'inasafe_fields'", "]", "if", "not", "hazar...
Assign the highest hazard value to an indivisible feature. For indivisible polygon exposure layers such as buildings, we need to assigned the greatest hazard that each polygon touches and use that as the effective hazard class. Issue https://github.com/inasafe/inasafe/issues/3192 We follow the co...
[ "Assign", "the", "highest", "hazard", "value", "to", "an", "indivisible", "feature", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/assign_highest_value.py#L33-L142
train
26,884
inasafe/inasafe
setup.py
get_version
def get_version(): """Obtain InaSAFE's version from version file. :returns: The current version number. :rtype: str """ # Get location of application wide version info root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) version_file = os.path.join(root_dir, 'safe', 'definit...
python
def get_version(): """Obtain InaSAFE's version from version file. :returns: The current version number. :rtype: str """ # Get location of application wide version info root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) version_file = os.path.join(root_dir, 'safe', 'definit...
[ "def", "get_version", "(", ")", ":", "# Get location of application wide version info", "root_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", ")", "versio...
Obtain InaSAFE's version from version file. :returns: The current version number. :rtype: str
[ "Obtain", "InaSAFE", "s", "version", "from", "version", "file", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/setup.py#L13-L34
train
26,885
inasafe/inasafe
safe/gui/tools/wizard/step_kw65_summary.py
StepKwSummary.set_widgets
def set_widgets(self): """Set widgets on the Keywords Summary tab.""" current_keywords = self.parent.get_keywords() current_keywords[inasafe_keyword_version_key] = inasafe_keyword_version header_path = resources_path('header.html') footer_path = resources_path('footer.html') ...
python
def set_widgets(self): """Set widgets on the Keywords Summary tab.""" current_keywords = self.parent.get_keywords() current_keywords[inasafe_keyword_version_key] = inasafe_keyword_version header_path = resources_path('header.html') footer_path = resources_path('footer.html') ...
[ "def", "set_widgets", "(", "self", ")", ":", "current_keywords", "=", "self", ".", "parent", ".", "get_keywords", "(", ")", "current_keywords", "[", "inasafe_keyword_version_key", "]", "=", "inasafe_keyword_version", "header_path", "=", "resources_path", "(", "'head...
Set widgets on the Keywords Summary tab.
[ "Set", "widgets", "on", "the", "Keywords", "Summary", "tab", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw65_summary.py#L105-L142
train
26,886
inasafe/inasafe
safe/common/parameters/default_value_parameter_widget.py
DefaultValueParameterWidget.raise_invalid_type_exception
def raise_invalid_type_exception(self): """Raise invalid type.""" message = 'Expecting element type of %s' % ( self._parameter.element_type.__name__) err = ValueError(message) return err
python
def raise_invalid_type_exception(self): """Raise invalid type.""" message = 'Expecting element type of %s' % ( self._parameter.element_type.__name__) err = ValueError(message) return err
[ "def", "raise_invalid_type_exception", "(", "self", ")", ":", "message", "=", "'Expecting element type of %s'", "%", "(", "self", ".", "_parameter", ".", "element_type", ".", "__name__", ")", "err", "=", "ValueError", "(", "message", ")", "return", "err" ]
Raise invalid type.
[ "Raise", "invalid", "type", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_value_parameter_widget.py#L70-L75
train
26,887
inasafe/inasafe
safe/common/parameters/default_value_parameter_widget.py
DefaultValueParameterWidget.set_value
def set_value(self, value): """Set value by item's string. :param value: The value. :type value: str, int :returns: True if success, else False. :rtype: bool """ # Find index of choice try: value_index = self._parameter.options.index(value) ...
python
def set_value(self, value): """Set value by item's string. :param value: The value. :type value: str, int :returns: True if success, else False. :rtype: bool """ # Find index of choice try: value_index = self._parameter.options.index(value) ...
[ "def", "set_value", "(", "self", ",", "value", ")", ":", "# Find index of choice", "try", ":", "value_index", "=", "self", ".", "_parameter", ".", "options", ".", "index", "(", "value", ")", "self", ".", "input_button_group", ".", "button", "(", "value_index...
Set value by item's string. :param value: The value. :type value: str, int :returns: True if success, else False. :rtype: bool
[ "Set", "value", "by", "item", "s", "string", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_value_parameter_widget.py#L99-L118
train
26,888
inasafe/inasafe
safe/common/parameters/default_value_parameter_widget.py
DefaultValueParameterWidget.toggle_custom_value
def toggle_custom_value(self): """Enable or disable the custom value line edit.""" radio_button_checked_id = self.input_button_group.checkedId() if (radio_button_checked_id == len(self._parameter.options) - 1): self.custom_value.setDisabled(False) else: ...
python
def toggle_custom_value(self): """Enable or disable the custom value line edit.""" radio_button_checked_id = self.input_button_group.checkedId() if (radio_button_checked_id == len(self._parameter.options) - 1): self.custom_value.setDisabled(False) else: ...
[ "def", "toggle_custom_value", "(", "self", ")", ":", "radio_button_checked_id", "=", "self", ".", "input_button_group", ".", "checkedId", "(", ")", "if", "(", "radio_button_checked_id", "==", "len", "(", "self", ".", "_parameter", ".", "options", ")", "-", "1"...
Enable or disable the custom value line edit.
[ "Enable", "or", "disable", "the", "custom", "value", "line", "edit", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/common/parameters/default_value_parameter_widget.py#L120-L127
train
26,889
inasafe/inasafe
safe/utilities/profiling.py
Tree.ended
def ended(self): """We call this method when the function is finished.""" self._end_time = time.time() if setting(key='memory_profile', expected_type=bool): self._end_memory = get_free_memory()
python
def ended(self): """We call this method when the function is finished.""" self._end_time = time.time() if setting(key='memory_profile', expected_type=bool): self._end_memory = get_free_memory()
[ "def", "ended", "(", "self", ")", ":", "self", ".", "_end_time", "=", "time", ".", "time", "(", ")", "if", "setting", "(", "key", "=", "'memory_profile'", ",", "expected_type", "=", "bool", ")", ":", "self", ".", "_end_memory", "=", "get_free_memory", ...
We call this method when the function is finished.
[ "We", "call", "this", "method", "when", "the", "function", "is", "finished", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/profiling.py#L48-L53
train
26,890
inasafe/inasafe
safe/utilities/profiling.py
Tree.elapsed_time
def elapsed_time(self): """To know the duration of the function. This property might return None if the function is still running. """ if self._end_time: elapsed_time = round(self._end_time - self._start_time, 3) return elapsed_time else: retu...
python
def elapsed_time(self): """To know the duration of the function. This property might return None if the function is still running. """ if self._end_time: elapsed_time = round(self._end_time - self._start_time, 3) return elapsed_time else: retu...
[ "def", "elapsed_time", "(", "self", ")", ":", "if", "self", ".", "_end_time", ":", "elapsed_time", "=", "round", "(", "self", ".", "_end_time", "-", "self", ".", "_start_time", ",", "3", ")", "return", "elapsed_time", "else", ":", "return", "None" ]
To know the duration of the function. This property might return None if the function is still running.
[ "To", "know", "the", "duration", "of", "the", "function", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/profiling.py#L56-L65
train
26,891
inasafe/inasafe
safe/utilities/profiling.py
Tree.memory_used
def memory_used(self): """To know the allocated memory at function termination. ..versionadded:: 4.1 This property might return None if the function is still running. This function should help to show memory leaks or ram greedy code. """ if self._end_memory: ...
python
def memory_used(self): """To know the allocated memory at function termination. ..versionadded:: 4.1 This property might return None if the function is still running. This function should help to show memory leaks or ram greedy code. """ if self._end_memory: ...
[ "def", "memory_used", "(", "self", ")", ":", "if", "self", ".", "_end_memory", ":", "memory_used", "=", "self", ".", "_end_memory", "-", "self", ".", "_start_memory", "return", "memory_used", "else", ":", "return", "None" ]
To know the allocated memory at function termination. ..versionadded:: 4.1 This property might return None if the function is still running. This function should help to show memory leaks or ram greedy code.
[ "To", "know", "the", "allocated", "memory", "at", "function", "termination", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/profiling.py#L68-L81
train
26,892
inasafe/inasafe
safe/utilities/profiling.py
Tree.append
def append(self, node): """To append a new child.""" if node.parent == self.key and not self.elapsed_time: self.children.append(node) else: # Recursive call for child in self.children: if not child.elapsed_time: child.append...
python
def append(self, node): """To append a new child.""" if node.parent == self.key and not self.elapsed_time: self.children.append(node) else: # Recursive call for child in self.children: if not child.elapsed_time: child.append...
[ "def", "append", "(", "self", ",", "node", ")", ":", "if", "node", ".", "parent", "==", "self", ".", "key", "and", "not", "self", ".", "elapsed_time", ":", "self", ".", "children", ".", "append", "(", "node", ")", "else", ":", "# Recursive call", "fo...
To append a new child.
[ "To", "append", "a", "new", "child", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/profiling.py#L83-L91
train
26,893
inasafe/inasafe
safe/impact_function/provenance_utilities.py
get_map_title
def get_map_title(hazard, exposure, hazard_category): """Helper to get map title. :param hazard: A hazard definition. :type hazard: dict :param exposure: An exposure definition. :type exposure: dict :param hazard_category: A hazard category definition. :type hazard_category: dict :re...
python
def get_map_title(hazard, exposure, hazard_category): """Helper to get map title. :param hazard: A hazard definition. :type hazard: dict :param exposure: An exposure definition. :type exposure: dict :param hazard_category: A hazard category definition. :type hazard_category: dict :re...
[ "def", "get_map_title", "(", "hazard", ",", "exposure", ",", "hazard_category", ")", ":", "if", "hazard", "==", "hazard_generic", ":", "map_title", "=", "tr", "(", "'{exposure_name} affected'", ")", ".", "format", "(", "exposure_name", "=", "exposure", "[", "'...
Helper to get map title. :param hazard: A hazard definition. :type hazard: dict :param exposure: An exposure definition. :type exposure: dict :param hazard_category: A hazard category definition. :type hazard_category: dict :returns: Map title based on the input. :rtype: str
[ "Helper", "to", "get", "map", "title", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/provenance_utilities.py#L16-L45
train
26,894
inasafe/inasafe
safe/impact_function/provenance_utilities.py
get_analysis_question
def get_analysis_question(hazard, exposure): """Construct analysis question based on hazard and exposure. :param hazard: A hazard definition. :type hazard: dict :param exposure: An exposure definition. :type exposure: dict :returns: Analysis question based on reporting standards. :rtype: ...
python
def get_analysis_question(hazard, exposure): """Construct analysis question based on hazard and exposure. :param hazard: A hazard definition. :type hazard: dict :param exposure: An exposure definition. :type exposure: dict :returns: Analysis question based on reporting standards. :rtype: ...
[ "def", "get_analysis_question", "(", "hazard", ",", "exposure", ")", ":", "# First we look for a translated hardcoded question.", "question", "=", "specific_analysis_question", "(", "hazard", ",", "exposure", ")", "if", "question", ":", "return", "question", "if", "haza...
Construct analysis question based on hazard and exposure. :param hazard: A hazard definition. :type hazard: dict :param exposure: An exposure definition. :type exposure: dict :returns: Analysis question based on reporting standards. :rtype: str
[ "Construct", "analysis", "question", "based", "on", "hazard", "and", "exposure", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/provenance_utilities.py#L48-L81
train
26,895
inasafe/inasafe
safe/impact_function/provenance_utilities.py
get_multi_exposure_analysis_question
def get_multi_exposure_analysis_question(hazard, exposures): """Construct analysis question based on hazard and exposures. :param hazard: A hazard definition. :type hazard: dict :param exposure: A list of exposure definition. :type exposure: list :returns: Analysis question based on reporting...
python
def get_multi_exposure_analysis_question(hazard, exposures): """Construct analysis question based on hazard and exposures. :param hazard: A hazard definition. :type hazard: dict :param exposure: A list of exposure definition. :type exposure: list :returns: Analysis question based on reporting...
[ "def", "get_multi_exposure_analysis_question", "(", "hazard", ",", "exposures", ")", ":", "exposures_question", "=", "''", "exposure_format", "=", "'{exposure_measure} {exposure_name}'", "for", "index", ",", "exposure", "in", "enumerate", "(", "exposures", ")", ":", "...
Construct analysis question based on hazard and exposures. :param hazard: A hazard definition. :type hazard: dict :param exposure: A list of exposure definition. :type exposure: list :returns: Analysis question based on reporting standards. :rtype: str
[ "Construct", "analysis", "question", "based", "on", "hazard", "and", "exposures", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/provenance_utilities.py#L84-L120
train
26,896
inasafe/inasafe
safe/messaging/message.py
Message.add
def add(self, message): """Add a MessageElement to the end of the queue. Strings can be passed and are automatically converted in to item.Text() :param message: An element to add to the message queue. :type message: safe.messaging.Message, MessageElement, str """ ...
python
def add(self, message): """Add a MessageElement to the end of the queue. Strings can be passed and are automatically converted in to item.Text() :param message: An element to add to the message queue. :type message: safe.messaging.Message, MessageElement, str """ ...
[ "def", "add", "(", "self", ",", "message", ")", ":", "if", "self", ".", "_is_stringable", "(", "message", ")", "or", "self", ".", "_is_qstring", "(", "message", ")", ":", "self", ".", "message", ".", "append", "(", "Text", "(", "message", ")", ")", ...
Add a MessageElement to the end of the queue. Strings can be passed and are automatically converted in to item.Text() :param message: An element to add to the message queue. :type message: safe.messaging.Message, MessageElement, str
[ "Add", "a", "MessageElement", "to", "the", "end", "of", "the", "queue", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/message.py#L61-L78
train
26,897
inasafe/inasafe
safe/messaging/message.py
Message.prepend
def prepend(self, message): """Prepend a MessageElement to the beginning of the queue. Strings can be passed and are automatically converted in to item.Text() :param message: An element to add to the message queue. :type message: safe.messaging.Message, MessageElement, str ...
python
def prepend(self, message): """Prepend a MessageElement to the beginning of the queue. Strings can be passed and are automatically converted in to item.Text() :param message: An element to add to the message queue. :type message: safe.messaging.Message, MessageElement, str ...
[ "def", "prepend", "(", "self", ",", "message", ")", ":", "if", "self", ".", "_is_stringable", "(", "message", ")", "or", "self", ".", "_is_qstring", "(", "message", ")", ":", "self", ".", "message", ".", "appendleft", "(", "Text", "(", "message", ")", ...
Prepend a MessageElement to the beginning of the queue. Strings can be passed and are automatically converted in to item.Text() :param message: An element to add to the message queue. :type message: safe.messaging.Message, MessageElement, str
[ "Prepend", "a", "MessageElement", "to", "the", "beginning", "of", "the", "queue", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/message.py#L80-L97
train
26,898
inasafe/inasafe
safe/messaging/message.py
Message.to_text
def to_text(self): """Render a MessageElement queue as plain text. :returns: Plain text representation of the message. :rtype: str """ message = '' last_was_text = False for m in self.message: if last_was_text and not isinstance(m, Text): ...
python
def to_text(self): """Render a MessageElement queue as plain text. :returns: Plain text representation of the message. :rtype: str """ message = '' last_was_text = False for m in self.message: if last_was_text and not isinstance(m, Text): ...
[ "def", "to_text", "(", "self", ")", ":", "message", "=", "''", "last_was_text", "=", "False", "for", "m", "in", "self", ".", "message", ":", "if", "last_was_text", "and", "not", "isinstance", "(", "m", ",", "Text", ")", ":", "message", "+=", "'\\n'", ...
Render a MessageElement queue as plain text. :returns: Plain text representation of the message. :rtype: str
[ "Render", "a", "MessageElement", "queue", "as", "plain", "text", "." ]
831d60abba919f6d481dc94a8d988cc205130724
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/message.py#L111-L130
train
26,899