INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Remove duplicate map table if it exists | def deleteMapTable(self, name, session):
"""
Remove duplicate map table if it exists
"""
duplicate_map_tables = session.query(MapTable).filter(MapTable.mapTableFile == self).filter(MapTable.name == name).all()
for duplicate_map_table in duplicate_map_tables:
if dupli... |
Create GSSHAPY Mapping Table ORM Objects Method | def _createGsshaPyObjects(self, mapTables, indexMaps, replaceParamFile, directory, session, spatial, spatialReferenceID):
"""
Create GSSHAPY Mapping Table ORM Objects Method
"""
for mt in mapTables:
# Create GSSHAPY MapTable object
try:
# Make sure... |
Populate GSSHAPY MTValue and MTIndex Objects Method | def _createValueObjects(self, valueList, varList, mapTable, indexMap, contaminant, replaceParamFile):
"""
Populate GSSHAPY MTValue and MTIndex Objects Method
"""
def assign_values_to_table(value_list, layer_id):
for i, value in enumerate(value_list):
value = v... |
Read any contaminant output files if available | def _readContaminantOutputFiles(self, directory, baseFileName, session, spatial, spatialReferenceID):
"""
Read any contaminant output files if available
"""
if not os.path.isdir(directory):
return
if baseFileName == '':
return
# Look for channel o... |
Write Generic Map Table Method
This method writes a mapping table in the generic format to file. The method will handle
both empty and filled cases of generic formatted mapping tables.
session = SQLAlchemy session object for retrieving data from the database
fileObject = The file objec... | def _writeMapTable(self, session, fileObject, mapTable, replaceParamFile):
"""
Write Generic Map Table Method
This method writes a mapping table in the generic format to file. The method will handle
both empty and filled cases of generic formatted mapping tables.
session = SQLA... |
This method writes the contaminant transport mapping table case. | def _writeContaminantTable(self, session, fileObject, mapTable, contaminants, replaceParamFile):
"""
This method writes the contaminant transport mapping table case.
"""
# Write the contaminant mapping table header
fileObject.write('%s\n' % (mapTable.name))
fileObject.wri... |
Write Sediment Mapping Table Method
This method writes the sediments special mapping table case. | def _writeSedimentTable(self, session, fileObject, mapTable, replaceParamFile):
"""
Write Sediment Mapping Table Method
This method writes the sediments special mapping table case.
"""
# Write the sediment mapping table header
fileObject.write('%s\n' % (mapTable.name))
... |
This function retrieves the values of a mapping table from the database and pivots them into the format that is
required by the mapping table file. This function returns a list of strings that can be printed to the file
directly. | def _valuePivot(self, session, mapTable, contaminant, replaceParaFile):
"""
This function retrieves the values of a mapping table from the database and pivots them into the format that is
required by the mapping table file. This function returns a list of strings that can be printed to the file
... |
Preprocess the contaminant output file path to a relative path. | def _preprocessContaminantOutFilePath(outPath):
"""
Preprocess the contaminant output file path to a relative path.
"""
if '/' in outPath:
splitPath = outPath.split('/')
elif '\\' in outPath:
splitPath = outPath.split('\\')
else:
spli... |
Adds a roughness map from land use file
Example::
from gsshapy.orm import ProjectFile
from gsshapy.lib import db_tools as dbt
from os import path, chdir
gssha_directory = '/gsshapy/tests/grid_standard/gssha_project'
land_use_grid = 'LC_5min_global_... | def addRoughnessMapFromLandUse(self, name,
session,
land_use_grid,
land_use_to_roughness_table=None,
land_use_grid_id=None,
... |
Update wildcards set with the input data nodes that are also outputs.
:param inputs:
Input data nodes.
:type inputs: list[str], iterable, optional
:param outputs:
Ending data nodes.
:type outputs: list[str], iterable, optional | def _set_wildcards(self, inputs=None, outputs=None):
"""
Update wildcards set with the input data nodes that are also outputs.
:param inputs:
Input data nodes.
:type inputs: list[str], iterable, optional
:param outputs:
Ending data nodes.
:type o... |
Set all asynchronous results.
:param timeout:
The number of seconds to wait for the result if the futures aren't
done. If None, then there is no limit on the wait time.
:type timeout: float
:return:
Update Solution.
:rtype: Solution | def result(self, timeout=None):
"""
Set all asynchronous results.
:param timeout:
The number of seconds to wait for the result if the futures aren't
done. If None, then there is no limit on the wait time.
:type timeout: float
:return:
Update ... |
Returns the sub-dispatcher induced by the workflow from sources.
The induced sub-dispatcher of the dsp contains the reachable nodes and
edges evaluated with breadth-first-search on the workflow graph from
source nodes.
:param sources:
Source nodes for the breadth-first-searc... | def get_sub_dsp_from_workflow(self, sources, reverse=False,
add_missing=False, check_inputs=True):
"""
Returns the sub-dispatcher induced by the workflow from sources.
The induced sub-dispatcher of the dsp contains the reachable nodes and
edges evaluate... |
Returns a function to terminate the ArciDispatch algorithm when all
targets have been visited.
:return:
A function to terminate the ArciDispatch algorithm.
:rtype: (str) -> bool | def _check_targets(self):
"""
Returns a function to terminate the ArciDispatch algorithm when all
targets have been visited.
:return:
A function to terminate the ArciDispatch algorithm.
:rtype: (str) -> bool
"""
if self.outputs:
targets ... |
Returns a function to stop the search of the investigated node of the
ArciDispatch algorithm.
:return:
A function to stop the search.
:rtype: (int | float) -> bool | def _check_cutoff(self):
"""
Returns a function to stop the search of the investigated node of the
ArciDispatch algorithm.
:return:
A function to stop the search.
:rtype: (int | float) -> bool
"""
if self.cutoff is not None:
cutoff = sel... |
Returns a function to stop the search of the investigated node of the
ArciDispatch algorithm.
:return:
A function to stop the search.
:rtype: (bool, str) -> bool | def _check_wait_input_flag(self):
"""
Returns a function to stop the search of the investigated node of the
ArciDispatch algorithm.
:return:
A function to stop the search.
:rtype: (bool, str) -> bool
"""
wf_pred = self._wf_pred # Namespace shortcuts... |
Returns the data nodes estimations and `wait_inputs` flag.
:param node_attr:
Dictionary of node attributes.
:type node_attr: dict
:param node_id:
Data node's id.
:type node_id: str
:returns:
- node estimations with minimum distance from the... | def _get_node_estimations(self, node_attr, node_id):
"""
Returns the data nodes estimations and `wait_inputs` flag.
:param node_attr:
Dictionary of node attributes.
:type node_attr: dict
:param node_id:
Data node's id.
:type node_id: str
... |
Set the node outputs from node inputs.
:param node_id:
Data or function node id.
:type node_id: str
:param no_call:
If True data node estimation function is not used.
:type no_call: bool
:return:
If the output have been evaluated correctly.
... | def _set_node_output(self, node_id, no_call, next_nds=None, **kw):
"""
Set the node outputs from node inputs.
:param node_id:
Data or function node id.
:type node_id: str
:param no_call:
If True data node estimation function is not used.
:type no... |
Set the data node output from node estimations.
:param node_id:
Data node id.
:type node_id: str
:param node_attr:
Dictionary of node attributes.
:type node_attr: dict[str, T]
:param no_call:
If True data node estimations are not used.
... | def _set_data_node_output(self, node_id, node_attr, no_call, next_nds=None,
**kw):
"""
Set the data node output from node estimations.
:param node_id:
Data node id.
:type node_id: str
:param node_attr:
Dictionary of node att... |
Set the function node output from node inputs.
:param node_id:
Function node id.
:type node_id: str
:param node_attr:
Dictionary of node attributes.
:type node_attr: dict[str, T]
:param no_call:
If True data node estimation function is not u... | def _set_function_node_output(self, node_id, node_attr, no_call,
next_nds=None, **kw):
"""
Set the function node output from node inputs.
:param node_id:
Function node id.
:type node_id: str
:param node_attr:
Dictionary ... |
Add initial values updating workflow, seen, and fringe.
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | int, bool, (str, Dispatcher)]
:param check_cutoff:
Check the cutoff limit.
:type check_cutoff: (int | float) -> bool
:pa... | def _add_initial_value(self, data_id, value, initial_dist=0.0,
fringe=None, check_cutoff=None, no_call=None):
"""
Add initial values updating workflow, seen, and fringe.
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | i... |
Visits a node, updating workflow, seen, and fringe..
:param node_id:
Node id to visit.
:type node_id: str
:param dist:
Distance from the starting node.
:type dist: float, int
:param fringe:
Heapq of closest available nodes.
:type fri... | def _visit_nodes(self, node_id, dist, fringe, check_cutoff, no_call=False,
**kw):
"""
Visits a node, updating workflow, seen, and fringe..
:param node_id:
Node id to visit.
:type node_id: str
:param dist:
Distance from the starting n... |
See a node, updating seen and fringe.
:param node_id:
Node id to see.
:type node_id: str
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | int, bool, (str, Dispatcher)]
:param dist:
Distance from the starting node.... | def _see_node(self, node_id, fringe, dist, w_wait_in=0):
"""
See a node, updating seen and fringe.
:param node_id:
Node id to see.
:type node_id: str
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | int, bool, (str, Di... |
Initialize the dispatcher as sub-dispatcher and update the fringe.
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | int, bool, (str, Dispatcher)]
:param outputs:
Ending data nodes.
:type outputs: list[str], iterable
:param no... | def _init_sub_dsp(self, dsp, fringe, outputs, no_call, initial_dist, index,
full_name):
"""
Initialize the dispatcher as sub-dispatcher and update the fringe.
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | int, bool, (str, ... |
See data remote links of the node (set output to remote links).
:param node_id:
Node id.
:type node_id: str
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(float | int, bool, (str, Dispatcher)]
:param dist:
Distance from... | def _see_remote_link_node(self, node_id, fringe=None, dist=None,
check_dsp=lambda x: True):
"""
See data remote links of the node (set output to remote links).
:param node_id:
Node id.
:type node_id: str
:param fringe:
Heapq... |
Initializes the sub-dispatcher and set its inputs.
:param node_id:
Input node to set.
:type node_id: str
:param dsp_id:
Sub-dispatcher node id.
:type dsp_id: str
:param fringe:
Heapq of closest available nodes.
:type fringe: list[(fl... | def _set_sub_dsp_node_input(self, node_id, dsp_id, fringe, check_cutoff,
no_call, initial_dist):
"""
Initializes the sub-dispatcher and set its inputs.
:param node_id:
Input node to set.
:type node_id: str
:param dsp_id:
S... |
Handles the error messages.
.. note:: If `self.raises` is True the dispatcher interrupt the dispatch
when an error occur, otherwise it logs a warning. | def _warning(self, msg, node_id, ex, *args, **kwargs):
"""
Handles the error messages.
.. note:: If `self.raises` is True the dispatcher interrupt the dispatch
when an error occur, otherwise it logs a warning.
"""
raises = self.raises(ex) if callable(self.raises) els... |
Grid Stream File Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Grid Stream File Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Keywords
KEYWORDS = ('STREAMCELLS',
... |
Grid Stream File Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Grid Stream File Write to File Method
"""
# Write lines
openFile.write('GRIDSTREAMFILE\n')
openFile.write('STREAMCELLS %s\n' % self.streamCells)
for cell in self.gridStreamCells:
openFile.writ... |
Create GSSHAPY PipeGridCell and PipeGridNode Objects Method | def _createGsshaPyObjects(self, cell):
"""
Create GSSHAPY PipeGridCell and PipeGridNode Objects Method
"""
# Initialize GSSHAPY PipeGridCell object
gridCell = GridStreamCell(cellI=cell['i'],
cellJ=cell['j'],
numN... |
Index Map Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Index Map Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Open file and read plain text into text field
... |
Index Map Write to File Method | def write(self, directory, name=None, session=None, replaceParamFile=None):
"""
Index Map Write to File Method
"""
# Initiate file
if name != None:
filename = '%s.%s' % (name, self.fileExtension)
filePath = os.path.join(directory, filename)
else:
... |
Grid Pipe File Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Grid Pipe File Write to File Method
"""
# Write Lines
openFile.write('GRIDPIPEFILE\n')
openFile.write('PIPECELLS %s\n' % self.pipeCells)
for cell in self.gridPipeCells:
openFile.write('CELLIJ ... |
Create GSSHAPY GridPipeCell and GridPipeNode Objects Method | def _createGsshaPyObjects(self, cell):
"""
Create GSSHAPY GridPipeCell and GridPipeNode Objects Method
"""
# Initialize GSSHAPY GridPipeCell object
gridCell = GridPipeCell(cellI=cell['i'],
cellJ=cell['j'],
numPipes=c... |
Parse CELLIJ Chunk Method | def _cellChunk(self, lines):
"""
Parse CELLIJ Chunk Method
"""
KEYWORDS = ('CELLIJ',
'NUMPIPES',
'SPIPE')
result = {'i': None,
'j': None,
'numPipes': None,
'spipes': []}
chunks... |
Section 4.1.2 defines SPARQL shortened forms
https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynLiterals
Examples of literal syntax in SPARQL include:
"chat"
'chat'@fr with language tag "fr"
"xyz"^^<http://example.org/ns/userDatatype>
"abc"^^appNS:appDataType
'... | def escape_any(value):
"""
Section 4.1.2 defines SPARQL shortened forms
https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#QSynLiterals
Examples of literal syntax in SPARQL include:
"chat"
'chat'@fr with language tag "fr"
"xyz"^^<http://example.org/ns/userDatatype>
... |
Replace Param File Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Replace Param File Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Open file and parse into a data structure
... |
Replace Param File Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Replace Param File Write to File Method
"""
# Retrieve TargetParameter objects
targets = self.targetParameters
# Write lines
openFile.write('%s\n' % self.numParameters)
for target in targets:
... |
Replace Val File Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Replace Val File Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Open file and parse into a data structure
... |
Replace Val File Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Replace Val File Write to File Method
"""
# Write lines
for line in self.lines:
openFile.write(line.contents) |
Use this function in emit data into the store.
:param data_frame: DataFrame to be recorded. | def emit(self, data_frame):
"""Use this function in emit data into the store.
:param data_frame: DataFrame to be recorded.
"""
if self.result is not None:
raise MultipleEmitsError()
data_frame.columns = [self.prefix + '__' + c
for c in d... |
Returns a list with each script that is triggered. | def trigger_hats(self, command, arg=None, callback=None):
"""Returns a list with each script that is triggered."""
threads = []
for scriptable in [self.project.stage] + self.project.sprites:
threads += self.trigger_scriptable_hats(scriptable, command, arg,
... |
Run the script and add it to the list of threads. | def push_script(self, scriptable, script, callback=None):
"""Run the script and add it to the list of threads."""
if script in self.threads:
self.threads[script].finish()
thread = Thread(self.run_script(scriptable, script),
scriptable, callback)
... |
Execute one frame of the interpreter.
Don't call more than 40 times per second. | def tick(self, events):
"""Execute one frame of the interpreter.
Don't call more than 40 times per second.
"""
self.add_new_threads()
if self.drag_sprite:
(mx, my) = self.screen.get_mouse_pos()
(ox, oy) = self.drag_offset
new_position = (mx ... |
Stop running threads. | def stop(self):
"""Stop running threads."""
self.threads = {}
self.new_threads = {}
self.answer = ""
self.ask_lock = False |
Expression evaluator.
* For expressions, returns the value of the expression.
* For Blocks, returns a generator (or the empty list []). | def evaluate(self, s, value, insert=None):
"""Expression evaluator.
* For expressions, returns the value of the expression.
* For Blocks, returns a generator (or the empty list []).
"""
assert not isinstance(value, kurt.Script)
if insert and insert.unevaluated:
... |
Name identifying this RabbitMQ cluster. | def get_cluster_name(self):
"""
Name identifying this RabbitMQ cluster.
"""
return self._get(
url=self.url + '/api/cluster-name',
headers=self.headers,
auth=self.auth
) |
An individual node in the RabbitMQ cluster. Set "memory=true" to get
memory statistics, and "binary=true" to get a breakdown of binary
memory use (may be expensive if there are many small binaries in the
system). | def get_node(self, name, memory=False, binary=False):
"""
An individual node in the RabbitMQ cluster. Set "memory=true" to get
memory statistics, and "binary=true" to get a breakdown of binary
memory use (may be expensive if there are many small binaries in the
system).
"... |
An individual connection.
:param name: The connection name
:type name: str | def get_connection(self, name):
"""
An individual connection.
:param name: The connection name
:type name: str
"""
return self._api_get('/api/connections/{0}'.format(
urllib.parse.quote_plus(name)
)) |
Closes an individual connection. Give an optional reason
:param name: The connection name
:type name: str
:param reason: An option reason why the connection was deleted
:type reason: str | def delete_connection(self, name, reason=None):
"""
Closes an individual connection. Give an optional reason
:param name: The connection name
:type name: str
:param reason: An option reason why the connection was deleted
:type reason: str
"""
headers = {... |
List of all channels for a given connection.
:param name: The connection name
:type name: str | def list_connection_channels(self, name):
"""
List of all channels for a given connection.
:param name: The connection name
:type name: str
"""
return self._api_get('/api/connections/{0}/channels'.format(
urllib.parse.quote_plus(name)
)) |
Details about an individual channel.
:param name: The channel name
:type name: str | def get_channel(self, name):
"""
Details about an individual channel.
:param name: The channel name
:type name: str
"""
return self._api_get('/api/channels/{0}'.format(
urllib.parse.quote_plus(name)
)) |
A list of all consumers in a given virtual host.
:param vhost: The vhost name
:type vhost: str | def list_consumers_for_vhost(self, vhost):
"""
A list of all consumers in a given virtual host.
:param vhost: The vhost name
:type vhost: str
"""
return self._api_get('/api/consumers/{0}'.format(
urllib.parse.quote_plus(vhost)
)) |
A list of all exchanges in a given virtual host.
:param vhost: The vhost name
:type vhost: str | def list_exchanges_for_vhost(self, vhost):
"""
A list of all exchanges in a given virtual host.
:param vhost: The vhost name
:type vhost: str
"""
return self._api_get('/api/exchanges/{0}'.format(
urllib.parse.quote_plus(vhost)
)) |
An individual exchange
:param exchange: The exchange name
:type exchange: str
:param vhost: The vhost name
:type vhost: str | def get_exchange_for_vhost(self, exchange, vhost):
"""
An individual exchange
:param exchange: The exchange name
:type exchange: str
:param vhost: The vhost name
:type vhost: str
"""
return self._api_get('/api/exchanges/{0}/{1}'.format(
urlli... |
Create an individual exchange.
The body should look like:
::
{
"type": "direct",
"auto_delete": false,
"durable": true,
"internal": false,
"arguments": {}
}
The type key is mandatory; other ... | def create_exchange_for_vhost(self, exchange, vhost, body):
"""
Create an individual exchange.
The body should look like:
::
{
"type": "direct",
"auto_delete": false,
"durable": true,
"internal": false,
... |
Delete an individual exchange. You can add the parameter
``if_unused=True``. This prevents the delete from succeeding if the
exchange is bound to a queue or as a source to another exchange.
:param exchange: The exchange name
:type exchange: str
:param vhost: The vhost name
... | def delete_exchange_for_vhost(self, exchange, vhost, if_unused=False):
"""
Delete an individual exchange. You can add the parameter
``if_unused=True``. This prevents the delete from succeeding if the
exchange is bound to a queue or as a source to another exchange.
:param exchang... |
A list of all bindings in a given virtual host.
:param vhost: The vhost name
:type vhost: str | def list_bindings_for_vhost(self, vhost):
"""
A list of all bindings in a given virtual host.
:param vhost: The vhost name
:type vhost: str
"""
return self._api_get('/api/bindings/{}'.format(
urllib.parse.quote_plus(vhost)
)) |
Details about an individual vhost.
:param name: The vhost name
:type name: str | def get_vhost(self, name):
"""
Details about an individual vhost.
:param name: The vhost name
:type name: str
"""
return self._api_get('/api/vhosts/{0}'.format(
urllib.parse.quote_plus(name)
)) |
Delete a vhost.
:param name: The vhost name
:type name: str | def delete_vhost(self, name):
"""
Delete a vhost.
:param name: The vhost name
:type name: str
"""
self._api_delete('/api/vhosts/{0}'.format(
urllib.parse.quote_plus(name)
)) |
Create an individual vhost.
:param name: The vhost name
:type name: str
:param tracing: Set to ``True`` to enable tracing
:type tracing: bool | def create_vhost(self, name, tracing=False):
"""
Create an individual vhost.
:param name: The vhost name
:type name: str
:param tracing: Set to ``True`` to enable tracing
:type tracing: bool
"""
data = {'tracing': True} if tracing else {}
self._a... |
Details about an individual user.
:param name: The user's name
:type name: str | def get_user(self, name):
"""
Details about an individual user.
:param name: The user's name
:type name: str
"""
return self._api_get('/api/users/{0}'.format(
urllib.parse.quote_plus(name)
)) |
Delete a user.
:param name: The user's name
:type name: str | def delete_user(self, name):
"""
Delete a user.
:param name: The user's name
:type name: str
"""
self._api_delete('/api/users/{0}'.format(
urllib.parse.quote_plus(name)
)) |
Create a user
:param name: The user's name
:type name: str
:param password: The user's password. Set to "" if no password is
desired. Takes precedence if ``password_hash`` is also set.
:type password: str
:param password_hash: An optional password hash for the user.
... | def create_user(self, name, password, password_hash=None, tags=None):
"""
Create a user
:param name: The user's name
:type name: str
:param password: The user's password. Set to "" if no password is
desired. Takes precedence if ``password_hash`` is also set.
... |
A list of all permissions for a given user.
:param name: The user's name
:type name: str | def list_user_permissions(self, name):
"""
A list of all permissions for a given user.
:param name: The user's name
:type name: str
"""
return self._api_get('/api/users/{0}/permissions'.format(
urllib.parse.quote_plus(name)
)) |
Create a user permission
:param name: The user's name
:type name: str
:param vhost: The vhost to assign the permission to
:type vhost: str
:param configure: A regex for the user permission. Default is ``.*``
:type configure: str
:param write: A regex for the user... | def create_user_permission(self,
name,
vhost,
configure=None,
write=None,
read=None):
"""
Create a user permission
:param name: The user's na... |
A list of all policies for a vhost. | def list_policies_for_vhost(self, vhost):
"""
A list of all policies for a vhost.
"""
return self._api_get('/api/policies/{0}'.format(
urllib.parse.quote_plus(vhost)
)) |
Get a specific policy for a vhost.
:param vhost: The virtual host the policy is for
:type vhost: str
:param name: The name of the policy
:type name: str | def get_policy_for_vhost(self, vhost, name):
"""
Get a specific policy for a vhost.
:param vhost: The virtual host the policy is for
:type vhost: str
:param name: The name of the policy
:type name: str
"""
return self._api_get('/api/policies/{0}/{1}'.form... |
Create a policy for a vhost.
:param vhost: The virtual host the policy is for
:type vhost: str
:param name: The name of the policy
:type name: str
:param definition: The definition of the policy. Required
:type definition: dict
:param priority: The priority of t... | def create_policy_for_vhost(
self, vhost, name,
definition,
pattern=None,
priority=0,
apply_to='all'):
"""
Create a policy for a vhost.
:param vhost: The virtual host the policy is for
:type vhost: str
:param name: The ... |
Delete a specific policy for a vhost.
:param vhost: The virtual host of the policy
:type vhost: str
:param name: The name of the policy
:type name: str | def delete_policy_for_vhost(self, vhost, name):
"""
Delete a specific policy for a vhost.
:param vhost: The virtual host of the policy
:type vhost: str
:param name: The name of the policy
:type name: str
"""
self._api_delete('/api/policies/{0}/{1}/'.forma... |
Declares a test queue, then publishes and consumes a message.
Intended for use by monitoring tools.
:param vhost: The vhost name to check
:type vhost: str | def is_vhost_alive(self, vhost):
"""
Declares a test queue, then publishes and consumes a message.
Intended for use by monitoring tools.
:param vhost: The vhost name to check
:type vhost: str
"""
return self._api_get('/api/aliveness-test/{0}'.format(
... |
Write from database to file.
*session* = SQLAlchemy session object\n
*directory* = to which directory will the files be written (e.g.: '/example/path')\n
*name* = name of file that will be written (e.g.: 'my_project.ext')\n | def write(self, session, directory, name, maskMap):
"""
Write from database to file.
*session* = SQLAlchemy session object\n
*directory* = to which directory will the files be written (e.g.: '/example/path')\n
*name* = name of file that will be written (e.g.: 'my_project.ext')\n... |
Retrieve the WMS dataset as a gridded time stamped KML string.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database.
projectFile(:class:`gsshapy.orm.ProjectFile`): Project file object for the GSSHA project to which the WMS da... | def getAsKmlGridAnimation(self, session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0, noDataValue=0.0):
"""
Retrieve the WMS dataset as a gridded time stamped KML string.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object b... |
Retrieve the WMS dataset as a PNG time stamped KMZ
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database.
projectFile(:class:`gsshapy.orm.ProjectFile`): Project file object for the GSSHA project to which the WMS dataset belong... | def getAsKmlPngAnimation(self, session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0,
noDataValue=0, drawOrder=0, cellSize=None, resampleMethod='NearestNeighbour'):
"""
Retrieve the WMS dataset as a PNG time stamped KMZ
Args:
... |
WMS Dataset File Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, maskMap):
"""
WMS Dataset File Read from File Method
"""
# Assign file extension attribute to file object
self.fileExtension = extension
if isinstance(maskMap, RasterMapFile... |
WMS Dataset File Write to File Method | def _write(self, session, openFile, maskMap):
"""
WMS Dataset File Write to File Method
"""
# Magic numbers
FIRST_VALUE_INDEX = 12
# Write the header
openFile.write('DATASET\r\n')
if self.type == self.SCALAR_TYPE:
openFile.write('OBJTYPE {0}\... |
Retrieve the WMS Raster as a string in the WMS Dataset format | def getAsWmsDatasetString(self, session):
"""
Retrieve the WMS Raster as a string in the WMS Dataset format
"""
# Magic numbers
FIRST_VALUE_INDEX = 12
# Write value raster
if type(self.raster) != type(None):
# Convert to GRASS ASCII Raster
... |
Make sure that there are no random artifacts in the file. | def check_watershed_boundary_geometry(shapefile_path):
"""Make sure that there are no random artifacts in the file."""
wfg = gpd.read_file(shapefile_path)
first_shape = wfg.iloc[0].geometry
if hasattr(first_shape, 'geoms'):
raise ValueError(
"Invalid watershed boundary geometry. "
... |
Get a batch of inputs and outputs from given sentences.
:param sentences: A list of list of tokens.
:param token_dict: The dict that maps a token to an integer. `<UNK>` and `<EOS>` should be preserved.
:param ignore_case: Whether ignoring the case of the token.
:param unk_index: The ind... | def get_batch(sentences,
token_dict,
ignore_case=False,
unk_index=1,
eos_index=2):
"""Get a batch of inputs and outputs from given sentences.
:param sentences: A list of list of tokens.
:param token_dict: The dict that maps... |
Simple wrapper of model.fit.
:param inputs: Inputs.
:param outputs: List of forward and backward outputs.
:param epochs: Number of epoch.
:return: None | def fit(self, inputs, outputs, epochs=1):
"""Simple wrapper of model.fit.
:param inputs: Inputs.
:param outputs: List of forward and backward outputs.
:param epochs: Number of epoch.
:return: None
"""
self.model.fit(inputs, outputs, epochs=epochs) |
Get layers that output the Bi-LM feature.
:param input_layer: Use existing input layer.
:param trainable: Whether the layers are still trainable.
:param use_weighted_sum: Whether to use weighted sum of RNN layers.
:return [input_layer,] output_layer: Input and output layer. | def get_feature_layers(self, input_layer=None, trainable=False, use_weighted_sum=False):
"""Get layers that output the Bi-LM feature.
:param input_layer: Use existing input layer.
:param trainable: Whether the layers are still trainable.
:param use_weighted_sum: Whether to use weighted ... |
if join returns false, the node did not entry the ring. Retry it | def join(self, n1):
"""if join returns false, the node did not entry the ring. Retry it"""
if self.id == n1.get_id():
for i in range(k):
self.finger[i] = self.proxy
self.predecessor = self.proxy
self.run = True
return True
else:
... |
NWSRFS Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
NWSRFS Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Open file and parse
with open(path, 'r') as nw... |
NWSRFS Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
NWSRFS Write to File Method
"""
# Write lines
openFile.write('Number_Bands: %s\n' % self.numBands)
openFile.write('Lower_Elevation Upper_Elevation MF_Min MF_Max SCF FR_USE TIPM NMF FUA PCWHC\n')
... |
Orographic Gage File Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Orographic Gage File Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Open file and parse into HmetRecords
... |
Orographic Gage File Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Orographic Gage File Write to File Method
"""
# Write lines
openFile.write('Num_Sites: %s\n' % self.numSites)
openFile.write('Elev_Base %s\n' % self.elevBase)
openFile.write('Elev_2 %s\n' % s... |
Retrieve only the links that represent fluvial portions of the stream. Returns a list of StreamLink instances.
Returns:
list: A list of fluvial :class:`.StreamLink` objects. | def getFluvialLinks(self):
"""
Retrieve only the links that represent fluvial portions of the stream. Returns a list of StreamLink instances.
Returns:
list: A list of fluvial :class:`.StreamLink` objects.
"""
# Define fluvial types
fluvialTypeKeywords = ('TRA... |
Retrieve the links in the order of the link number.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database.
Returns:
list: A list of :class:`.StreamLink` objects. | def getOrderedLinks(self, session):
"""
Retrieve the links in the order of the link number.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database.
Returns:
list: A list of :class:`.StreamLink` objects.... |
Retrieve the stream network visualization in KML format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database
path (str, optional): Path to file where KML will be written. Defaults to None.
documentName (str, opti... | def getStreamNetworkAsKml(self, session, path=None, documentName='Stream Network', withNodes=False, styles={}):
"""
Retrieve the stream network visualization in KML format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled data... |
Retrieve the stream network geometry in Well Known Text format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database
withNodes (bool, optional): Include nodes. Defaults to False.
Returns:
str: Well Known ... | def getStreamNetworkAsWkt(self, session, withNodes=True):
"""
Retrieve the stream network geometry in Well Known Text format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database
withNodes (bool, optional): In... |
Retrieve the stream network geometry in GeoJSON format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database
withNodes (bool, optional): Include nodes. Defaults to False.
Returns:
str: GeoJSON string. | def getStreamNetworkAsGeoJson(self, session, withNodes=True):
"""
Retrieve the stream network geometry in GeoJSON format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database
withNodes (bool, optional): Includ... |
Channel Input File Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Channel Input File Read from File Method
"""
# Set file extension property
self.fileExtension = extension
# Dictionary of keywords/cards and parse fun... |
Channel Input File Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Channel Input File Write to File Method
"""
# Write lines
openFile.write('GSSHA_CHAN\n')
alpha = vwp(self.alpha, replaceParamFile)
try:
openFile.write('ALPHA%s%.6f\n' % (' ' * 7, alpha))
... |
Create GSSHAPY Link Object Method | def _createLink(self, linkResult, replaceParamFile):
"""
Create GSSHAPY Link Object Method
"""
link = None
# Cases
if linkResult['type'] == 'XSEC':
# Cross section link handler
link = self._createCrossSection(linkResult, replaceParamFile)
... |
Create GSSHAPY Connect Object Method | def _createConnectivity(self, linkList, connectList):
"""
Create GSSHAPY Connect Object Method
"""
# Create StreamLink-Connectivity Pairs
for idx, link in enumerate(linkList):
connectivity = connectList[idx]
# Initialize GSSHAPY UpstreamLink objects
... |
Create GSSHAPY Cross Section Objects Method | def _createCrossSection(self, linkResult, replaceParamFile):
"""
Create GSSHAPY Cross Section Objects Method
"""
# Extract header variables from link result object
header = linkResult['header']
# Initialize GSSHAPY StreamLink object
link = StreamLink(linkNumber=i... |
Create GSSHAPY Structure Objects Method | def _createStructure(self, linkResult, replaceParamFile):
"""
Create GSSHAPY Structure Objects Method
"""
# Constants
WEIRS = ('WEIR', 'SAG_WEIR')
CULVERTS = ('ROUND_CULVERT', 'RECT_CULVERT')
CURVES = ('RATING_CURVE', 'SCHEDULED_RELEASE', 'RULE_CURVE')
... |
Create GSSHAPY Reservoir Objects Method | def _createReservoir(self, linkResult, replaceParamFile):
"""
Create GSSHAPY Reservoir Objects Method
"""
# Extract header variables from link result object
header = linkResult['header']
# Cases
if linkResult['type'] == 'LAKE':
# Lake handler
... |
Create PostGIS geometric objects | def _createGeometry(self, session, spatialReferenceID):
"""
Create PostGIS geometric objects
"""
# Flush the current session
session.flush()
# Create geometry for each fluvial link
for link in self.getFluvialLinks():
# Retrieve the nodes for each lin... |
Write Connectivity Lines to File Method | def _writeConnectivity(self, links, fileObject):
"""
Write Connectivity Lines to File Method
"""
for link in links:
linkNum = link.linkNumber
downLink = link.downstreamLinkID
numUpLinks = link.numUpstreamLinks
upLinks = ''
for u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.