nautical.cache package

Submodules

nautical.cache.file module

No matter what system is used, the cache should be save to the correct/known location provided by this module.

class nautical.cache.file.CacheData(value)[source]

Bases: Enum

Describes the type of data that the user wants to retrieve from the CACHE

ALL = 0
BUOYS = 1
SOURCES = 2
TIME = 3
nautical.cache.file.setup() None[source]

Create the cache directory if it does not exist/

nautical.cache.file.copy_current_cache(extra_name_data: str) str | None[source]

Copy the current nautical cache file and append the extra_data.

Returns:

Filename on success, None otherwise

nautical.cache.file.copy_current_cache_with_timestamp() str | None[source]

Apply timestamp to the name of the nautical cache

nautical.cache.file.load(filename: str = '/home/runner/.cache/nautical/nautical_cache.json', cached_output: CacheData = CacheData.ALL) dict[source]

Load the nautical cache if it exists. All nautical data is returned as nautical objects in the dictionary. Time is provided as a string.

Parameters:
  • filename – Name of the file containing cached data.

  • cached_output – CacheData enumeration type. What type of information to retrieve

Returns:

Dictionary containing all cached output

nautical.cache.file.dumps(data: dict, filename: str = '/home/runner/.cache/nautical/nautical_cache.json') None[source]

Overwrite the current value of the NAUTICAL_CACHE_FILE with the current contents of data. The data should be passed in should be provided as nautical objects for buoys and sources.

Parameters:
  • data – Dictionary containing buoys and sources with the keys to match

  • filename – name of the file where the data will be stored

nautical.cache.time module

nautical.cache.time.should_update(date_time_stamp: str, units=TimeUnits.MINUTES, max_diff=30)[source]

Determine if an update _should_ occur based on the time provided. The date_time_stamp should be provided with the format __DT_FORMAT (see ../time/ops.py for more information).

Parameters:
  • data_time_stamp – String format for the string following the format in __DT_FORMAT

  • units – Resulting time units

  • max_diff – if the diff exceeds this value then True is returned

Returns:

True when an update _may_ be desired

Module contents

nautical.cache.setup() None[source]

Create the cache directory if it does not exist/

nautical.cache.copy_current_cache(extra_name_data: str) str | None[source]

Copy the current nautical cache file and append the extra_data.

Returns:

Filename on success, None otherwise

nautical.cache.copy_current_cache_with_timestamp() str | None[source]

Apply timestamp to the name of the nautical cache

nautical.cache.load(filename: str = '/home/runner/.cache/nautical/nautical_cache.json', cached_output: CacheData = CacheData.ALL) dict[source]

Load the nautical cache if it exists. All nautical data is returned as nautical objects in the dictionary. Time is provided as a string.

Parameters:
  • filename – Name of the file containing cached data.

  • cached_output – CacheData enumeration type. What type of information to retrieve

Returns:

Dictionary containing all cached output

nautical.cache.dumps(data: dict, filename: str = '/home/runner/.cache/nautical/nautical_cache.json') None[source]

Overwrite the current value of the NAUTICAL_CACHE_FILE with the current contents of data. The data should be passed in should be provided as nautical objects for buoys and sources.

Parameters:
  • data – Dictionary containing buoys and sources with the keys to match

  • filename – name of the file where the data will be stored

nautical.cache.should_update(date_time_stamp: str, units=TimeUnits.MINUTES, max_diff=30)[source]

Determine if an update _should_ occur based on the time provided. The date_time_stamp should be provided with the format __DT_FORMAT (see ../time/ops.py for more information).

Parameters:
  • data_time_stamp – String format for the string following the format in __DT_FORMAT

  • units – Resulting time units

  • max_diff – if the diff exceeds this value then True is returned

Returns:

True when an update _may_ be desired

class nautical.cache.CacheData(value)[source]

Bases: Enum

Describes the type of data that the user wants to retrieve from the CACHE

ALL = 0
BUOYS = 1
SOURCES = 2
TIME = 3