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._convert_to_keys(output_type)[source]

Convert the CacheData type to string keys required for output

nautical.cache.file.copy_current_cache(extra_name_data)[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()[source]

Apply timestamp to the name of the nautical cache

nautical.cache.file.dumps(data, filename='/home/bbarbach/.cache/nautical/nautical_cache.json')[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.file.load(filename='/home/bbarbach/.cache/nautical/nautical_cache.json', cached_output=CacheData.ALL)[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.setup()[source]

Create the cache directory if it does not exist/

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

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
nautical.cache.copy_current_cache(extra_name_data)[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()[source]

Apply timestamp to the name of the nautical cache

nautical.cache.dumps(data, filename='/home/bbarbach/.cache/nautical/nautical_cache.json')[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.load(filename='/home/bbarbach/.cache/nautical/nautical_cache.json', cached_output=CacheData.ALL)[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.setup()[source]

Create the cache directory if it does not exist/

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