Package horizons :: Package util :: Module yamlcache :: Class YamlCache
[hide private]
[frames] | no frames]

Class YamlCache

source code

Loads and caches YAML files in a persistent cache. Threadsafe.

Use get_file for files to cache (default case) or load_yaml_data for special use cases (behaves like yaml.load).

Class Methods [hide private]
load_yaml_data(cls, string_or_stream)
Use this instead of yaml.load everywhere in uh in case get_file isn't useable
source code
get_file(cls, filename, game_data=False)
Get contents of a yaml file
source code
_open_cache(cls) source code
Only write to disc once in a while, it's too slow when done every time
source code
Class Variables [hide private]
  cache = None
  cache_filename = os.path.join(PATHS.USER_DIR, 'yamldata.cache')
  sync_scheduled = False
  lock = threading.Lock()
  log = logging.getLogger("yamlcache")
Method Details [hide private]

get_file(cls, filename, game_data=False)
Class Method

source code 

Get contents of a yaml file

  • filename - path to the file
  • game_data - Whether this file contains data like BUILDINGS.LUMBERJACK to resolve