safe.common.minimum_needs module

This module contains the abstract class of the MinimumNeeds. The storage logic is omitted here.

class safe.common.minimum_needs.MinimumNeeds[source]

Bases: object

A abstract class for handling the minimum needs.

The persistence logic is excluded from this class.

New in version 2.2..

get_full_needs()[source]

The full list of minimum needs with all fields.

Returns:minimum needs
Return type:dict
get_minimum_needs()[source]

Get the minimum needed information about the minimum needs.

That is the resource and the amount.

Returns:minimum needs
Return type:OrderedDict
get_need(resource)[source]

Get a resource from the minimum_needs.

Parameters:resource (basestring) – The resource name
Returns:resource needed.
Return type:dict, None
read_from_file(filename)[source]

Read from an existing json file.

Parameters:filename (basestring, str) – The file to be written to.
Returns:Success status. -1 for unsuccessful 0 for success
Return type:int
static remove_file(filename)[source]

Remove a minimum needs file.

Parameters:filename (basestring, str) – The file to be removed.
set_need(resource, amount, units, frequency='weekly')[source]

Append a single new minimum need entry to the list.

Parameters:
  • resource (basestring) – Minimum need resource name.
  • amount (int, float) – Amount per person per time interval
  • units – The unit that the resource is measured in.
  • frequency – How regularly the unit needs to be dispatched
Type:

basestring

Type:

basestring # maybe at some point fix this to a selection.

update_minimum_needs(minimum_needs)[source]

Overwrite the internal minimum needs with new needs.

Validate the new minimum needs. If ok, set these as the internal minimum needs.
Parameters:minimum_needs (dict) – The new minimum
Returns:Returns success code, -1 for failure, 0 for success.
Return type:int
write_to_file(filename)[source]

Write minimum needs as json to a file.

Parameters:filename (basestring, str) – The file to be written to.