def get_cache_dir(versioned=True, name=None): """Get the cache dir as a string, and make the directory if it does not already exist. :param Boolean versioned: Whether to return the versioned path in the cache. Escher maps for the latest version of Escher are found in the versioned directory (versioned = True), but maps for previous versions of Escher can be found by visiting the parent directory (versioned = False). :param string name: An optional subdirectory within the cache. If versioned is False, then name is ignored. """ cache_dir = user_cache_dir('escher', appauthor='Zachary King') # add version if versioned: cache_dir = join(cache_dir, __schema_version__, __map_model_version__) # add subdirectory if name is not None: cache_dir = join(cache_dir, name) try: os.makedirs(cache_dir) except OSError: pass return cache_dir
def get_cache_dir(name=None): """ Get the cache dir as a string. :param string name: An optional subdirectory within the cache """ cache_dir = join(user_cache_dir('escher', appauthor='Zachary King')) if name is not None: cache_dir = join(cache_dir, name) try: os.makedirs(cache_dir) except OSError: pass return cache_dir