Mercurial > vim-crosoft
changeset 14:0aa61944e518
Add utility script to print the contents of a solution's cache.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 29 Aug 2023 12:52:12 -0700 |
parents | dce01b0e9982 |
children | cfcac4ed7d21 |
files | scripts/dump_sln_cache.py |
diffstat | 1 files changed, 47 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/dump_sln_cache.py Tue Aug 29 12:52:12 2023 -0700 @@ -0,0 +1,47 @@ +import os.path +import pickle +import pprint +import logging +import argparse +from vsutil import SolutionCache + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('cache', + help="The path to the cache file") + parser.add_argument('-v', '--verbose', + action='store_true') + args = parser.parse_args() + + loglevel = logging.INFO + if args.verbose: + loglevel = logging.DEBUG + logging.basicConfig(level=loglevel) + logger = logging.getLogger() + + cachepath = args.cache + try: + with open(cachepath, 'rb') as fp: + cache = pickle.load(fp) + except Exception as ex: + logger.error("Error loading solution cache: %s" % ex) + return 1 + + loaded_ver = getattr(cache, '_saved_version', 0) + if loaded_ver != SolutionCache.VERSION: + logger.warn(f"Cache was saved with older format: {cachepath} " + f"(got {loaded_ver}, expected {SolutionCache.VERSION})") + else: + logger.info(f"Cache has correct version: {loaded_ver}") + + logger.info(f"VSSolution: {cache.slnobj.path}") + logger.info(f"Projects: {len(cache.slnobj.projects)}") + for proj in cache.slnobj.projects: + logger.info(f" {proj.name}: {proj.path}") + logger.info(f"Sections: {len(cache.slnobj.sections)}") + for section in cache.slnobj.sections: + logger.info(f" {section.name} ({len(section.entries)} entries)") + +if __name__ == '__main__': + main()