def persist_package_cache() -> None: """Write the contents of the package cache for this GOROOT into the disk """ cachefile = os.path.join(cache_directory, project_name(), 'packages.cache') if not os.path.exists(os.path.dirname(cachefile)): os.makedirs(os.path.dirname(cachefile)) with open(cachefile, 'w') as fd: json.dump(PACKAGES_CACHE[go.GOROOT], fd)
def load_package_cache() -> typing.List: """Load a previously stores package cache file """ global PACKAGES_CACHE cachefile = os.path.join(cache_directory, project_name(), 'packages.cache') try: with open(cachefile, 'r') as fd: PACKAGES_CACHE[go.GOROOT] = json.load(fd) except FileNotFoundError: pass
def _project_name(self) -> str: """Return the current project name """ return project_name()