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..


The full list of minimum needs with all fields.

Returns:minimum needs
Return type:dict

Get the minimum needed information about the minimum needs.

That is the resource and the amount.

Returns:minimum needs
Return type:OrderedDict

Get a resource from the minimum_needs.

Parameters:resource (basestring) – The resource name
Returns:resource needed.
Return type:dict, None

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.

  • 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



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


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 minimum needs as json to a file.

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