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/gui/widgets/message_viewer.py | MessageViewer.dynamic_message_event | def dynamic_message_event(self, sender, message):
"""Dynamic event handler - set message state based on event.
Dynamic messages don't clear the message buffer.
:param sender: Unused - the object that sent the message.
:type sender: Object, None
:param message: A message to sho... | python | def dynamic_message_event(self, sender, message):
"""Dynamic event handler - set message state based on event.
Dynamic messages don't clear the message buffer.
:param sender: Unused - the object that sent the message.
:type sender: Object, None
:param message: A message to sho... | [
"def",
"dynamic_message_event",
"(",
"self",
",",
"sender",
",",
"message",
")",
":",
"# LOGGER.debug('Dynamic message event')",
"_",
"=",
"sender",
"# NOQA",
"self",
".",
"dynamic_messages",
".",
"append",
"(",
"message",
")",
"self",
".",
"dynamic_messages_log",
... | Dynamic event handler - set message state based on event.
Dynamic messages don't clear the message buffer.
:param sender: Unused - the object that sent the message.
:type sender: Object, None
:param message: A message to show in the viewer.
:type message: safe.messaging.Messag... | [
"Dynamic",
"event",
"handler",
"-",
"set",
"message",
"state",
"based",
"on",
"event",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L222-L239 | train | 27,300 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.to_message | def to_message(self):
"""Collate all message elements to a single message."""
my_message = m.Message()
if self.static_message is not None:
my_message.add(self.static_message)
for myDynamic in self.dynamic_messages:
my_message.add(myDynamic)
return my_messa... | python | def to_message(self):
"""Collate all message elements to a single message."""
my_message = m.Message()
if self.static_message is not None:
my_message.add(self.static_message)
for myDynamic in self.dynamic_messages:
my_message.add(myDynamic)
return my_messa... | [
"def",
"to_message",
"(",
"self",
")",
":",
"my_message",
"=",
"m",
".",
"Message",
"(",
")",
"if",
"self",
".",
"static_message",
"is",
"not",
"None",
":",
"my_message",
".",
"add",
"(",
"self",
".",
"static_message",
")",
"for",
"myDynamic",
"in",
"s... | Collate all message elements to a single message. | [
"Collate",
"all",
"message",
"elements",
"to",
"a",
"single",
"message",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L305-L312 | train | 27,301 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.save_report_to_html | def save_report_to_html(self):
"""Save report in the dock to html."""
html = self.page().mainFrame().toHtml()
if self.report_path is not None:
html_to_file(html, self.report_path)
else:
msg = self.tr('report_path is not set')
raise InvalidParameterErro... | python | def save_report_to_html(self):
"""Save report in the dock to html."""
html = self.page().mainFrame().toHtml()
if self.report_path is not None:
html_to_file(html, self.report_path)
else:
msg = self.tr('report_path is not set')
raise InvalidParameterErro... | [
"def",
"save_report_to_html",
"(",
"self",
")",
":",
"html",
"=",
"self",
".",
"page",
"(",
")",
".",
"mainFrame",
"(",
")",
".",
"toHtml",
"(",
")",
"if",
"self",
".",
"report_path",
"is",
"not",
"None",
":",
"html_to_file",
"(",
"html",
",",
"self"... | Save report in the dock to html. | [
"Save",
"report",
"in",
"the",
"dock",
"to",
"html",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L328-L335 | train | 27,302 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.save_log_to_html | def save_log_to_html(self):
"""Helper to write the log out as an html file."""
html = html_header()
html += (
'<img src="file:///%s/img/logos/inasafe-logo-url.png" '
'title="InaSAFE Logo" alt="InaSAFE Logo" />' % resources_path())
html += ('<h5 class="info"><i cla... | python | def save_log_to_html(self):
"""Helper to write the log out as an html file."""
html = html_header()
html += (
'<img src="file:///%s/img/logos/inasafe-logo-url.png" '
'title="InaSAFE Logo" alt="InaSAFE Logo" />' % resources_path())
html += ('<h5 class="info"><i cla... | [
"def",
"save_log_to_html",
"(",
"self",
")",
":",
"html",
"=",
"html_header",
"(",
")",
"html",
"+=",
"(",
"'<img src=\"file:///%s/img/logos/inasafe-logo-url.png\" '",
"'title=\"InaSAFE Logo\" alt=\"InaSAFE Logo\" />'",
"%",
"resources_path",
"(",
")",
")",
"html",
"+=",
... | Helper to write the log out as an html file. | [
"Helper",
"to",
"write",
"the",
"log",
"out",
"as",
"an",
"html",
"file",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L337-L352 | train | 27,303 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.show_report | def show_report(self):
"""Show report."""
self.action_show_report.setEnabled(False)
self.action_show_log.setEnabled(True)
self.load_html_file(self.report_path) | python | def show_report(self):
"""Show report."""
self.action_show_report.setEnabled(False)
self.action_show_log.setEnabled(True)
self.load_html_file(self.report_path) | [
"def",
"show_report",
"(",
"self",
")",
":",
"self",
".",
"action_show_report",
".",
"setEnabled",
"(",
"False",
")",
"self",
".",
"action_show_log",
".",
"setEnabled",
"(",
"True",
")",
"self",
".",
"load_html_file",
"(",
"self",
".",
"report_path",
")"
] | Show report. | [
"Show",
"report",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L354-L358 | train | 27,304 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.show_log | def show_log(self):
"""Show log."""
self.action_show_report.setEnabled(True)
self.action_show_log.setEnabled(False)
self.load_html_file(self.log_path) | python | def show_log(self):
"""Show log."""
self.action_show_report.setEnabled(True)
self.action_show_log.setEnabled(False)
self.load_html_file(self.log_path) | [
"def",
"show_log",
"(",
"self",
")",
":",
"self",
".",
"action_show_report",
".",
"setEnabled",
"(",
"True",
")",
"self",
".",
"action_show_log",
".",
"setEnabled",
"(",
"False",
")",
"self",
".",
"load_html_file",
"(",
"self",
".",
"log_path",
")"
] | Show log. | [
"Show",
"log",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L360-L364 | train | 27,305 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.open_current_in_browser | def open_current_in_browser(self):
"""Open current selected impact report in browser."""
if self.impact_path is None:
html = self.page().mainFrame().toHtml()
html_to_file(html, open_browser=True)
else:
if self.action_show_report.isEnabled():
# ... | python | def open_current_in_browser(self):
"""Open current selected impact report in browser."""
if self.impact_path is None:
html = self.page().mainFrame().toHtml()
html_to_file(html, open_browser=True)
else:
if self.action_show_report.isEnabled():
# ... | [
"def",
"open_current_in_browser",
"(",
"self",
")",
":",
"if",
"self",
".",
"impact_path",
"is",
"None",
":",
"html",
"=",
"self",
".",
"page",
"(",
")",
".",
"mainFrame",
"(",
")",
".",
"toHtml",
"(",
")",
"html_to_file",
"(",
"html",
",",
"open_brows... | Open current selected impact report in browser. | [
"Open",
"current",
"selected",
"impact",
"report",
"in",
"browser",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L366-L376 | train | 27,306 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.generate_pdf | def generate_pdf(self):
"""Generate a PDF from the displayed content."""
printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
printer.setPageSize(QtGui.QPrinter.A4)
printer.setColorMode(QtGui.QPrinter.Color)
printer.setOutputFormat(QtGui.QPrinter.PdfFormat)
report_path... | python | def generate_pdf(self):
"""Generate a PDF from the displayed content."""
printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
printer.setPageSize(QtGui.QPrinter.A4)
printer.setColorMode(QtGui.QPrinter.Color)
printer.setOutputFormat(QtGui.QPrinter.PdfFormat)
report_path... | [
"def",
"generate_pdf",
"(",
"self",
")",
":",
"printer",
"=",
"QtGui",
".",
"QPrinter",
"(",
"QtGui",
".",
"QPrinter",
".",
"HighResolution",
")",
"printer",
".",
"setPageSize",
"(",
"QtGui",
".",
"QPrinter",
".",
"A4",
")",
"printer",
".",
"setColorMode",... | Generate a PDF from the displayed content. | [
"Generate",
"a",
"PDF",
"from",
"the",
"displayed",
"content",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L378-L389 | train | 27,307 |
inasafe/inasafe | safe/gui/widgets/message_viewer.py | MessageViewer.load_html | def load_html(self, mode, html):
"""Load HTML to this class with the mode specified.
There are two modes that can be used:
* HTML_FILE_MODE: Directly from a local HTML file.
* HTML_STR_MODE: From a valid HTML string.
:param mode: The mode.
:type mode: int
... | python | def load_html(self, mode, html):
"""Load HTML to this class with the mode specified.
There are two modes that can be used:
* HTML_FILE_MODE: Directly from a local HTML file.
* HTML_STR_MODE: From a valid HTML string.
:param mode: The mode.
:type mode: int
... | [
"def",
"load_html",
"(",
"self",
",",
"mode",
",",
"html",
")",
":",
"# noinspection PyCallByClass,PyTypeChecker,PyArgumentList",
"self",
".",
"_html_loaded_flag",
"=",
"False",
"if",
"mode",
"==",
"HTML_FILE_MODE",
":",
"self",
".",
"setUrl",
"(",
"QtCore",
".",
... | Load HTML to this class with the mode specified.
There are two modes that can be used:
* HTML_FILE_MODE: Directly from a local HTML file.
* HTML_STR_MODE: From a valid HTML string.
:param mode: The mode.
:type mode: int
:param html: The html that will be loaded... | [
"Load",
"HTML",
"to",
"this",
"class",
"with",
"the",
"mode",
"specified",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/message_viewer.py#L399-L432 | train | 27,308 |
inasafe/inasafe | safe/messaging/error_message.py | ErrorMessage.standard_suggestions | def standard_suggestions(self):
"""Standard generic suggestions.
:return: List of standard suggestions for users who encounter errors.
:rtype: BulletedList
"""
suggestions = BulletedList()
suggestions.add(
'Check that you have the latest version of InaSAFE in... | python | def standard_suggestions(self):
"""Standard generic suggestions.
:return: List of standard suggestions for users who encounter errors.
:rtype: BulletedList
"""
suggestions = BulletedList()
suggestions.add(
'Check that you have the latest version of InaSAFE in... | [
"def",
"standard_suggestions",
"(",
"self",
")",
":",
"suggestions",
"=",
"BulletedList",
"(",
")",
"suggestions",
".",
"add",
"(",
"'Check that you have the latest version of InaSAFE installed '",
"'- you may have encountered a bug that is fixed in a '",
"'subsequent release.'",
... | Standard generic suggestions.
:return: List of standard suggestions for users who encounter errors.
:rtype: BulletedList | [
"Standard",
"generic",
"suggestions",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/error_message.py#L114-L141 | train | 27,309 |
inasafe/inasafe | safe/messaging/error_message.py | ErrorMessage._render | def _render(self):
"""Create a Message version of this ErrorMessage
Args:
none
Returns:
the Message instance of this ErrorMessage
Raises:
Errors are propagated
"""
message = Message()
message.add(Heading(tr('Problem'), **ORAN... | python | def _render(self):
"""Create a Message version of this ErrorMessage
Args:
none
Returns:
the Message instance of this ErrorMessage
Raises:
Errors are propagated
"""
message = Message()
message.add(Heading(tr('Problem'), **ORAN... | [
"def",
"_render",
"(",
"self",
")",
":",
"message",
"=",
"Message",
"(",
")",
"message",
".",
"add",
"(",
"Heading",
"(",
"tr",
"(",
"'Problem'",
")",
",",
"*",
"*",
"ORANGE_LEVEL_4_STYLE",
")",
")",
"message",
".",
"add",
"(",
"Paragraph",
"(",
"tr"... | Create a Message version of this ErrorMessage
Args:
none
Returns:
the Message instance of this ErrorMessage
Raises:
Errors are propagated | [
"Create",
"a",
"Message",
"version",
"of",
"this",
"ErrorMessage"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/error_message.py#L143-L194 | train | 27,310 |
inasafe/inasafe | safe/messaging/error_message.py | ErrorMessage.append | def append(self, error_message):
"""Add an ErrorMessage to the end of the queue.
Tracebacks are not appended.
:param error_message: An element to add to the message.
:type error_message: ErrorMessage
"""
self.problems = self.problems + error_message.problems
se... | python | def append(self, error_message):
"""Add an ErrorMessage to the end of the queue.
Tracebacks are not appended.
:param error_message: An element to add to the message.
:type error_message: ErrorMessage
"""
self.problems = self.problems + error_message.problems
se... | [
"def",
"append",
"(",
"self",
",",
"error_message",
")",
":",
"self",
".",
"problems",
"=",
"self",
".",
"problems",
"+",
"error_message",
".",
"problems",
"self",
".",
"details",
"=",
"self",
".",
"details",
"+",
"error_message",
".",
"details",
"self",
... | Add an ErrorMessage to the end of the queue.
Tracebacks are not appended.
:param error_message: An element to add to the message.
:type error_message: ErrorMessage | [
"Add",
"an",
"ErrorMessage",
"to",
"the",
"end",
"of",
"the",
"queue",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/error_message.py#L196-L208 | train | 27,311 |
inasafe/inasafe | safe/messaging/error_message.py | ErrorMessage.prepend | def prepend(self, error_message):
"""Add an ErrorMessage to the beginning of the queue.
Tracebacks are not prepended.
:param error_message: An element to add to the message.
:type error_message: ErrorMessage
"""
self.problems = error_message.problems + self.problems
... | python | def prepend(self, error_message):
"""Add an ErrorMessage to the beginning of the queue.
Tracebacks are not prepended.
:param error_message: An element to add to the message.
:type error_message: ErrorMessage
"""
self.problems = error_message.problems + self.problems
... | [
"def",
"prepend",
"(",
"self",
",",
"error_message",
")",
":",
"self",
".",
"problems",
"=",
"error_message",
".",
"problems",
"+",
"self",
".",
"problems",
"self",
".",
"details",
"=",
"error_message",
".",
"details",
"+",
"self",
".",
"details",
"self",
... | Add an ErrorMessage to the beginning of the queue.
Tracebacks are not prepended.
:param error_message: An element to add to the message.
:type error_message: ErrorMessage | [
"Add",
"an",
"ErrorMessage",
"to",
"the",
"beginning",
"of",
"the",
"queue",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/error_message.py#L210-L224 | train | 27,312 |
inasafe/inasafe | safe/messaging/error_message.py | ErrorMessage.clear | def clear(self):
"""Clear ErrorMessage.
"""
self.problems = []
self.details = []
self.suggestions = []
self.tracebacks = [] | python | def clear(self):
"""Clear ErrorMessage.
"""
self.problems = []
self.details = []
self.suggestions = []
self.tracebacks = [] | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"problems",
"=",
"[",
"]",
"self",
".",
"details",
"=",
"[",
"]",
"self",
".",
"suggestions",
"=",
"[",
"]",
"self",
".",
"tracebacks",
"=",
"[",
"]"
] | Clear ErrorMessage. | [
"Clear",
"ErrorMessage",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/error_message.py#L226-L232 | train | 27,313 |
inasafe/inasafe | safe/datastore/folder.py | Folder.layers | def layers(self):
"""Return a list of layers available.
:return: List of layers available in the datastore.
:rtype: list
.. versionadded:: 4.0
"""
extensions = ['*.%s' % f for f in EXTENSIONS]
self.uri.setNameFilters(extensions)
files = self.uri.entryLis... | python | def layers(self):
"""Return a list of layers available.
:return: List of layers available in the datastore.
:rtype: list
.. versionadded:: 4.0
"""
extensions = ['*.%s' % f for f in EXTENSIONS]
self.uri.setNameFilters(extensions)
files = self.uri.entryLis... | [
"def",
"layers",
"(",
"self",
")",
":",
"extensions",
"=",
"[",
"'*.%s'",
"%",
"f",
"for",
"f",
"in",
"EXTENSIONS",
"]",
"self",
".",
"uri",
".",
"setNameFilters",
"(",
"extensions",
")",
"files",
"=",
"self",
".",
"uri",
".",
"entryList",
"(",
")",
... | Return a list of layers available.
:return: List of layers available in the datastore.
:rtype: list
.. versionadded:: 4.0 | [
"Return",
"a",
"list",
"of",
"layers",
"available",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/folder.py#L110-L123 | train | 27,314 |
inasafe/inasafe | safe/datastore/folder.py | Folder._add_tabular_layer | def _add_tabular_layer(self, tabular_layer, layer_name, save_style=False):
"""Add a tabular layer to the folder.
:param tabular_layer: The layer to add.
:type tabular_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
... | python | def _add_tabular_layer(self, tabular_layer, layer_name, save_style=False):
"""Add a tabular layer to the folder.
:param tabular_layer: The layer to add.
:type tabular_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
... | [
"def",
"_add_tabular_layer",
"(",
"self",
",",
"tabular_layer",
",",
"layer_name",
",",
"save_style",
"=",
"False",
")",
":",
"output",
"=",
"QFileInfo",
"(",
"self",
".",
"uri",
".",
"filePath",
"(",
"layer_name",
"+",
"'.csv'",
")",
")",
"QgsVectorFileWrit... | Add a tabular layer to the folder.
:param tabular_layer: The layer to add.
:type tabular_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
:param save_style: If we have to save a QML too. Default to False.
:type save... | [
"Add",
"a",
"tabular",
"layer",
"to",
"the",
"folder",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/folder.py#L146-L180 | train | 27,315 |
inasafe/inasafe | safe/datastore/folder.py | Folder._add_vector_layer | def _add_vector_layer(self, vector_layer, layer_name, save_style=False):
"""Add a vector layer to the folder.
:param vector_layer: The layer to add.
:type vector_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
:par... | python | def _add_vector_layer(self, vector_layer, layer_name, save_style=False):
"""Add a vector layer to the folder.
:param vector_layer: The layer to add.
:type vector_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
:par... | [
"def",
"_add_vector_layer",
"(",
"self",
",",
"vector_layer",
",",
"layer_name",
",",
"save_style",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"is_writable",
"(",
")",
":",
"return",
"False",
",",
"'The destination is not writable.'",
"output",
"=",
"QF... | Add a vector layer to the folder.
:param vector_layer: The layer to add.
:type vector_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
:param save_style: If we have to save a QML too. Default to False.
:type save_st... | [
"Add",
"a",
"vector",
"layer",
"to",
"the",
"folder",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/datastore/folder.py#L182-L226 | train | 27,316 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc40_explayer_from_browser.py | StepFcExpLayerFromBrowser.set_widgets | def set_widgets(self):
"""Set widgets on the Exposure Layer From Browser tab."""
self.tvBrowserExposure_selection_changed()
# Set icon
exposure = self.parent.step_fc_functions1.selected_value(
layer_purpose_exposure['key'])
icon_path = get_image_path(exposure)
... | python | def set_widgets(self):
"""Set widgets on the Exposure Layer From Browser tab."""
self.tvBrowserExposure_selection_changed()
# Set icon
exposure = self.parent.step_fc_functions1.selected_value(
layer_purpose_exposure['key'])
icon_path = get_image_path(exposure)
... | [
"def",
"set_widgets",
"(",
"self",
")",
":",
"self",
".",
"tvBrowserExposure_selection_changed",
"(",
")",
"# Set icon",
"exposure",
"=",
"self",
".",
"parent",
".",
"step_fc_functions1",
".",
"selected_value",
"(",
"layer_purpose_exposure",
"[",
"'key'",
"]",
")"... | Set widgets on the Exposure Layer From Browser tab. | [
"Set",
"widgets",
"on",
"the",
"Exposure",
"Layer",
"From",
"Browser",
"tab",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc40_explayer_from_browser.py#L73-L81 | train | 27,317 |
inasafe/inasafe | safe/messaging/item/paragraph.py | Paragraph.to_html | def to_html(self):
"""Render a Paragraph MessageElement as html
:returns: The html representation of the Paragraph MessageElement
"""
if self.text is None:
return
else:
return '<p%s>%s%s</p>' % (
self.html_attributes(), self.html_icon(), ... | python | def to_html(self):
"""Render a Paragraph MessageElement as html
:returns: The html representation of the Paragraph MessageElement
"""
if self.text is None:
return
else:
return '<p%s>%s%s</p>' % (
self.html_attributes(), self.html_icon(), ... | [
"def",
"to_html",
"(",
"self",
")",
":",
"if",
"self",
".",
"text",
"is",
"None",
":",
"return",
"else",
":",
"return",
"'<p%s>%s%s</p>'",
"%",
"(",
"self",
".",
"html_attributes",
"(",
")",
",",
"self",
".",
"html_icon",
"(",
")",
",",
"self",
".",
... | Render a Paragraph MessageElement as html
:returns: The html representation of the Paragraph MessageElement | [
"Render",
"a",
"Paragraph",
"MessageElement",
"as",
"html"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/messaging/item/paragraph.py#L47-L57 | train | 27,318 |
inasafe/inasafe | safe/metadata/metadata_db_io.py | MetadataDbIO.open_connection | def open_connection(self):
"""Open an sqlite connection to the metadata database.
By default the metadata database will be used in the plugin dir,
unless an explicit path has been set using setmetadataDbPath, or
overridden in QSettings. If the db does not exist it will
be create... | python | def open_connection(self):
"""Open an sqlite connection to the metadata database.
By default the metadata database will be used in the plugin dir,
unless an explicit path has been set using setmetadataDbPath, or
overridden in QSettings. If the db does not exist it will
be create... | [
"def",
"open_connection",
"(",
"self",
")",
":",
"self",
".",
"connection",
"=",
"None",
"base_directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"metadata_db_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"base_direct... | Open an sqlite connection to the metadata database.
By default the metadata database will be used in the plugin dir,
unless an explicit path has been set using setmetadataDbPath, or
overridden in QSettings. If the db does not exist it will
be created.
:raises: An sqlite.Error i... | [
"Open",
"an",
"sqlite",
"connection",
"to",
"the",
"metadata",
"database",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/metadata_db_io.py#L82-L106 | train | 27,319 |
inasafe/inasafe | safe/metadata/metadata_db_io.py | MetadataDbIO.get_cursor | def get_cursor(self):
"""Get a cursor for the active connection.
The cursor can be used to execute arbitrary queries against the
database. This method also checks that the metadata table exists in
the schema, and if not, it creates it.
:returns: A valid cursor opened against th... | python | def get_cursor(self):
"""Get a cursor for the active connection.
The cursor can be used to execute arbitrary queries against the
database. This method also checks that the metadata table exists in
the schema, and if not, it creates it.
:returns: A valid cursor opened against th... | [
"def",
"get_cursor",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection",
"is",
"None",
":",
"try",
":",
"self",
".",
"open_connection",
"(",
")",
"except",
"OperationalError",
":",
"raise",
"try",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
... | Get a cursor for the active connection.
The cursor can be used to execute arbitrary queries against the
database. This method also checks that the metadata table exists in
the schema, and if not, it creates it.
:returns: A valid cursor opened against the connection.
:rtype: sql... | [
"Get",
"a",
"cursor",
"for",
"the",
"active",
"connection",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/metadata_db_io.py#L114-L156 | train | 27,320 |
inasafe/inasafe | safe/metadata/metadata_db_io.py | MetadataDbIO.hash_for_datasource | def hash_for_datasource(data_source):
"""Given a data_source, return its hash.
:param data_source: The data_source name from a layer.
:type data_source: str
:returns: An md5 hash for the data source name.
:rtype: str
"""
import hashlib
hash_value = hashl... | python | def hash_for_datasource(data_source):
"""Given a data_source, return its hash.
:param data_source: The data_source name from a layer.
:type data_source: str
:returns: An md5 hash for the data source name.
:rtype: str
"""
import hashlib
hash_value = hashl... | [
"def",
"hash_for_datasource",
"(",
"data_source",
")",
":",
"import",
"hashlib",
"hash_value",
"=",
"hashlib",
".",
"md5",
"(",
")",
"hash_value",
".",
"update",
"(",
"data_source",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"hash_value",
"=",
"hash_value",
".... | Given a data_source, return its hash.
:param data_source: The data_source name from a layer.
:type data_source: str
:returns: An md5 hash for the data source name.
:rtype: str | [
"Given",
"a",
"data_source",
"return",
"its",
"hash",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/metadata_db_io.py#L198-L211 | train | 27,321 |
inasafe/inasafe | safe/metadata/metadata_db_io.py | MetadataDbIO.delete_metadata_for_uri | def delete_metadata_for_uri(self, uri):
"""Delete metadata for a URI in the metadata database.
A hash will be constructed from the supplied uri and a lookup made
in a local SQLITE database for the metadata. If there is an existing
record for the hash, the entire record will be erased.
... | python | def delete_metadata_for_uri(self, uri):
"""Delete metadata for a URI in the metadata database.
A hash will be constructed from the supplied uri and a lookup made
in a local SQLITE database for the metadata. If there is an existing
record for the hash, the entire record will be erased.
... | [
"def",
"delete_metadata_for_uri",
"(",
"self",
",",
"uri",
")",
":",
"hash_value",
"=",
"self",
".",
"hash_for_datasource",
"(",
"uri",
")",
"try",
":",
"cursor",
"=",
"self",
".",
"get_cursor",
"(",
")",
"# now see if we have any data for our hash",
"sql",
"=",... | Delete metadata for a URI in the metadata database.
A hash will be constructed from the supplied uri and a lookup made
in a local SQLITE database for the metadata. If there is an existing
record for the hash, the entire record will be erased.
.. seealso:: write_metadata_for_uri, read_m... | [
"Delete",
"metadata",
"for",
"a",
"URI",
"in",
"the",
"metadata",
"database",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/metadata_db_io.py#L213-L243 | train | 27,322 |
inasafe/inasafe | safe/metadata/metadata_db_io.py | MetadataDbIO.write_metadata_for_uri | def write_metadata_for_uri(self, uri, json=None, xml=None):
"""Write metadata for a URI into the metadata database. All the
metadata for the uri should be written in a single operation.
A hash will be constructed from the supplied uri and a lookup made
in a local SQLite database for the ... | python | def write_metadata_for_uri(self, uri, json=None, xml=None):
"""Write metadata for a URI into the metadata database. All the
metadata for the uri should be written in a single operation.
A hash will be constructed from the supplied uri and a lookup made
in a local SQLite database for the ... | [
"def",
"write_metadata_for_uri",
"(",
"self",
",",
"uri",
",",
"json",
"=",
"None",
",",
"xml",
"=",
"None",
")",
":",
"hash_value",
"=",
"self",
".",
"hash_for_datasource",
"(",
"uri",
")",
"try",
":",
"cursor",
"=",
"self",
".",
"get_cursor",
"(",
")... | Write metadata for a URI into the metadata database. All the
metadata for the uri should be written in a single operation.
A hash will be constructed from the supplied uri and a lookup made
in a local SQLite database for the metadata. If there is an existing
record it will be updated, if... | [
"Write",
"metadata",
"for",
"a",
"URI",
"into",
"the",
"metadata",
"database",
".",
"All",
"the",
"metadata",
"for",
"the",
"uri",
"should",
"be",
"written",
"in",
"a",
"single",
"operation",
".",
"A",
"hash",
"will",
"be",
"constructed",
"from",
"the",
... | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/metadata_db_io.py#L245-L300 | train | 27,323 |
inasafe/inasafe | safe/metadata/metadata_db_io.py | MetadataDbIO.read_metadata_from_uri | def read_metadata_from_uri(self, uri, metadata_format):
"""Try to get metadata from the DB entry associated with a URI.
This is used for layers that are non local layer (e.g. postgresql
connection) and so we need to retrieve the metadata from the sqlite
metadata db.
A hash will... | python | def read_metadata_from_uri(self, uri, metadata_format):
"""Try to get metadata from the DB entry associated with a URI.
This is used for layers that are non local layer (e.g. postgresql
connection) and so we need to retrieve the metadata from the sqlite
metadata db.
A hash will... | [
"def",
"read_metadata_from_uri",
"(",
"self",
",",
"uri",
",",
"metadata_format",
")",
":",
"allowed_formats",
"=",
"[",
"'json'",
",",
"'xml'",
"]",
"if",
"metadata_format",
"not",
"in",
"allowed_formats",
":",
"message",
"=",
"'Metadata format %s is not valid. Val... | Try to get metadata from the DB entry associated with a URI.
This is used for layers that are non local layer (e.g. postgresql
connection) and so we need to retrieve the metadata from the sqlite
metadata db.
A hash will be constructed from the supplied uri and a lookup made
in ... | [
"Try",
"to",
"get",
"metadata",
"from",
"the",
"DB",
"entry",
"associated",
"with",
"a",
"URI",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/metadata_db_io.py#L302-L362 | train | 27,324 |
inasafe/inasafe | safe/gis/vector/summary_1_aggregate_hazard.py | report_on_field | def report_on_field(layer):
"""Helper function to set on which field we are going to report.
The return might be empty if we don't report on a field.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:return: The field index on which we should report.
:rtype: int
"""
source_... | python | def report_on_field(layer):
"""Helper function to set on which field we are going to report.
The return might be empty if we don't report on a field.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:return: The field index on which we should report.
:rtype: int
"""
source_... | [
"def",
"report_on_field",
"(",
"layer",
")",
":",
"source_fields",
"=",
"layer",
".",
"keywords",
"[",
"'inasafe_fields'",
"]",
"if",
"source_fields",
".",
"get",
"(",
"size_field",
"[",
"'key'",
"]",
")",
":",
"field_size",
"=",
"source_fields",
"[",
"size_... | Helper function to set on which field we are going to report.
The return might be empty if we don't report on a field.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:return: The field index on which we should report.
:rtype: int | [
"Helper",
"function",
"to",
"set",
"on",
"which",
"field",
"we",
"are",
"going",
"to",
"report",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/summary_1_aggregate_hazard.py#L228-L267 | train | 27,325 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc30_explayer_origin.py | StepFcExpLayerOrigin.set_widgets | def set_widgets(self):
"""Set widgets on the Exposure Layer Origin Type tab."""
# First, list available layers in order to check if there are
# any available layers. Note This will be repeated in
# set_widgets_step_fc_explayer_from_canvas because we need
# to list them again afte... | python | def set_widgets(self):
"""Set widgets on the Exposure Layer Origin Type tab."""
# First, list available layers in order to check if there are
# any available layers. Note This will be repeated in
# set_widgets_step_fc_explayer_from_canvas because we need
# to list them again afte... | [
"def",
"set_widgets",
"(",
"self",
")",
":",
"# First, list available layers in order to check if there are",
"# any available layers. Note This will be repeated in",
"# set_widgets_step_fc_explayer_from_canvas because we need",
"# to list them again after coming back from the Keyword Wizard.",
... | Set widgets on the Exposure Layer Origin Type tab. | [
"Set",
"widgets",
"on",
"the",
"Exposure",
"Layer",
"Origin",
"Type",
"tab",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc30_explayer_origin.py#L68-L116 | train | 27,326 |
inasafe/inasafe | safe/impact_function/impact_function_utilities.py | check_input_layer | def check_input_layer(layer, purpose):
"""Function to check if the layer is valid.
The function will also set the monkey patching if needed.
:param layer: The layer to test.
:type layer: QgsMapLayer
:param purpose: The expected purpose of the layer.
:type purpose: basestring
:return: A t... | python | def check_input_layer(layer, purpose):
"""Function to check if the layer is valid.
The function will also set the monkey patching if needed.
:param layer: The layer to test.
:type layer: QgsMapLayer
:param purpose: The expected purpose of the layer.
:type purpose: basestring
:return: A t... | [
"def",
"check_input_layer",
"(",
"layer",
",",
"purpose",
")",
":",
"if",
"not",
"layer",
".",
"isValid",
"(",
")",
":",
"title",
"=",
"tr",
"(",
"'The {purpose} layer is invalid'",
")",
".",
"format",
"(",
"purpose",
"=",
"purpose",
")",
"content",
"=",
... | Function to check if the layer is valid.
The function will also set the monkey patching if needed.
:param layer: The layer to test.
:type layer: QgsMapLayer
:param purpose: The expected purpose of the layer.
:type purpose: basestring
:return: A tuple with the status of the layer and an error... | [
"Function",
"to",
"check",
"if",
"the",
"layer",
"is",
"valid",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/impact_function_utilities.py#L40-L127 | train | 27,327 |
inasafe/inasafe | safe/impact_function/impact_function_utilities.py | report_urls | def report_urls(impact_function):
"""Get report urls for all report generated by the ImpactFunction.
:param impact_function: The ImpactFunction
:type impact_function: ImpactFunction
:return: Dictionary of all generated report urls by its product type
eg:
{
'html... | python | def report_urls(impact_function):
"""Get report urls for all report generated by the ImpactFunction.
:param impact_function: The ImpactFunction
:type impact_function: ImpactFunction
:return: Dictionary of all generated report urls by its product type
eg:
{
'html... | [
"def",
"report_urls",
"(",
"impact_function",
")",
":",
"report_path",
"=",
"impact_function",
".",
"impact_report",
".",
"output_folder",
"standard_report_metadata",
"=",
"impact_function",
".",
"report_metadata",
"def",
"retrieve_components",
"(",
"tags",
")",
":",
... | Get report urls for all report generated by the ImpactFunction.
:param impact_function: The ImpactFunction
:type impact_function: ImpactFunction
:return: Dictionary of all generated report urls by its product type
eg:
{
'html_product_tag': {
'action-... | [
"Get",
"report",
"urls",
"for",
"all",
"report",
"generated",
"by",
"the",
"ImpactFunction",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/impact_function/impact_function_utilities.py#L130-L210 | train | 27,328 |
inasafe/inasafe | safe/gui/tools/help/developer_help.py | developer_help | def developer_help():
"""Help message for developers.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())
return mess... | python | def developer_help():
"""Help message for developers.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())
return mess... | [
"def",
"developer_help",
"(",
")",
":",
"message",
"=",
"m",
".",
"Message",
"(",
")",
"message",
".",
"add",
"(",
"m",
".",
"Brand",
"(",
")",
")",
"message",
".",
"add",
"(",
"heading",
"(",
")",
")",
"message",
".",
"add",
"(",
"content",
"(",... | Help message for developers.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message | [
"Help",
"message",
"for",
"developers",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/developer_help.py#L33-L46 | train | 27,329 |
inasafe/inasafe | safe/gui/tools/help/developer_help.py | _get_definition_from_module | def _get_definition_from_module(definitions_module, symbol):
"""Given a python module fetch the declaration of a variable."""
path = definitions_module.__file__
path = path.replace('.pyc', '.py')
source = open(path, encoding='utf-8').readlines()
text = None
for line in source:
if symbol ... | python | def _get_definition_from_module(definitions_module, symbol):
"""Given a python module fetch the declaration of a variable."""
path = definitions_module.__file__
path = path.replace('.pyc', '.py')
source = open(path, encoding='utf-8').readlines()
text = None
for line in source:
if symbol ... | [
"def",
"_get_definition_from_module",
"(",
"definitions_module",
",",
"symbol",
")",
":",
"path",
"=",
"definitions_module",
".",
"__file__",
"path",
"=",
"path",
".",
"replace",
"(",
"'.pyc'",
",",
"'.py'",
")",
"source",
"=",
"open",
"(",
"path",
",",
"enc... | Given a python module fetch the declaration of a variable. | [
"Given",
"a",
"python",
"module",
"fetch",
"the",
"declaration",
"of",
"a",
"variable",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/developer_help.py#L239-L255 | train | 27,330 |
inasafe/inasafe | safe/gis/raster/contour.py | gaussian_kernel | def gaussian_kernel(sigma, truncate=4.0):
"""Return Gaussian that truncates at the given number of std deviations.
Adapted from https://github.com/nicjhan/gaussian-filter
"""
sigma = float(sigma)
radius = int(truncate * sigma + 0.5)
x, y = np.mgrid[-radius:radius + 1, -radius:radius + 1]
... | python | def gaussian_kernel(sigma, truncate=4.0):
"""Return Gaussian that truncates at the given number of std deviations.
Adapted from https://github.com/nicjhan/gaussian-filter
"""
sigma = float(sigma)
radius = int(truncate * sigma + 0.5)
x, y = np.mgrid[-radius:radius + 1, -radius:radius + 1]
... | [
"def",
"gaussian_kernel",
"(",
"sigma",
",",
"truncate",
"=",
"4.0",
")",
":",
"sigma",
"=",
"float",
"(",
"sigma",
")",
"radius",
"=",
"int",
"(",
"truncate",
"*",
"sigma",
"+",
"0.5",
")",
"x",
",",
"y",
"=",
"np",
".",
"mgrid",
"[",
"-",
"radi... | Return Gaussian that truncates at the given number of std deviations.
Adapted from https://github.com/nicjhan/gaussian-filter | [
"Return",
"Gaussian",
"that",
"truncates",
"at",
"the",
"given",
"number",
"of",
"std",
"deviations",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L53-L68 | train | 27,331 |
inasafe/inasafe | safe/gis/raster/contour.py | tile_and_reflect | def tile_and_reflect(input):
"""Make 3x3 tiled array.
Central area is 'input', surrounding areas are reflected.
Adapted from https://github.com/nicjhan/gaussian-filter
"""
tiled_input = np.tile(input, (3, 3))
rows = input.shape[0]
cols = input.shape[1]
# Now we have a 3x3 tiles - do... | python | def tile_and_reflect(input):
"""Make 3x3 tiled array.
Central area is 'input', surrounding areas are reflected.
Adapted from https://github.com/nicjhan/gaussian-filter
"""
tiled_input = np.tile(input, (3, 3))
rows = input.shape[0]
cols = input.shape[1]
# Now we have a 3x3 tiles - do... | [
"def",
"tile_and_reflect",
"(",
"input",
")",
":",
"tiled_input",
"=",
"np",
".",
"tile",
"(",
"input",
",",
"(",
"3",
",",
"3",
")",
")",
"rows",
"=",
"input",
".",
"shape",
"[",
"0",
"]",
"cols",
"=",
"input",
".",
"shape",
"[",
"1",
"]",
"# ... | Make 3x3 tiled array.
Central area is 'input', surrounding areas are reflected.
Adapted from https://github.com/nicjhan/gaussian-filter | [
"Make",
"3x3",
"tiled",
"array",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L71-L114 | train | 27,332 |
inasafe/inasafe | safe/gis/raster/contour.py | convolve | def convolve(input, weights, mask=None, slow=False):
"""2 dimensional convolution.
This is a Python implementation of what will be written in Fortran.
Borders are handled with reflection.
Masking is supported in the following way:
* Masked points are skipped.
* Parts of the input whic... | python | def convolve(input, weights, mask=None, slow=False):
"""2 dimensional convolution.
This is a Python implementation of what will be written in Fortran.
Borders are handled with reflection.
Masking is supported in the following way:
* Masked points are skipped.
* Parts of the input whic... | [
"def",
"convolve",
"(",
"input",
",",
"weights",
",",
"mask",
"=",
"None",
",",
"slow",
"=",
"False",
")",
":",
"assert",
"(",
"len",
"(",
"input",
".",
"shape",
")",
"==",
"2",
")",
"assert",
"(",
"len",
"(",
"weights",
".",
"shape",
")",
"==",
... | 2 dimensional convolution.
This is a Python implementation of what will be written in Fortran.
Borders are handled with reflection.
Masking is supported in the following way:
* Masked points are skipped.
* Parts of the input which are masked have weight 0 in the kernel.
* Since th... | [
"2",
"dimensional",
"convolution",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L117-L228 | train | 27,333 |
inasafe/inasafe | safe/gis/raster/contour.py | create_smooth_contour | def create_smooth_contour(
shakemap_layer,
output_file_path='',
active_band=1,
smoothing_method=NUMPY_SMOOTHING,
smoothing_sigma=0.9):
"""Create contour from a shake map layer by using smoothing method.
:param shakemap_layer: The shake map raster layer.
:type shakema... | python | def create_smooth_contour(
shakemap_layer,
output_file_path='',
active_band=1,
smoothing_method=NUMPY_SMOOTHING,
smoothing_sigma=0.9):
"""Create contour from a shake map layer by using smoothing method.
:param shakemap_layer: The shake map raster layer.
:type shakema... | [
"def",
"create_smooth_contour",
"(",
"shakemap_layer",
",",
"output_file_path",
"=",
"''",
",",
"active_band",
"=",
"1",
",",
"smoothing_method",
"=",
"NUMPY_SMOOTHING",
",",
"smoothing_sigma",
"=",
"0.9",
")",
":",
"timestamp",
"=",
"datetime",
".",
"now",
"(",... | Create contour from a shake map layer by using smoothing method.
:param shakemap_layer: The shake map raster layer.
:type shakemap_layer: QgsRasterLayer
:param active_band: The band which the data located, default to 1.
:type active_band: int
:param smoothing_method: The smoothing method that wan... | [
"Create",
"contour",
"from",
"a",
"shake",
"map",
"layer",
"by",
"using",
"smoothing",
"method",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L231-L273 | train | 27,334 |
inasafe/inasafe | safe/gis/raster/contour.py | smooth_shakemap | def smooth_shakemap(
shakemap_layer_path,
output_file_path='',
active_band=1,
smoothing_method=NUMPY_SMOOTHING,
smoothing_sigma=0.9):
"""Make a smoother shakemap layer from a shake map.
:param shakemap_layer_path: The shake map raster layer path.
:type shakemap_layer... | python | def smooth_shakemap(
shakemap_layer_path,
output_file_path='',
active_band=1,
smoothing_method=NUMPY_SMOOTHING,
smoothing_sigma=0.9):
"""Make a smoother shakemap layer from a shake map.
:param shakemap_layer_path: The shake map raster layer path.
:type shakemap_layer... | [
"def",
"smooth_shakemap",
"(",
"shakemap_layer_path",
",",
"output_file_path",
"=",
"''",
",",
"active_band",
"=",
"1",
",",
"smoothing_method",
"=",
"NUMPY_SMOOTHING",
",",
"smoothing_sigma",
"=",
"0.9",
")",
":",
"# Set output path",
"if",
"not",
"output_file_path... | Make a smoother shakemap layer from a shake map.
:param shakemap_layer_path: The shake map raster layer path.
:type shakemap_layer_path: basestring
:param active_band: The band which the data located, default to 1.
:type active_band: int
:param smoothing_method: The smoothing method that wanted t... | [
"Make",
"a",
"smoother",
"shakemap",
"layer",
"from",
"a",
"shake",
"map",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L276-L339 | train | 27,335 |
inasafe/inasafe | safe/gis/raster/contour.py | shakemap_contour | def shakemap_contour(shakemap_layer_path, output_file_path='', active_band=1):
"""Creating contour from a shakemap layer.
:param shakemap_layer_path: The shake map raster layer path.
:type shakemap_layer_path: basestring
:param output_file_path: The path where the contour will be saved.
:type outp... | python | def shakemap_contour(shakemap_layer_path, output_file_path='', active_band=1):
"""Creating contour from a shakemap layer.
:param shakemap_layer_path: The shake map raster layer path.
:type shakemap_layer_path: basestring
:param output_file_path: The path where the contour will be saved.
:type outp... | [
"def",
"shakemap_contour",
"(",
"shakemap_layer_path",
",",
"output_file_path",
"=",
"''",
",",
"active_band",
"=",
"1",
")",
":",
"# Set output path",
"if",
"not",
"output_file_path",
":",
"output_file_path",
"=",
"unique_filename",
"(",
"suffix",
"=",
"'.shp'",
... | Creating contour from a shakemap layer.
:param shakemap_layer_path: The shake map raster layer path.
:type shakemap_layer_path: basestring
:param output_file_path: The path where the contour will be saved.
:type output_file_path: basestring
:param active_band: The band which the data located, def... | [
"Creating",
"contour",
"from",
"a",
"shakemap",
"layer",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L342-L432 | train | 27,336 |
inasafe/inasafe | safe/gis/raster/contour.py | set_contour_properties | def set_contour_properties(contour_file_path):
"""Set the X, Y, RGB, ROMAN attributes of the contour layer.
:param contour_file_path: Path of the contour layer.
:type contour_file_path: str
:raise: InvalidLayerError if anything is amiss with the layer.
"""
LOGGER.debug(
'Set_contour_pr... | python | def set_contour_properties(contour_file_path):
"""Set the X, Y, RGB, ROMAN attributes of the contour layer.
:param contour_file_path: Path of the contour layer.
:type contour_file_path: str
:raise: InvalidLayerError if anything is amiss with the layer.
"""
LOGGER.debug(
'Set_contour_pr... | [
"def",
"set_contour_properties",
"(",
"contour_file_path",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Set_contour_properties requested for %s.'",
"%",
"contour_file_path",
")",
"layer",
"=",
"QgsVectorLayer",
"(",
"contour_file_path",
",",
"'mmi-contours'",
",",
"\"ogr\"",
... | Set the X, Y, RGB, ROMAN attributes of the contour layer.
:param contour_file_path: Path of the contour layer.
:type contour_file_path: str
:raise: InvalidLayerError if anything is amiss with the layer. | [
"Set",
"the",
"X",
"Y",
"RGB",
"ROMAN",
"attributes",
"of",
"the",
"contour",
"layer",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L435-L508 | train | 27,337 |
inasafe/inasafe | safe/gis/raster/contour.py | create_contour_metadata | def create_contour_metadata(contour_path):
"""Create metadata file for contour layer.
:param contour_path: Path where the contour is located.
:type contour_path: basestring
"""
metadata = {
'title': tr('Earthquake Contour'),
'layer_purpose': layer_purpose_earthquake_contour['key'],
... | python | def create_contour_metadata(contour_path):
"""Create metadata file for contour layer.
:param contour_path: Path where the contour is located.
:type contour_path: basestring
"""
metadata = {
'title': tr('Earthquake Contour'),
'layer_purpose': layer_purpose_earthquake_contour['key'],
... | [
"def",
"create_contour_metadata",
"(",
"contour_path",
")",
":",
"metadata",
"=",
"{",
"'title'",
":",
"tr",
"(",
"'Earthquake Contour'",
")",
",",
"'layer_purpose'",
":",
"layer_purpose_earthquake_contour",
"[",
"'key'",
"]",
",",
"'layer_geometry'",
":",
"layer_ge... | Create metadata file for contour layer.
:param contour_path: Path where the contour is located.
:type contour_path: basestring | [
"Create",
"metadata",
"file",
"for",
"contour",
"layer",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/contour.py#L511-L529 | train | 27,338 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc50_agglayer_origin.py | StepFcAggLayerOrigin.is_ready_to_next_step | def is_ready_to_next_step(self):
"""Check if the step is complete. If so, there is
no reason to block the Next button.
:returns: True if new step may be enabled.
:rtype: bool
"""
return (bool(self.rbAggLayerFromCanvas.isChecked()
or self.rbAggLay... | python | def is_ready_to_next_step(self):
"""Check if the step is complete. If so, there is
no reason to block the Next button.
:returns: True if new step may be enabled.
:rtype: bool
"""
return (bool(self.rbAggLayerFromCanvas.isChecked()
or self.rbAggLay... | [
"def",
"is_ready_to_next_step",
"(",
"self",
")",
":",
"return",
"(",
"bool",
"(",
"self",
".",
"rbAggLayerFromCanvas",
".",
"isChecked",
"(",
")",
"or",
"self",
".",
"rbAggLayerFromBrowser",
".",
"isChecked",
"(",
")",
"or",
"self",
".",
"rbAggLayerNoAggregat... | Check if the step is complete. If so, there is
no reason to block the Next button.
:returns: True if new step may be enabled.
:rtype: bool | [
"Check",
"if",
"the",
"step",
"is",
"complete",
".",
"If",
"so",
"there",
"is",
"no",
"reason",
"to",
"block",
"the",
"Next",
"button",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc50_agglayer_origin.py#L22-L31 | train | 27,339 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc50_agglayer_origin.py | StepFcAggLayerOrigin.on_rbAggLayerNoAggregation_toggled | def on_rbAggLayerNoAggregation_toggled(self):
"""Unlock the Next button
Also, clear any previously set aggregation layer
.. note:: This is an automatic Qt slot
executed when the radiobutton is activated.
"""
self.parent.aggregation_layer = None
self.parent.... | python | def on_rbAggLayerNoAggregation_toggled(self):
"""Unlock the Next button
Also, clear any previously set aggregation layer
.. note:: This is an automatic Qt slot
executed when the radiobutton is activated.
"""
self.parent.aggregation_layer = None
self.parent.... | [
"def",
"on_rbAggLayerNoAggregation_toggled",
"(",
"self",
")",
":",
"self",
".",
"parent",
".",
"aggregation_layer",
"=",
"None",
"self",
".",
"parent",
".",
"pbnNext",
".",
"setEnabled",
"(",
"True",
")"
] | Unlock the Next button
Also, clear any previously set aggregation layer
.. note:: This is an automatic Qt slot
executed when the radiobutton is activated. | [
"Unlock",
"the",
"Next",
"button",
"Also",
"clear",
"any",
"previously",
"set",
"aggregation",
"layer"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc50_agglayer_origin.py#L66-L74 | train | 27,340 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc50_agglayer_origin.py | StepFcAggLayerOrigin.set_widgets | def set_widgets(self):
"""Set widgets on the Aggregation Layer Origin Type tab."""
# First, list available layers in order to check if there are
# any available layers. Note This will be repeated in
# set_widgets_step_fc_agglayer_from_canvas because we need
# to list them again a... | python | def set_widgets(self):
"""Set widgets on the Aggregation Layer Origin Type tab."""
# First, list available layers in order to check if there are
# any available layers. Note This will be repeated in
# set_widgets_step_fc_agglayer_from_canvas because we need
# to list them again a... | [
"def",
"set_widgets",
"(",
"self",
")",
":",
"# First, list available layers in order to check if there are",
"# any available layers. Note This will be repeated in",
"# set_widgets_step_fc_agglayer_from_canvas because we need",
"# to list them again after coming back from the Keyword Wizard.",
... | Set widgets on the Aggregation Layer Origin Type tab. | [
"Set",
"widgets",
"on",
"the",
"Aggregation",
"Layer",
"Origin",
"Type",
"tab",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc50_agglayer_origin.py#L76-L102 | train | 27,341 |
inasafe/inasafe | safe/metadata35/metadata_db_io.py | MetadataDbIO.default_metadata_db_path | def default_metadata_db_path():
"""Helper to get the default path for the metadata file.
:returns: The path to where the default location of the metadata
database is. Maps to which is ~/.inasafe.metadata35.db
:rtype: str
"""
home = expanduser("~")
home = os.... | python | def default_metadata_db_path():
"""Helper to get the default path for the metadata file.
:returns: The path to where the default location of the metadata
database is. Maps to which is ~/.inasafe.metadata35.db
:rtype: str
"""
home = expanduser("~")
home = os.... | [
"def",
"default_metadata_db_path",
"(",
")",
":",
"home",
"=",
"expanduser",
"(",
"\"~\"",
")",
"home",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"home",
",",
"'.inasafe'",
",",
"'metadata.db'",
")",
")",
"return... | Helper to get the default path for the metadata file.
:returns: The path to where the default location of the metadata
database is. Maps to which is ~/.inasafe.metadata35.db
:rtype: str | [
"Helper",
"to",
"get",
"the",
"default",
"path",
"for",
"the",
"metadata",
"file",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/metadata_db_io.py#L65-L76 | train | 27,342 |
inasafe/inasafe | safe/metadata35/metadata_db_io.py | MetadataDbIO.setup_metadata_db_path | def setup_metadata_db_path(self):
"""Helper to set the active path for the metadata.
Called at init time, you can override this path by calling
set_metadata_db_path.setmetadataDbPath.
:returns: The path to where the metadata file is. If the user has
never specified what thi... | python | def setup_metadata_db_path(self):
"""Helper to set the active path for the metadata.
Called at init time, you can override this path by calling
set_metadata_db_path.setmetadataDbPath.
:returns: The path to where the metadata file is. If the user has
never specified what thi... | [
"def",
"setup_metadata_db_path",
"(",
"self",
")",
":",
"settings",
"=",
"QSettings",
"(",
")",
"path",
"=",
"settings",
".",
"value",
"(",
"'inasafe.metadata35CachePath'",
",",
"self",
".",
"default_metadata_db_path",
"(",
")",
",",
"type",
"=",
"str",
")",
... | Helper to set the active path for the metadata.
Called at init time, you can override this path by calling
set_metadata_db_path.setmetadataDbPath.
:returns: The path to where the metadata file is. If the user has
never specified what this path is, the defaultmetadataDbPath is
... | [
"Helper",
"to",
"set",
"the",
"active",
"path",
"for",
"the",
"metadata",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata35/metadata_db_io.py#L78-L93 | train | 27,343 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | connect | def connect(receiver, signal=Any, sender=Any, weak=True):
"""Connect receiver to sender for signal
receiver -- a callable Python object which is to receive
messages/signals/events. Receivers must be hashable
objects.
if weak is True, then receiver must be weak-referencable
(mo... | python | def connect(receiver, signal=Any, sender=Any, weak=True):
"""Connect receiver to sender for signal
receiver -- a callable Python object which is to receive
messages/signals/events. Receivers must be hashable
objects.
if weak is True, then receiver must be weak-referencable
(mo... | [
"def",
"connect",
"(",
"receiver",
",",
"signal",
"=",
"Any",
",",
"sender",
"=",
"Any",
",",
"weak",
"=",
"True",
")",
":",
"if",
"signal",
"is",
"None",
":",
"raise",
"errors",
".",
"DispatcherTypeError",
"(",
"'Signal cannot be None (receiver=%r sender=%r)'... | Connect receiver to sender for signal
receiver -- a callable Python object which is to receive
messages/signals/events. Receivers must be hashable
objects.
if weak is True, then receiver must be weak-referencable
(more precisely saferef.safeRef() must be able to create
a r... | [
"Connect",
"receiver",
"to",
"sender",
"for",
"signal"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L73-L166 | train | 27,344 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | getReceivers | def getReceivers( sender = Any, signal = Any ):
"""Get list of receivers from global tables
This utility function allows you to retrieve the
raw list of receivers from the connections table
for the given sender and signal pair.
Note:
there is no guarantee that this is the actual list
... | python | def getReceivers( sender = Any, signal = Any ):
"""Get list of receivers from global tables
This utility function allows you to retrieve the
raw list of receivers from the connections table
for the given sender and signal pair.
Note:
there is no guarantee that this is the actual list
... | [
"def",
"getReceivers",
"(",
"sender",
"=",
"Any",
",",
"signal",
"=",
"Any",
")",
":",
"try",
":",
"return",
"connections",
"[",
"id",
"(",
"sender",
")",
"]",
"[",
"signal",
"]",
"except",
"KeyError",
":",
"return",
"[",
"]"
] | Get list of receivers from global tables
This utility function allows you to retrieve the
raw list of receivers from the connections table
for the given sender and signal pair.
Note:
there is no guarantee that this is the actual list
stored in the connections table, so the value
... | [
"Get",
"list",
"of",
"receivers",
"from",
"global",
"tables"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L225-L246 | train | 27,345 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | liveReceivers | def liveReceivers(receivers):
"""Filter sequence of receivers to get resolved, live receivers
This is a generator which will iterate over
the passed sequence, checking for weak references
and resolving them, then returning all live
receivers.
"""
for receiver in receivers:
if isinst... | python | def liveReceivers(receivers):
"""Filter sequence of receivers to get resolved, live receivers
This is a generator which will iterate over
the passed sequence, checking for weak references
and resolving them, then returning all live
receivers.
"""
for receiver in receivers:
if isinst... | [
"def",
"liveReceivers",
"(",
"receivers",
")",
":",
"for",
"receiver",
"in",
"receivers",
":",
"if",
"isinstance",
"(",
"receiver",
",",
"WEAKREF_TYPES",
")",
":",
"# Dereference the weak reference.",
"receiver",
"=",
"receiver",
"(",
")",
"if",
"receiver",
"is"... | Filter sequence of receivers to get resolved, live receivers
This is a generator which will iterate over
the passed sequence, checking for weak references
and resolving them, then returning all live
receivers. | [
"Filter",
"sequence",
"of",
"receivers",
"to",
"get",
"resolved",
"live",
"receivers"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L248-L263 | train | 27,346 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | getAllReceivers | def getAllReceivers( sender = Any, signal = Any ):
"""Get list of all receivers from global tables
This gets all receivers which should receive
the given signal from sender, each receiver should
be produced only once by the resulting generator
"""
receivers = {}
for set in (
# Get r... | python | def getAllReceivers( sender = Any, signal = Any ):
"""Get list of all receivers from global tables
This gets all receivers which should receive
the given signal from sender, each receiver should
be produced only once by the resulting generator
"""
receivers = {}
for set in (
# Get r... | [
"def",
"getAllReceivers",
"(",
"sender",
"=",
"Any",
",",
"signal",
"=",
"Any",
")",
":",
"receivers",
"=",
"{",
"}",
"for",
"set",
"in",
"(",
"# Get receivers that receive *this* signal from *this* sender.",
"getReceivers",
"(",
"sender",
",",
"signal",
")",
",... | Get list of all receivers from global tables
This gets all receivers which should receive
the given signal from sender, each receiver should
be produced only once by the resulting generator | [
"Get",
"list",
"of",
"all",
"receivers",
"from",
"global",
"tables"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L267-L293 | train | 27,347 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | sendExact | def sendExact( signal=Any, sender=Anonymous, *arguments, **named ):
"""Send signal only to those receivers registered for exact message
sendExact allows for avoiding Any/Anonymous registered
handlers, sending only to those receivers explicitly
registered for a particular signal on a particular
send... | python | def sendExact( signal=Any, sender=Anonymous, *arguments, **named ):
"""Send signal only to those receivers registered for exact message
sendExact allows for avoiding Any/Anonymous registered
handlers, sending only to those receivers explicitly
registered for a particular signal on a particular
send... | [
"def",
"sendExact",
"(",
"signal",
"=",
"Any",
",",
"sender",
"=",
"Anonymous",
",",
"*",
"arguments",
",",
"*",
"*",
"named",
")",
":",
"responses",
"=",
"[",
"]",
"for",
"receiver",
"in",
"liveReceivers",
"(",
"getReceivers",
"(",
"sender",
",",
"sig... | Send signal only to those receivers registered for exact message
sendExact allows for avoiding Any/Anonymous registered
handlers, sending only to those receivers explicitly
registered for a particular signal on a particular
sender. | [
"Send",
"signal",
"only",
"to",
"those",
"receivers",
"registered",
"for",
"exact",
"message"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L342-L360 | train | 27,348 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | _removeReceiver | def _removeReceiver(receiver):
"""Remove receiver from connections."""
if not sendersBack:
# During module cleanup the mapping will be replaced with None
return False
backKey = id(receiver)
try:
backSet = sendersBack.pop(backKey)
except KeyError:
return False
els... | python | def _removeReceiver(receiver):
"""Remove receiver from connections."""
if not sendersBack:
# During module cleanup the mapping will be replaced with None
return False
backKey = id(receiver)
try:
backSet = sendersBack.pop(backKey)
except KeyError:
return False
els... | [
"def",
"_removeReceiver",
"(",
"receiver",
")",
":",
"if",
"not",
"sendersBack",
":",
"# During module cleanup the mapping will be replaced with None",
"return",
"False",
"backKey",
"=",
"id",
"(",
"receiver",
")",
"try",
":",
"backSet",
"=",
"sendersBack",
".",
"po... | Remove receiver from connections. | [
"Remove",
"receiver",
"from",
"connections",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L363-L390 | train | 27,349 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | _cleanupConnections | def _cleanupConnections(senderkey, signal):
"""Delete any empty signals for senderkey. Delete senderkey if empty."""
try:
receivers = connections[senderkey][signal]
except:
pass
else:
if not receivers:
# No more connected receivers. Therefore, remove the signal.
... | python | def _cleanupConnections(senderkey, signal):
"""Delete any empty signals for senderkey. Delete senderkey if empty."""
try:
receivers = connections[senderkey][signal]
except:
pass
else:
if not receivers:
# No more connected receivers. Therefore, remove the signal.
... | [
"def",
"_cleanupConnections",
"(",
"senderkey",
",",
"signal",
")",
":",
"try",
":",
"receivers",
"=",
"connections",
"[",
"senderkey",
"]",
"[",
"signal",
"]",
"except",
":",
"pass",
"else",
":",
"if",
"not",
"receivers",
":",
"# No more connected receivers. ... | Delete any empty signals for senderkey. Delete senderkey if empty. | [
"Delete",
"any",
"empty",
"signals",
"for",
"senderkey",
".",
"Delete",
"senderkey",
"if",
"empty",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L392-L409 | train | 27,350 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | _removeBackrefs | def _removeBackrefs( senderkey):
"""Remove all back-references to this senderkey"""
try:
signals = connections[senderkey]
except KeyError:
signals = None
else:
items = signals.items()
def allReceivers( ):
for signal,set in items:
for item in se... | python | def _removeBackrefs( senderkey):
"""Remove all back-references to this senderkey"""
try:
signals = connections[senderkey]
except KeyError:
signals = None
else:
items = signals.items()
def allReceivers( ):
for signal,set in items:
for item in se... | [
"def",
"_removeBackrefs",
"(",
"senderkey",
")",
":",
"try",
":",
"signals",
"=",
"connections",
"[",
"senderkey",
"]",
"except",
"KeyError",
":",
"signals",
"=",
"None",
"else",
":",
"items",
"=",
"signals",
".",
"items",
"(",
")",
"def",
"allReceivers",
... | Remove all back-references to this senderkey | [
"Remove",
"all",
"back",
"-",
"references",
"to",
"this",
"senderkey"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L426-L439 | train | 27,351 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | _removeOldBackRefs | def _removeOldBackRefs(senderkey, signal, receiver, receivers):
"""Kill old sendersBack references from receiver
This guards against multiple registration of the same
receiver for a given signal and sender leaking memory
as old back reference records build up.
Also removes old receiver instance fr... | python | def _removeOldBackRefs(senderkey, signal, receiver, receivers):
"""Kill old sendersBack references from receiver
This guards against multiple registration of the same
receiver for a given signal and sender leaking memory
as old back reference records build up.
Also removes old receiver instance fr... | [
"def",
"_removeOldBackRefs",
"(",
"senderkey",
",",
"signal",
",",
"receiver",
",",
"receivers",
")",
":",
"try",
":",
"index",
"=",
"receivers",
".",
"index",
"(",
"receiver",
")",
"# need to scan back references here and remove senderkey",
"except",
"ValueError",
... | Kill old sendersBack references from receiver
This guards against multiple registration of the same
receiver for a given signal and sender leaking memory
as old back reference records build up.
Also removes old receiver instance from receivers | [
"Kill",
"old",
"sendersBack",
"references",
"from",
"receiver"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L441-L470 | train | 27,352 |
inasafe/inasafe | safe_extras/pydispatch/dispatcher.py | _killBackref | def _killBackref( receiver, senderkey ):
"""Do the actual removal of back reference from receiver to senderkey"""
receiverkey = id(receiver)
set = sendersBack.get( receiverkey, () )
while senderkey in set:
try:
set.remove( senderkey )
except:
break
if not set:... | python | def _killBackref( receiver, senderkey ):
"""Do the actual removal of back reference from receiver to senderkey"""
receiverkey = id(receiver)
set = sendersBack.get( receiverkey, () )
while senderkey in set:
try:
set.remove( senderkey )
except:
break
if not set:... | [
"def",
"_killBackref",
"(",
"receiver",
",",
"senderkey",
")",
":",
"receiverkey",
"=",
"id",
"(",
"receiver",
")",
"set",
"=",
"sendersBack",
".",
"get",
"(",
"receiverkey",
",",
"(",
")",
")",
"while",
"senderkey",
"in",
"set",
":",
"try",
":",
"set"... | Do the actual removal of back reference from receiver to senderkey | [
"Do",
"the",
"actual",
"removal",
"of",
"back",
"reference",
"from",
"receiver",
"to",
"senderkey"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L473-L487 | train | 27,353 |
inasafe/inasafe | safe/gui/tools/wizard/step_kw00_purpose.py | StepKwPurpose.on_lstCategories_itemSelectionChanged | def on_lstCategories_itemSelectionChanged(self):
"""Update purpose description label.
.. note:: This is an automatic Qt slot
executed when the purpose selection changes.
"""
self.clear_further_steps()
# Set widgets
purpose = self.selected_purpose()
# E... | python | def on_lstCategories_itemSelectionChanged(self):
"""Update purpose description label.
.. note:: This is an automatic Qt slot
executed when the purpose selection changes.
"""
self.clear_further_steps()
# Set widgets
purpose = self.selected_purpose()
# E... | [
"def",
"on_lstCategories_itemSelectionChanged",
"(",
"self",
")",
":",
"self",
".",
"clear_further_steps",
"(",
")",
"# Set widgets",
"purpose",
"=",
"self",
".",
"selected_purpose",
"(",
")",
"# Exit if no selection",
"if",
"not",
"purpose",
":",
"return",
"# Set d... | Update purpose description label.
.. note:: This is an automatic Qt slot
executed when the purpose selection changes. | [
"Update",
"purpose",
"description",
"label",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw00_purpose.py#L58-L76 | train | 27,354 |
inasafe/inasafe | safe/gui/tools/wizard/step_kw00_purpose.py | StepKwPurpose.selected_purpose | def selected_purpose(self):
"""Obtain the layer purpose selected by user.
:returns: Metadata of the selected layer purpose.
:rtype: dict, None
"""
item = self.lstCategories.currentItem()
try:
return definition(item.data(QtCore.Qt.UserRole))
except (At... | python | def selected_purpose(self):
"""Obtain the layer purpose selected by user.
:returns: Metadata of the selected layer purpose.
:rtype: dict, None
"""
item = self.lstCategories.currentItem()
try:
return definition(item.data(QtCore.Qt.UserRole))
except (At... | [
"def",
"selected_purpose",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"lstCategories",
".",
"currentItem",
"(",
")",
"try",
":",
"return",
"definition",
"(",
"item",
".",
"data",
"(",
"QtCore",
".",
"Qt",
".",
"UserRole",
")",
")",
"except",
"(",... | Obtain the layer purpose selected by user.
:returns: Metadata of the selected layer purpose.
:rtype: dict, None | [
"Obtain",
"the",
"layer",
"purpose",
"selected",
"by",
"user",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw00_purpose.py#L78-L88 | train | 27,355 |
inasafe/inasafe | safe/gui/tools/wizard/step_kw00_purpose.py | StepKwPurpose.set_widgets | def set_widgets(self):
"""Set widgets on the layer purpose tab."""
self.clear_further_steps()
# Set widgets
self.lstCategories.clear()
self.lblDescribeCategory.setText('')
self.lblIconCategory.setPixmap(QPixmap())
self.lblSelectCategory.setText(
catego... | python | def set_widgets(self):
"""Set widgets on the layer purpose tab."""
self.clear_further_steps()
# Set widgets
self.lstCategories.clear()
self.lblDescribeCategory.setText('')
self.lblIconCategory.setPixmap(QPixmap())
self.lblSelectCategory.setText(
catego... | [
"def",
"set_widgets",
"(",
"self",
")",
":",
"self",
".",
"clear_further_steps",
"(",
")",
"# Set widgets",
"self",
".",
"lstCategories",
".",
"clear",
"(",
")",
"self",
".",
"lblDescribeCategory",
".",
"setText",
"(",
"''",
")",
"self",
".",
"lblIconCategor... | Set widgets on the layer purpose tab. | [
"Set",
"widgets",
"on",
"the",
"layer",
"purpose",
"tab",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw00_purpose.py#L118-L153 | train | 27,356 |
inasafe/inasafe | safe/utilities/expressions.py | qgis_expressions | def qgis_expressions():
"""Retrieve all QGIS Expressions provided by InaSAFE.
:return: Dictionary of expression name and the expression itself.
:rtype: dict
"""
all_expressions = {
fct[0]: fct[1] for fct in getmembers(generic_expressions)
if fct[1].__class__.__name__ == 'QgsExpressi... | python | def qgis_expressions():
"""Retrieve all QGIS Expressions provided by InaSAFE.
:return: Dictionary of expression name and the expression itself.
:rtype: dict
"""
all_expressions = {
fct[0]: fct[1] for fct in getmembers(generic_expressions)
if fct[1].__class__.__name__ == 'QgsExpressi... | [
"def",
"qgis_expressions",
"(",
")",
":",
"all_expressions",
"=",
"{",
"fct",
"[",
"0",
"]",
":",
"fct",
"[",
"1",
"]",
"for",
"fct",
"in",
"getmembers",
"(",
"generic_expressions",
")",
"if",
"fct",
"[",
"1",
"]",
".",
"__class__",
".",
"__name__",
... | Retrieve all QGIS Expressions provided by InaSAFE.
:return: Dictionary of expression name and the expression itself.
:rtype: dict | [
"Retrieve",
"all",
"QGIS",
"Expressions",
"provided",
"by",
"InaSAFE",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/expressions.py#L16-L34 | train | 27,357 |
inasafe/inasafe | safe/processors/pre_processors.py | check_nearby_preprocessor | def check_nearby_preprocessor(impact_function):
"""Checker for the nearby preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool
"""
hazard_key = layer_purpose_hazard['key']
earthquake_key... | python | def check_nearby_preprocessor(impact_function):
"""Checker for the nearby preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool
"""
hazard_key = layer_purpose_hazard['key']
earthquake_key... | [
"def",
"check_nearby_preprocessor",
"(",
"impact_function",
")",
":",
"hazard_key",
"=",
"layer_purpose_hazard",
"[",
"'key'",
"]",
"earthquake_key",
"=",
"hazard_earthquake",
"[",
"'key'",
"]",
"exposure_key",
"=",
"layer_purpose_exposure",
"[",
"'key'",
"]",
"place_... | Checker for the nearby preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool | [
"Checker",
"for",
"the",
"nearby",
"preprocessor",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/processors/pre_processors.py#L32-L48 | train | 27,358 |
inasafe/inasafe | safe/processors/pre_processors.py | fake_nearby_preprocessor | def fake_nearby_preprocessor(impact_function):
"""Fake nearby preprocessor.
We can put here the function to generate contours or nearby places.
It must return a layer with a specific layer_purpose.
:return: The output layer.
:rtype: QgsMapLayer
"""
_ = impact_function # NOQA
from saf... | python | def fake_nearby_preprocessor(impact_function):
"""Fake nearby preprocessor.
We can put here the function to generate contours or nearby places.
It must return a layer with a specific layer_purpose.
:return: The output layer.
:rtype: QgsMapLayer
"""
_ = impact_function # NOQA
from saf... | [
"def",
"fake_nearby_preprocessor",
"(",
"impact_function",
")",
":",
"_",
"=",
"impact_function",
"# NOQA",
"from",
"safe",
".",
"test",
".",
"utilities",
"import",
"load_test_vector_layer",
"fake_layer",
"=",
"load_test_vector_layer",
"(",
"'gisv4'",
",",
"'impacts'"... | Fake nearby preprocessor.
We can put here the function to generate contours or nearby places.
It must return a layer with a specific layer_purpose.
:return: The output layer.
:rtype: QgsMapLayer | [
"Fake",
"nearby",
"preprocessor",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/processors/pre_processors.py#L51-L68 | train | 27,359 |
inasafe/inasafe | safe/processors/pre_processors.py | check_earthquake_contour_preprocessor | def check_earthquake_contour_preprocessor(impact_function):
"""Checker for the contour preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool
"""
hazard_key = impact_function.hazard.keywords.g... | python | def check_earthquake_contour_preprocessor(impact_function):
"""Checker for the contour preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool
"""
hazard_key = impact_function.hazard.keywords.g... | [
"def",
"check_earthquake_contour_preprocessor",
"(",
"impact_function",
")",
":",
"hazard_key",
"=",
"impact_function",
".",
"hazard",
".",
"keywords",
".",
"get",
"(",
"'hazard'",
")",
"is_earthquake",
"=",
"hazard_key",
"==",
"hazard_earthquake",
"[",
"'key'",
"]"... | Checker for the contour preprocessor.
:param impact_function: Impact function to check.
:type impact_function: ImpactFunction
:return: If the preprocessor can run.
:rtype: bool | [
"Checker",
"for",
"the",
"contour",
"preprocessor",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/processors/pre_processors.py#L88-L103 | train | 27,360 |
inasafe/inasafe | safe/processors/pre_processors.py | earthquake_contour_preprocessor | def earthquake_contour_preprocessor(impact_function):
"""Preprocessor to create contour from an earthquake
:param impact_function: Impact function to run.
:type impact_function: ImpactFunction
:return: The contour layer.
:rtype: QgsMapLayer
"""
contour_path = create_smooth_contour(impact_f... | python | def earthquake_contour_preprocessor(impact_function):
"""Preprocessor to create contour from an earthquake
:param impact_function: Impact function to run.
:type impact_function: ImpactFunction
:return: The contour layer.
:rtype: QgsMapLayer
"""
contour_path = create_smooth_contour(impact_f... | [
"def",
"earthquake_contour_preprocessor",
"(",
"impact_function",
")",
":",
"contour_path",
"=",
"create_smooth_contour",
"(",
"impact_function",
".",
"hazard",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"contour_path",
")",
":",
"from",
"safe",
".",
"gis... | Preprocessor to create contour from an earthquake
:param impact_function: Impact function to run.
:type impact_function: ImpactFunction
:return: The contour layer.
:rtype: QgsMapLayer | [
"Preprocessor",
"to",
"create",
"contour",
"from",
"an",
"earthquake"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/processors/pre_processors.py#L106-L119 | train | 27,361 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.set_mode_label_to_ifcw | def set_mode_label_to_ifcw(self):
"""Set the mode label to the IFCW."""
self.setWindowTitle(self.ifcw_name)
self.lblSubtitle.setText(tr(
'Use this wizard to run a guided impact assessment')) | python | def set_mode_label_to_ifcw(self):
"""Set the mode label to the IFCW."""
self.setWindowTitle(self.ifcw_name)
self.lblSubtitle.setText(tr(
'Use this wizard to run a guided impact assessment')) | [
"def",
"set_mode_label_to_ifcw",
"(",
"self",
")",
":",
"self",
".",
"setWindowTitle",
"(",
"self",
".",
"ifcw_name",
")",
"self",
".",
"lblSubtitle",
".",
"setText",
"(",
"tr",
"(",
"'Use this wizard to run a guided impact assessment'",
")",
")"
] | Set the mode label to the IFCW. | [
"Set",
"the",
"mode",
"label",
"to",
"the",
"IFCW",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L264-L268 | train | 27,362 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.set_keywords_creation_mode | def set_keywords_creation_mode(self, layer=None, keywords=None):
"""Set the Wizard to the Keywords Creation mode.
:param layer: Layer to set the keywords for
:type layer: QgsMapLayer
:param keywords: Keywords for the layer.
:type keywords: dict, None
"""
self.la... | python | def set_keywords_creation_mode(self, layer=None, keywords=None):
"""Set the Wizard to the Keywords Creation mode.
:param layer: Layer to set the keywords for
:type layer: QgsMapLayer
:param keywords: Keywords for the layer.
:type keywords: dict, None
"""
self.la... | [
"def",
"set_keywords_creation_mode",
"(",
"self",
",",
"layer",
"=",
"None",
",",
"keywords",
"=",
"None",
")",
":",
"self",
".",
"layer",
"=",
"layer",
"or",
"self",
".",
"iface",
".",
"mapCanvas",
"(",
")",
".",
"currentLayer",
"(",
")",
"if",
"keywo... | Set the Wizard to the Keywords Creation mode.
:param layer: Layer to set the keywords for
:type layer: QgsMapLayer
:param keywords: Keywords for the layer.
:type keywords: dict, None | [
"Set",
"the",
"Wizard",
"to",
"the",
"Keywords",
"Creation",
"mode",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L270-L300 | train | 27,363 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.set_function_centric_mode | def set_function_centric_mode(self):
"""Set the Wizard to the Function Centric mode."""
self.set_mode_label_to_ifcw()
step = self.step_fc_functions1
step.set_widgets()
self.go_to_step(step) | python | def set_function_centric_mode(self):
"""Set the Wizard to the Function Centric mode."""
self.set_mode_label_to_ifcw()
step = self.step_fc_functions1
step.set_widgets()
self.go_to_step(step) | [
"def",
"set_function_centric_mode",
"(",
"self",
")",
":",
"self",
".",
"set_mode_label_to_ifcw",
"(",
")",
"step",
"=",
"self",
".",
"step_fc_functions1",
"step",
".",
"set_widgets",
"(",
")",
"self",
".",
"go_to_step",
"(",
"step",
")"
] | Set the Wizard to the Function Centric mode. | [
"Set",
"the",
"Wizard",
"to",
"the",
"Function",
"Centric",
"mode",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L302-L308 | train | 27,364 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.field_keyword_for_the_layer | def field_keyword_for_the_layer(self):
"""Return the proper keyword for field for the current layer.
:returns: the field keyword
:rtype: str
"""
layer_purpose_key = self.step_kw_purpose.selected_purpose()['key']
if layer_purpose_key == layer_purpose_aggregation['key']:
... | python | def field_keyword_for_the_layer(self):
"""Return the proper keyword for field for the current layer.
:returns: the field keyword
:rtype: str
"""
layer_purpose_key = self.step_kw_purpose.selected_purpose()['key']
if layer_purpose_key == layer_purpose_aggregation['key']:
... | [
"def",
"field_keyword_for_the_layer",
"(",
"self",
")",
":",
"layer_purpose_key",
"=",
"self",
".",
"step_kw_purpose",
".",
"selected_purpose",
"(",
")",
"[",
"'key'",
"]",
"if",
"layer_purpose_key",
"==",
"layer_purpose_aggregation",
"[",
"'key'",
"]",
":",
"retu... | Return the proper keyword for field for the current layer.
:returns: the field keyword
:rtype: str | [
"Return",
"the",
"proper",
"keyword",
"for",
"field",
"for",
"the",
"current",
"layer",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L310-L326 | train | 27,365 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.get_parent_mode_constraints | def get_parent_mode_constraints(self):
"""Return the category and subcategory keys to be set in the
subordinate mode.
:returns: (the category definition, the hazard/exposure definition)
:rtype: (dict, dict)
"""
h, e, _hc, _ec = self.selected_impact_function_constraints()... | python | def get_parent_mode_constraints(self):
"""Return the category and subcategory keys to be set in the
subordinate mode.
:returns: (the category definition, the hazard/exposure definition)
:rtype: (dict, dict)
"""
h, e, _hc, _ec = self.selected_impact_function_constraints()... | [
"def",
"get_parent_mode_constraints",
"(",
"self",
")",
":",
"h",
",",
"e",
",",
"_hc",
",",
"_ec",
"=",
"self",
".",
"selected_impact_function_constraints",
"(",
")",
"if",
"self",
".",
"parent_step",
"in",
"[",
"self",
".",
"step_fc_hazlayer_from_canvas",
",... | Return the category and subcategory keys to be set in the
subordinate mode.
:returns: (the category definition, the hazard/exposure definition)
:rtype: (dict, dict) | [
"Return",
"the",
"category",
"and",
"subcategory",
"keys",
"to",
"be",
"set",
"in",
"the",
"subordinate",
"mode",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L328-L350 | train | 27,366 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.selected_impact_function_constraints | def selected_impact_function_constraints(self):
"""Obtain impact function constraints selected by user.
:returns: Tuple of metadata of hazard, exposure,
hazard layer geometry and exposure layer geometry
:rtype: tuple
"""
hazard = self.step_fc_functions1.selected_val... | python | def selected_impact_function_constraints(self):
"""Obtain impact function constraints selected by user.
:returns: Tuple of metadata of hazard, exposure,
hazard layer geometry and exposure layer geometry
:rtype: tuple
"""
hazard = self.step_fc_functions1.selected_val... | [
"def",
"selected_impact_function_constraints",
"(",
"self",
")",
":",
"hazard",
"=",
"self",
".",
"step_fc_functions1",
".",
"selected_value",
"(",
"layer_purpose_hazard",
"[",
"'key'",
"]",
")",
"exposure",
"=",
"self",
".",
"step_fc_functions1",
".",
"selected_val... | Obtain impact function constraints selected by user.
:returns: Tuple of metadata of hazard, exposure,
hazard layer geometry and exposure layer geometry
:rtype: tuple | [
"Obtain",
"impact",
"function",
"constraints",
"selected",
"by",
"user",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L352-L369 | train | 27,367 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.is_layer_compatible | def is_layer_compatible(self, layer, layer_purpose=None, keywords=None):
"""Validate if a given layer is compatible for selected IF
as a given layer_purpose
:param layer: The layer to be validated
:type layer: QgsVectorLayer | QgsRasterLayer
:param layer_purpose: The layer_p... | python | def is_layer_compatible(self, layer, layer_purpose=None, keywords=None):
"""Validate if a given layer is compatible for selected IF
as a given layer_purpose
:param layer: The layer to be validated
:type layer: QgsVectorLayer | QgsRasterLayer
:param layer_purpose: The layer_p... | [
"def",
"is_layer_compatible",
"(",
"self",
",",
"layer",
",",
"layer_purpose",
"=",
"None",
",",
"keywords",
"=",
"None",
")",
":",
"# If not explicitly stated, find the desired purpose",
"# from the parent step",
"if",
"not",
"layer_purpose",
":",
"layer_purpose",
"=",... | Validate if a given layer is compatible for selected IF
as a given layer_purpose
:param layer: The layer to be validated
:type layer: QgsVectorLayer | QgsRasterLayer
:param layer_purpose: The layer_purpose the layer is validated for
:type layer_purpose: None, string
... | [
"Validate",
"if",
"a",
"given",
"layer",
"is",
"compatible",
"for",
"selected",
"IF",
"as",
"a",
"given",
"layer_purpose"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L371-L448 | train | 27,368 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.get_compatible_canvas_layers | def get_compatible_canvas_layers(self, category):
"""Collect layers from map canvas, compatible for the given category
and selected impact function
.. note:: Returns layers with keywords and layermode matching
the category and compatible with the selected impact function.
... | python | def get_compatible_canvas_layers(self, category):
"""Collect layers from map canvas, compatible for the given category
and selected impact function
.. note:: Returns layers with keywords and layermode matching
the category and compatible with the selected impact function.
... | [
"def",
"get_compatible_canvas_layers",
"(",
"self",
",",
"category",
")",
":",
"# Collect compatible layers",
"layers",
"=",
"[",
"]",
"for",
"layer",
"in",
"self",
".",
"iface",
".",
"mapCanvas",
"(",
")",
".",
"layers",
"(",
")",
":",
"try",
":",
"keywor... | Collect layers from map canvas, compatible for the given category
and selected impact function
.. note:: Returns layers with keywords and layermode matching
the category and compatible with the selected impact function.
Also returns layers without keywords with layermode
... | [
"Collect",
"layers",
"from",
"map",
"canvas",
"compatible",
"for",
"the",
"given",
"category",
"and",
"selected",
"impact",
"function"
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L450-L492 | train | 27,369 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.get_existing_keyword | def get_existing_keyword(self, keyword):
"""Obtain an existing keyword's value.
:param keyword: A keyword from keywords.
:type keyword: str
:returns: The value of the keyword.
:rtype: str, QUrl
"""
if self.existing_keywords is None:
return {}
... | python | def get_existing_keyword(self, keyword):
"""Obtain an existing keyword's value.
:param keyword: A keyword from keywords.
:type keyword: str
:returns: The value of the keyword.
:rtype: str, QUrl
"""
if self.existing_keywords is None:
return {}
... | [
"def",
"get_existing_keyword",
"(",
"self",
",",
"keyword",
")",
":",
"if",
"self",
".",
"existing_keywords",
"is",
"None",
":",
"return",
"{",
"}",
"if",
"keyword",
"is",
"not",
"None",
":",
"return",
"self",
".",
"existing_keywords",
".",
"get",
"(",
"... | Obtain an existing keyword's value.
:param keyword: A keyword from keywords.
:type keyword: str
:returns: The value of the keyword.
:rtype: str, QUrl | [
"Obtain",
"an",
"existing",
"keyword",
"s",
"value",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L509-L523 | train | 27,370 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.get_layer_description_from_canvas | def get_layer_description_from_canvas(self, layer, purpose):
"""Obtain the description of a canvas layer selected by user.
:param layer: The QGIS layer.
:type layer: QgsMapLayer
:param purpose: The layer purpose of the layer to get the description.
:type purpose: string
... | python | def get_layer_description_from_canvas(self, layer, purpose):
"""Obtain the description of a canvas layer selected by user.
:param layer: The QGIS layer.
:type layer: QgsMapLayer
:param purpose: The layer purpose of the layer to get the description.
:type purpose: string
... | [
"def",
"get_layer_description_from_canvas",
"(",
"self",
",",
"layer",
",",
"purpose",
")",
":",
"if",
"not",
"layer",
":",
"return",
"\"\"",
"try",
":",
"keywords",
"=",
"self",
".",
"keyword_io",
".",
"read_keywords",
"(",
"layer",
")",
"if",
"'layer_purpo... | Obtain the description of a canvas layer selected by user.
:param layer: The QGIS layer.
:type layer: QgsMapLayer
:param purpose: The layer purpose of the layer to get the description.
:type purpose: string
:returns: description of the selected layer.
:rtype: string | [
"Obtain",
"the",
"description",
"of",
"a",
"canvas",
"layer",
"selected",
"by",
"user",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L525-L570 | train | 27,371 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.go_to_step | def go_to_step(self, step):
"""Set the stacked widget to the given step, set up the buttons,
and run all operations that should start immediately after
entering the new step.
:param step: The step widget to be moved to.
:type step: WizardStep
"""
self.stack... | python | def go_to_step(self, step):
"""Set the stacked widget to the given step, set up the buttons,
and run all operations that should start immediately after
entering the new step.
:param step: The step widget to be moved to.
:type step: WizardStep
"""
self.stack... | [
"def",
"go_to_step",
"(",
"self",
",",
"step",
")",
":",
"self",
".",
"stackedWidget",
".",
"setCurrentWidget",
"(",
"step",
")",
"# Disable the Next button unless new data already entered",
"self",
".",
"pbnNext",
".",
"setEnabled",
"(",
"step",
".",
"is_ready_to_n... | Set the stacked widget to the given step, set up the buttons,
and run all operations that should start immediately after
entering the new step.
:param step: The step widget to be moved to.
:type step: WizardStep | [
"Set",
"the",
"stacked",
"widget",
"to",
"the",
"given",
"step",
"set",
"up",
"the",
"buttons",
"and",
"run",
"all",
"operations",
"that",
"should",
"start",
"immediately",
"after",
"entering",
"the",
"new",
"step",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L576-L618 | train | 27,372 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.on_pbnNext_released | def on_pbnNext_released(self):
"""Handle the Next button release.
.. note:: This is an automatic Qt slot
executed when the Next button is released.
"""
current_step = self.get_current_step()
if current_step == self.step_kw_fields_mapping:
try:
... | python | def on_pbnNext_released(self):
"""Handle the Next button release.
.. note:: This is an automatic Qt slot
executed when the Next button is released.
"""
current_step = self.get_current_step()
if current_step == self.step_kw_fields_mapping:
try:
... | [
"def",
"on_pbnNext_released",
"(",
"self",
")",
":",
"current_step",
"=",
"self",
".",
"get_current_step",
"(",
")",
"if",
"current_step",
"==",
"self",
".",
"step_kw_fields_mapping",
":",
"try",
":",
"self",
".",
"step_kw_fields_mapping",
".",
"get_field_mapping"... | Handle the Next button release.
.. note:: This is an automatic Qt slot
executed when the Next button is released. | [
"Handle",
"the",
"Next",
"button",
"release",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L623-L680 | train | 27,373 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.on_pbnBack_released | def on_pbnBack_released(self):
"""Handle the Back button release.
.. note:: This is an automatic Qt slot
executed when the Back button is released.
"""
current_step = self.get_current_step()
if current_step.step_type == STEP_FC:
new_step = self.impact_func... | python | def on_pbnBack_released(self):
"""Handle the Back button release.
.. note:: This is an automatic Qt slot
executed when the Back button is released.
"""
current_step = self.get_current_step()
if current_step.step_type == STEP_FC:
new_step = self.impact_func... | [
"def",
"on_pbnBack_released",
"(",
"self",
")",
":",
"current_step",
"=",
"self",
".",
"get_current_step",
"(",
")",
"if",
"current_step",
".",
"step_type",
"==",
"STEP_FC",
":",
"new_step",
"=",
"self",
".",
"impact_function_steps",
".",
"pop",
"(",
")",
"e... | Handle the Back button release.
.. note:: This is an automatic Qt slot
executed when the Back button is released. | [
"Handle",
"the",
"Back",
"button",
"release",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L685-L713 | train | 27,374 |
inasafe/inasafe | safe/gui/tools/wizard/wizard_dialog.py | WizardDialog.save_current_keywords | def save_current_keywords(self):
"""Save keywords to the layer.
It will write out the keywords for the current layer.
This method is based on the KeywordsDialog class.
"""
current_keywords = self.get_keywords()
try:
self.keyword_io.write_keywords(
... | python | def save_current_keywords(self):
"""Save keywords to the layer.
It will write out the keywords for the current layer.
This method is based on the KeywordsDialog class.
"""
current_keywords = self.get_keywords()
try:
self.keyword_io.write_keywords(
... | [
"def",
"save_current_keywords",
"(",
"self",
")",
":",
"current_keywords",
"=",
"self",
".",
"get_keywords",
"(",
")",
"try",
":",
"self",
".",
"keyword_io",
".",
"write_keywords",
"(",
"layer",
"=",
"self",
".",
"layer",
",",
"keywords",
"=",
"current_keywo... | Save keywords to the layer.
It will write out the keywords for the current layer.
This method is based on the KeywordsDialog class. | [
"Save",
"keywords",
"to",
"the",
"layer",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/wizard_dialog.py#L850-L878 | train | 27,375 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc00_functions1.py | StepFcFunctions1.populate_function_table_1 | def populate_function_table_1(self):
"""Populate the tblFunctions1 table with available functions."""
hazards = deepcopy(hazard_all)
exposures = exposure_all
self.lblAvailableFunctions1.clear()
self.tblFunctions1.clear()
self.tblFunctions1.setColumnCount(len(hazards))
... | python | def populate_function_table_1(self):
"""Populate the tblFunctions1 table with available functions."""
hazards = deepcopy(hazard_all)
exposures = exposure_all
self.lblAvailableFunctions1.clear()
self.tblFunctions1.clear()
self.tblFunctions1.setColumnCount(len(hazards))
... | [
"def",
"populate_function_table_1",
"(",
"self",
")",
":",
"hazards",
"=",
"deepcopy",
"(",
"hazard_all",
")",
"exposures",
"=",
"exposure_all",
"self",
".",
"lblAvailableFunctions1",
".",
"clear",
"(",
")",
"self",
".",
"tblFunctions1",
".",
"clear",
"(",
")"... | Populate the tblFunctions1 table with available functions. | [
"Populate",
"the",
"tblFunctions1",
"table",
"with",
"available",
"functions",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc00_functions1.py#L113-L157 | train | 27,376 |
inasafe/inasafe | safe/gui/tools/wizard/step_fc00_functions1.py | StepFcFunctions1.set_widgets | def set_widgets(self):
"""Set widgets on the Impact Functions Table 1 tab."""
self.tblFunctions1.horizontalHeader().setSectionResizeMode(
QHeaderView.Stretch)
self.tblFunctions1.verticalHeader().setSectionResizeMode(
QHeaderView.Stretch)
self.populate_function_ta... | python | def set_widgets(self):
"""Set widgets on the Impact Functions Table 1 tab."""
self.tblFunctions1.horizontalHeader().setSectionResizeMode(
QHeaderView.Stretch)
self.tblFunctions1.verticalHeader().setSectionResizeMode(
QHeaderView.Stretch)
self.populate_function_ta... | [
"def",
"set_widgets",
"(",
"self",
")",
":",
"self",
".",
"tblFunctions1",
".",
"horizontalHeader",
"(",
")",
".",
"setSectionResizeMode",
"(",
"QHeaderView",
".",
"Stretch",
")",
"self",
".",
"tblFunctions1",
".",
"verticalHeader",
"(",
")",
".",
"setSectionR... | Set widgets on the Impact Functions Table 1 tab. | [
"Set",
"widgets",
"on",
"the",
"Impact",
"Functions",
"Table",
"1",
"tab",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_fc00_functions1.py#L159-L166 | train | 27,377 |
inasafe/inasafe | safe/gui/tools/help/dock_help.py | dock_help | def dock_help():
"""Help message for Dock Widget.
.. 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())
return message | python | def dock_help():
"""Help message for Dock Widget.
.. 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())
return message | [
"def",
"dock_help",
"(",
")",
":",
"message",
"=",
"m",
".",
"Message",
"(",
")",
"message",
".",
"add",
"(",
"m",
".",
"Brand",
"(",
")",
")",
"message",
".",
"add",
"(",
"heading",
"(",
")",
")",
"message",
".",
"add",
"(",
"content",
"(",
")... | Help message for Dock Widget.
.. versionadded:: 3.2.1
:returns: A message object containing helpful information.
:rtype: messaging.message.Message | [
"Help",
"message",
"for",
"Dock",
"Widget",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/dock_help.py#L20-L33 | train | 27,378 |
inasafe/inasafe | safe/utilities/keyword_io.py | KeywordIO.write_keywords | def write_keywords(layer, keywords):
"""Write keywords for a datasource.
This is a wrapper method that will 'do the right thing' to store
keywords for the given datasource. In particular, if the datasource
is remote (e.g. a database connection) it will write the keywords from
th... | python | def write_keywords(layer, keywords):
"""Write keywords for a datasource.
This is a wrapper method that will 'do the right thing' to store
keywords for the given datasource. In particular, if the datasource
is remote (e.g. a database connection) it will write the keywords from
th... | [
"def",
"write_keywords",
"(",
"layer",
",",
"keywords",
")",
":",
"if",
"not",
"isinstance",
"(",
"layer",
",",
"QgsMapLayer",
")",
":",
"raise",
"Exception",
"(",
"tr",
"(",
"'The layer is not a QgsMapLayer : {type}'",
")",
".",
"format",
"(",
"type",
"=",
... | Write keywords for a datasource.
This is a wrapper method that will 'do the right thing' to store
keywords for the given datasource. In particular, if the datasource
is remote (e.g. a database connection) it will write the keywords from
the keywords store.
:param layer: A QGIS ... | [
"Write",
"keywords",
"for",
"a",
"datasource",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/keyword_io.py#L82-L105 | train | 27,379 |
inasafe/inasafe | safe/utilities/keyword_io.py | KeywordIO.to_message | def to_message(self, keywords=None, show_header=True):
"""Format keywords as a message object.
.. versionadded:: 3.2
.. versionchanged:: 3.3 - default keywords to None
The message object can then be rendered to html, plain text etc.
:param keywords: Keywords to be converted t... | python | def to_message(self, keywords=None, show_header=True):
"""Format keywords as a message object.
.. versionadded:: 3.2
.. versionchanged:: 3.3 - default keywords to None
The message object can then be rendered to html, plain text etc.
:param keywords: Keywords to be converted t... | [
"def",
"to_message",
"(",
"self",
",",
"keywords",
"=",
"None",
",",
"show_header",
"=",
"True",
")",
":",
"if",
"keywords",
"is",
"None",
"and",
"self",
".",
"layer",
"is",
"not",
"None",
":",
"keywords",
"=",
"self",
".",
"read_keywords",
"(",
"self"... | Format keywords as a message object.
.. versionadded:: 3.2
.. versionchanged:: 3.3 - default keywords to None
The message object can then be rendered to html, plain text etc.
:param keywords: Keywords to be converted to a message. Optional. If
not passed then we will atte... | [
"Format",
"keywords",
"as",
"a",
"message",
"object",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/keyword_io.py#L109-L199 | train | 27,380 |
inasafe/inasafe | safe/utilities/keyword_io.py | KeywordIO._keyword_to_row | def _keyword_to_row(self, keyword, value, wrap_slash=False):
"""Helper to make a message row from a keyword.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object.
:param keyword: The keyword to be rendered.
:type... | python | def _keyword_to_row(self, keyword, value, wrap_slash=False):
"""Helper to make a message row from a keyword.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object.
:param keyword: The keyword to be rendered.
:type... | [
"def",
"_keyword_to_row",
"(",
"self",
",",
"keyword",
",",
"value",
",",
"wrap_slash",
"=",
"False",
")",
":",
"row",
"=",
"m",
".",
"Row",
"(",
")",
"# Translate titles explicitly if possible",
"if",
"keyword",
"==",
"'title'",
":",
"value",
"=",
"tr",
"... | Helper to make a message row from a keyword.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object.
:param keyword: The keyword to be rendered.
:type keyword: str
:param value: Value of the keyword to be rendered... | [
"Helper",
"to",
"make",
"a",
"message",
"row",
"from",
"a",
"keyword",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/keyword_io.py#L201-L306 | train | 27,381 |
inasafe/inasafe | safe/utilities/keyword_io.py | KeywordIO._dict_to_row | def _dict_to_row(keyword_value, keyword_property=None):
"""Helper to make a message row from a keyword where value is a dict.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object. This variant will unpack the dict and
pre... | python | def _dict_to_row(keyword_value, keyword_property=None):
"""Helper to make a message row from a keyword where value is a dict.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object. This variant will unpack the dict and
pre... | [
"def",
"_dict_to_row",
"(",
"keyword_value",
",",
"keyword_property",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"keyword_value",
",",
"str",
")",
":",
"keyword_value",
"=",
"literal_eval",
"(",
"keyword_value",
")",
"table",
"=",
"m",
".",
"Table",
"("... | Helper to make a message row from a keyword where value is a dict.
.. versionadded:: 3.2
Use this when constructing a table from keywords to display as
part of a message object. This variant will unpack the dict and
present it nicely in the keyword value area as a nested table in the
... | [
"Helper",
"to",
"make",
"a",
"message",
"row",
"from",
"a",
"keyword",
"where",
"value",
"is",
"a",
"dict",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/keyword_io.py#L445-L531 | train | 27,382 |
inasafe/inasafe | safe/utilities/keyword_io.py | KeywordIO._value_maps_row | def _value_maps_row(value_maps_keyword):
"""Helper to make a message row from a value maps.
Expected keywords:
'value_maps': {
'structure': {
'ina_structure_flood_hazard_classification': {
'classes': {
'low': [1, 2, 3],
... | python | def _value_maps_row(value_maps_keyword):
"""Helper to make a message row from a value maps.
Expected keywords:
'value_maps': {
'structure': {
'ina_structure_flood_hazard_classification': {
'classes': {
'low': [1, 2, 3],
... | [
"def",
"_value_maps_row",
"(",
"value_maps_keyword",
")",
":",
"if",
"isinstance",
"(",
"value_maps_keyword",
",",
"str",
")",
":",
"value_maps_keyword",
"=",
"literal_eval",
"(",
"value_maps_keyword",
")",
"table",
"=",
"m",
".",
"Table",
"(",
"style_class",
"=... | Helper to make a message row from a value maps.
Expected keywords:
'value_maps': {
'structure': {
'ina_structure_flood_hazard_classification': {
'classes': {
'low': [1, 2, 3],
'medium': [4],
... | [
"Helper",
"to",
"make",
"a",
"message",
"row",
"from",
"a",
"value",
"maps",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/utilities/keyword_io.py#L534-L642 | train | 27,383 |
inasafe/inasafe | safe/gis/vector/intersection.py | intersection | def intersection(source, mask):
"""Intersect two layers.
Issue https://github.com/inasafe/inasafe/issues/3186
:param source: The vector layer to clip.
:type source: QgsVectorLayer
:param mask: The vector layer to use for clipping.
:type mask: QgsVectorLayer
:return: The clip vector layer... | python | def intersection(source, mask):
"""Intersect two layers.
Issue https://github.com/inasafe/inasafe/issues/3186
:param source: The vector layer to clip.
:type source: QgsVectorLayer
:param mask: The vector layer to use for clipping.
:type mask: QgsVectorLayer
:return: The clip vector layer... | [
"def",
"intersection",
"(",
"source",
",",
"mask",
")",
":",
"output_layer_name",
"=",
"intersection_steps",
"[",
"'output_layer_name'",
"]",
"output_layer_name",
"=",
"output_layer_name",
"%",
"(",
"source",
".",
"keywords",
"[",
"'layer_purpose'",
"]",
")",
"par... | Intersect two layers.
Issue https://github.com/inasafe/inasafe/issues/3186
:param source: The vector layer to clip.
:type source: QgsVectorLayer
:param mask: The vector layer to use for clipping.
:type mask: QgsVectorLayer
:return: The clip vector layer.
:rtype: QgsVectorLayer
.. ve... | [
"Intersect",
"two",
"layers",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/intersection.py#L28-L79 | train | 27,384 |
inasafe/inasafe | safe/gui/tools/help/field_mapping_help.py | field_mapping_help | def field_mapping_help():
"""Help message for field mapping Dialog.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())
... | python | def field_mapping_help():
"""Help message for field mapping Dialog.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())
... | [
"def",
"field_mapping_help",
"(",
")",
":",
"message",
"=",
"m",
".",
"Message",
"(",
")",
"message",
".",
"add",
"(",
"m",
".",
"Brand",
"(",
")",
")",
"message",
".",
"add",
"(",
"heading",
"(",
")",
")",
"message",
".",
"add",
"(",
"content",
... | Help message for field mapping Dialog.
.. versionadded:: 4.1.0
:returns: A message object containing helpful information.
:rtype: messaging.message.Message | [
"Help",
"message",
"for",
"field",
"mapping",
"Dialog",
"."
] | 831d60abba919f6d481dc94a8d988cc205130724 | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/field_mapping_help.py#L20-L32 | train | 27,385 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_init.py | TcExInit._print_results | def _print_results(file, status):
"""Print the download results.
Args:
file (str): The filename.
status (str): The file download status.
"""
file_color = c.Fore.GREEN
status_color = c.Fore.RED
if status == 'Success':
status_color = c.... | python | def _print_results(file, status):
"""Print the download results.
Args:
file (str): The filename.
status (str): The file download status.
"""
file_color = c.Fore.GREEN
status_color = c.Fore.RED
if status == 'Success':
status_color = c.... | [
"def",
"_print_results",
"(",
"file",
",",
"status",
")",
":",
"file_color",
"=",
"c",
".",
"Fore",
".",
"GREEN",
"status_color",
"=",
"c",
".",
"Fore",
".",
"RED",
"if",
"status",
"==",
"'Success'",
":",
"status_color",
"=",
"c",
".",
"Fore",
".",
"... | Print the download results.
Args:
file (str): The filename.
status (str): The file download status. | [
"Print",
"the",
"download",
"results",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_init.py#L34-L59 | train | 27,386 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_init.py | TcExInit._confirm_overwrite | def _confirm_overwrite(filename):
"""Confirm overwrite of template files.
Make sure the user would like to continue downloading a file which will overwrite a file
in the current directory.
Args:
filename (str): The name of the file to overwrite.
Returns:
... | python | def _confirm_overwrite(filename):
"""Confirm overwrite of template files.
Make sure the user would like to continue downloading a file which will overwrite a file
in the current directory.
Args:
filename (str): The name of the file to overwrite.
Returns:
... | [
"def",
"_confirm_overwrite",
"(",
"filename",
")",
":",
"message",
"=",
"'{}Would you like to overwrite the contents of {} (y/[n])? '",
".",
"format",
"(",
"c",
".",
"Fore",
".",
"MAGENTA",
",",
"filename",
")",
"# 2to3 fixes this for py3",
"response",
"=",
"raw_input",... | Confirm overwrite of template files.
Make sure the user would like to continue downloading a file which will overwrite a file
in the current directory.
Args:
filename (str): The name of the file to overwrite.
Returns:
bool: True if the user specifies a "yes" re... | [
"Confirm",
"overwrite",
"of",
"template",
"files",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_init.py#L62-L84 | train | 27,387 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_init.py | TcExInit.check_empty_app_dir | def check_empty_app_dir(self):
"""Check to see if the directory in which the app is going to be created is empty."""
if not os.listdir(self.app_path):
self.handle_error(
'No app exists in this directory. Try using "tcinit --template '
'{} --action create" to c... | python | def check_empty_app_dir(self):
"""Check to see if the directory in which the app is going to be created is empty."""
if not os.listdir(self.app_path):
self.handle_error(
'No app exists in this directory. Try using "tcinit --template '
'{} --action create" to c... | [
"def",
"check_empty_app_dir",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"listdir",
"(",
"self",
".",
"app_path",
")",
":",
"self",
".",
"handle_error",
"(",
"'No app exists in this directory. Try using \"tcinit --template '",
"'{} --action create\" to create an app.'... | Check to see if the directory in which the app is going to be created is empty. | [
"Check",
"to",
"see",
"if",
"the",
"directory",
"in",
"which",
"the",
"app",
"is",
"going",
"to",
"be",
"created",
"is",
"empty",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_init.py#L86-L92 | train | 27,388 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_init.py | TcExInit.download_file | def download_file(self, remote_filename, local_filename=None):
"""Download file from github.
Args:
remote_filename (str): The name of the file as defined in git repository.
local_filename (str, optional): Defaults to None. The name of the file as it should be
be ... | python | def download_file(self, remote_filename, local_filename=None):
"""Download file from github.
Args:
remote_filename (str): The name of the file as defined in git repository.
local_filename (str, optional): Defaults to None. The name of the file as it should be
be ... | [
"def",
"download_file",
"(",
"self",
",",
"remote_filename",
",",
"local_filename",
"=",
"None",
")",
":",
"status",
"=",
"'Failed'",
"if",
"local_filename",
"is",
"None",
":",
"local_filename",
"=",
"remote_filename",
"if",
"not",
"self",
".",
"args",
".",
... | Download file from github.
Args:
remote_filename (str): The name of the file as defined in git repository.
local_filename (str, optional): Defaults to None. The name of the file as it should be
be written to local filesystem. | [
"Download",
"file",
"from",
"github",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_init.py#L94-L120 | train | 27,389 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_init.py | TcExInit.update_install_json | def update_install_json():
"""Update the install.json configuration file if exists."""
if not os.path.isfile('install.json'):
return
with open('install.json', 'r') as f:
install_json = json.load(f)
if install_json.get('programMain'):
install_json['pr... | python | def update_install_json():
"""Update the install.json configuration file if exists."""
if not os.path.isfile('install.json'):
return
with open('install.json', 'r') as f:
install_json = json.load(f)
if install_json.get('programMain'):
install_json['pr... | [
"def",
"update_install_json",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"'install.json'",
")",
":",
"return",
"with",
"open",
"(",
"'install.json'",
",",
"'r'",
")",
"as",
"f",
":",
"install_json",
"=",
"json",
".",
"load",
"("... | Update the install.json configuration file if exists. | [
"Update",
"the",
"install",
".",
"json",
"configuration",
"file",
"if",
"exists",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_init.py#L123-L138 | train | 27,390 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_init.py | TcExInit.update_tcex_json | def update_tcex_json(self):
"""Update the tcex.json configuration file if exists."""
if not os.path.isfile('tcex.json'):
return
# display warning on missing app_name field
if self.tcex_json.get('package', {}).get('app_name') is None:
print('{}The tcex.json file i... | python | def update_tcex_json(self):
"""Update the tcex.json configuration file if exists."""
if not os.path.isfile('tcex.json'):
return
# display warning on missing app_name field
if self.tcex_json.get('package', {}).get('app_name') is None:
print('{}The tcex.json file i... | [
"def",
"update_tcex_json",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"'tcex.json'",
")",
":",
"return",
"# display warning on missing app_name field",
"if",
"self",
".",
"tcex_json",
".",
"get",
"(",
"'package'",
",",
"{",
"}... | Update the tcex.json configuration file if exists. | [
"Update",
"the",
"tcex",
".",
"json",
"configuration",
"file",
"if",
"exists",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_init.py#L140-L194 | train | 27,391 |
ThreatConnect-Inc/tcex | tcex/tcex_ti/mappings/group/group_types/signature.py | Signature.download | def download(self):
"""
Downloads the signature.
Returns:
"""
if not self.can_update():
self._tcex.handle_error(910, [self.type])
return self.tc_requests.download(self.api_type, self.api_sub_type, self.unique_id) | python | def download(self):
"""
Downloads the signature.
Returns:
"""
if not self.can_update():
self._tcex.handle_error(910, [self.type])
return self.tc_requests.download(self.api_type, self.api_sub_type, self.unique_id) | [
"def",
"download",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"can_update",
"(",
")",
":",
"self",
".",
"_tcex",
".",
"handle_error",
"(",
"910",
",",
"[",
"self",
".",
"type",
"]",
")",
"return",
"self",
".",
"tc_requests",
".",
"download",
... | Downloads the signature.
Returns: | [
"Downloads",
"the",
"signature",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/mappings/group/group_types/signature.py#L36-L46 | train | 27,392 |
ThreatConnect-Inc/tcex | tcex/tcex_datastore.py | TcExDataStore._create_index | def _create_index(self):
"""Create index if it doesn't exist."""
if not self.index_exists:
index_settings = {}
headers = {'Content-Type': 'application/json', 'DB-Method': 'POST'}
url = '/v2/exchange/db/{}/{}'.format(self.domain, self.data_type)
r = self.tc... | python | def _create_index(self):
"""Create index if it doesn't exist."""
if not self.index_exists:
index_settings = {}
headers = {'Content-Type': 'application/json', 'DB-Method': 'POST'}
url = '/v2/exchange/db/{}/{}'.format(self.domain, self.data_type)
r = self.tc... | [
"def",
"_create_index",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"index_exists",
":",
"index_settings",
"=",
"{",
"}",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'DB-Method'",
":",
"'POST'",
"}",
"url",
"=",
"'/v2/exchang... | Create index if it doesn't exist. | [
"Create",
"index",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_datastore.py#L54-L67 | train | 27,393 |
ThreatConnect-Inc/tcex | tcex/tcex_datastore.py | TcExDataStore._update_mappings | def _update_mappings(self):
"""Update the mappings for the current index."""
headers = {'Content-Type': 'application/json', 'DB-Method': 'PUT'}
url = '/v2/exchange/db/{}/{}/_mappings'.format(self.domain, self.data_type)
r = self.tcex.session.post(url, json=self.mapping, headers=headers)
... | python | def _update_mappings(self):
"""Update the mappings for the current index."""
headers = {'Content-Type': 'application/json', 'DB-Method': 'PUT'}
url = '/v2/exchange/db/{}/{}/_mappings'.format(self.domain, self.data_type)
r = self.tcex.session.post(url, json=self.mapping, headers=headers)
... | [
"def",
"_update_mappings",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'DB-Method'",
":",
"'PUT'",
"}",
"url",
"=",
"'/v2/exchange/db/{}/{}/_mappings'",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
... | Update the mappings for the current index. | [
"Update",
"the",
"mappings",
"for",
"the",
"current",
"index",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_datastore.py#L69-L76 | train | 27,394 |
ThreatConnect-Inc/tcex | tcex/tcex_datastore.py | TcExDataStore.index_exists | def index_exists(self):
"""Check to see if index exists."""
headers = {'Content-Type': 'application/json', 'DB-Method': 'GET'}
url = '/v2/exchange/db/{}/{}/_search'.format(self.domain, self.data_type)
r = self.tcex.session.post(url, headers=headers)
if not r.ok:
self.... | python | def index_exists(self):
"""Check to see if index exists."""
headers = {'Content-Type': 'application/json', 'DB-Method': 'GET'}
url = '/v2/exchange/db/{}/{}/_search'.format(self.domain, self.data_type)
r = self.tcex.session.post(url, headers=headers)
if not r.ok:
self.... | [
"def",
"index_exists",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'DB-Method'",
":",
"'GET'",
"}",
"url",
"=",
"'/v2/exchange/db/{}/{}/_search'",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
... | Check to see if index exists. | [
"Check",
"to",
"see",
"if",
"index",
"exists",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_datastore.py#L79-L87 | train | 27,395 |
ThreatConnect-Inc/tcex | tcex/tcex_datastore.py | TcExDataStore.put | def put(self, rid, data, raise_on_error=True):
"""Update the data for the provided Id.
Args:
rid (str): The record identifier.
data (dict): A search query
raise_on_error (bool): If True and not r.ok this method will raise a RunTimeError.
Returns:
... | python | def put(self, rid, data, raise_on_error=True):
"""Update the data for the provided Id.
Args:
rid (str): The record identifier.
data (dict): A search query
raise_on_error (bool): If True and not r.ok this method will raise a RunTimeError.
Returns:
... | [
"def",
"put",
"(",
"self",
",",
"rid",
",",
"data",
",",
"raise_on_error",
"=",
"True",
")",
":",
"response_data",
"=",
"None",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'DB-Method'",
":",
"'PUT'",
"}",
"url",
"=",
"'/v2/excha... | Update the data for the provided Id.
Args:
rid (str): The record identifier.
data (dict): A search query
raise_on_error (bool): If True and not r.ok this method will raise a RunTimeError.
Returns:
object : Python request response. | [
"Update",
"the",
"data",
"for",
"the",
"provided",
"Id",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_datastore.py#L178-L199 | train | 27,396 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_run.py | TcExRun._create_tc_dirs | def _create_tc_dirs(self):
"""Create app directories for logs and data files."""
tc_log_path = self.profile.get('args', {}).get('tc_log_path')
if tc_log_path is not None and not os.path.isdir(tc_log_path):
os.makedirs(tc_log_path)
tc_out_path = self.profile.get('args', {}).ge... | python | def _create_tc_dirs(self):
"""Create app directories for logs and data files."""
tc_log_path = self.profile.get('args', {}).get('tc_log_path')
if tc_log_path is not None and not os.path.isdir(tc_log_path):
os.makedirs(tc_log_path)
tc_out_path = self.profile.get('args', {}).ge... | [
"def",
"_create_tc_dirs",
"(",
"self",
")",
":",
"tc_log_path",
"=",
"self",
".",
"profile",
".",
"get",
"(",
"'args'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'tc_log_path'",
")",
"if",
"tc_log_path",
"is",
"not",
"None",
"and",
"not",
"os",
".",
"pat... | Create app directories for logs and data files. | [
"Create",
"app",
"directories",
"for",
"logs",
"and",
"data",
"files",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L70-L80 | train | 27,397 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_run.py | TcExRun._logger | def _logger(self):
"""Create logger instance.
Returns:
logger: An instance of logging
"""
log_level = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': l... | python | def _logger(self):
"""Create logger instance.
Returns:
logger: An instance of logging
"""
log_level = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': l... | [
"def",
"_logger",
"(",
"self",
")",
":",
"log_level",
"=",
"{",
"'debug'",
":",
"logging",
".",
"DEBUG",
",",
"'info'",
":",
"logging",
".",
"INFO",
",",
"'warning'",
":",
"logging",
".",
"WARNING",
",",
"'error'",
":",
"logging",
".",
"ERROR",
",",
... | Create logger instance.
Returns:
logger: An instance of logging | [
"Create",
"logger",
"instance",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L110-L152 | train | 27,398 |
ThreatConnect-Inc/tcex | tcex/tcex_bin_run.py | TcExRun._signal_handler_init | def _signal_handler_init(self):
"""Catch interupt signals."""
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGINT, self._signal_handler)
signal.signal(signal.SIGTERM, self._signal_handler) | python | def _signal_handler_init(self):
"""Catch interupt signals."""
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGINT, self._signal_handler)
signal.signal(signal.SIGTERM, self._signal_handler) | [
"def",
"_signal_handler_init",
"(",
"self",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal",
".",
"SIG_IGN",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"self",
".",
"_signal_handler",
")",
"signal",
".... | Catch interupt signals. | [
"Catch",
"interupt",
"signals",
"."
] | dd4d7a1ef723af1561687120191886b9a2fd4b47 | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin_run.py#L154-L158 | train | 27,399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.