Mercurial > vim-crosoft
comparison scripts/dump_sln_cache.py @ 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 | |
children |
comparison
equal
deleted
inserted
replaced
13:dce01b0e9982 | 14:0aa61944e518 |
---|---|
1 import os.path | |
2 import pickle | |
3 import pprint | |
4 import logging | |
5 import argparse | |
6 from vsutil import SolutionCache | |
7 | |
8 | |
9 def main(): | |
10 parser = argparse.ArgumentParser() | |
11 parser.add_argument('cache', | |
12 help="The path to the cache file") | |
13 parser.add_argument('-v', '--verbose', | |
14 action='store_true') | |
15 args = parser.parse_args() | |
16 | |
17 loglevel = logging.INFO | |
18 if args.verbose: | |
19 loglevel = logging.DEBUG | |
20 logging.basicConfig(level=loglevel) | |
21 logger = logging.getLogger() | |
22 | |
23 cachepath = args.cache | |
24 try: | |
25 with open(cachepath, 'rb') as fp: | |
26 cache = pickle.load(fp) | |
27 except Exception as ex: | |
28 logger.error("Error loading solution cache: %s" % ex) | |
29 return 1 | |
30 | |
31 loaded_ver = getattr(cache, '_saved_version', 0) | |
32 if loaded_ver != SolutionCache.VERSION: | |
33 logger.warn(f"Cache was saved with older format: {cachepath} " | |
34 f"(got {loaded_ver}, expected {SolutionCache.VERSION})") | |
35 else: | |
36 logger.info(f"Cache has correct version: {loaded_ver}") | |
37 | |
38 logger.info(f"VSSolution: {cache.slnobj.path}") | |
39 logger.info(f"Projects: {len(cache.slnobj.projects)}") | |
40 for proj in cache.slnobj.projects: | |
41 logger.info(f" {proj.name}: {proj.path}") | |
42 logger.info(f"Sections: {len(cache.slnobj.sections)}") | |
43 for section in cache.slnobj.sections: | |
44 logger.info(f" {section.name} ({len(section.entries)} entries)") | |
45 | |
46 if __name__ == '__main__': | |
47 main() |