From 58a1de86b4e5a2dfa30a951e28f9c1dc5ff1be41 Mon Sep 17 00:00:00 2001 From: snakez Date: Sat, 6 Jun 2015 18:45:56 -0400 Subject: [PATCH] Added support for indexes from multiple installs --- parse_index.py | 6 +++++- rescache.py | 33 ++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/parse_index.py b/parse_index.py index 04bb006..b4a2cfe 100644 --- a/parse_index.py +++ b/parse_index.py @@ -28,4 +28,8 @@ def __init__(self): self.cached_name = "" self.md5_checksum = "" self.size_in_bytes = 0 - self.compressed_size = 0 \ No newline at end of file + self.compressed_size = 0 + def __hash__(self): + return hash(self.cached_name) + def __eq__(self, other): + return self.cached_name == other.cached_name \ No newline at end of file diff --git a/rescache.py b/rescache.py index 1e0d49e..725dc15 100644 --- a/rescache.py +++ b/rescache.py @@ -24,13 +24,27 @@ DEFAULT_INDEX_FILENAME = "resfileindex.txt" -def _get_index(filename): +def _get_index(filename, dirs = None): + index = [] try: index_path = get_index_path(filename) with open(index_path) as f: - index = parse_index(f) + index += parse_index(f) except IOError: - print "Couldn't open index file: %s" % index_path + if not dirs: + print "Couldn't open index file: %s" % index_path + + if dirs: + for dir in dirs: + try: + index_path = get_index_path(os.path.join(dir, filename)) + with open(index_path) as f: + index += parse_index(f) + except IOError: + print "Couldn't open index file: %s" % index_path + index = list(set(index)) + + if len(index) == 0: sys.exit(1) return index @@ -43,19 +57,19 @@ def _get_res_folder(args): def verify_command(args): - verify_cache(_get_index(args.index), _get_res_folder(args)) + verify_cache(_get_index(args.index, args.dir), _get_res_folder(args)) def diff_command(args): - diff_cache(_get_index(args.index), _get_res_folder(args)) + diff_cache(_get_index(args.index, args.dir), _get_res_folder(args)) def purge_command(args): - purge_cache(_get_index(args.index), _get_res_folder(args)) + purge_cache(_get_index(args.index, args.dir), _get_res_folder(args)) def download_command(args): - download_cache(_get_index(args.index), _get_res_folder(args)) + download_cache(_get_index(args.index, args.dir), _get_res_folder(args)) def move_command(args): @@ -108,6 +122,11 @@ def main(): default=get_shared_cache_folder(), help="The location of the shared cache to use - defaults to what the EVE client uses" ) + parser.add_argument( + "-d", "--dir", + action='append', + help="Additional directories (EVE installs) to read indexes from" + ) subparsers = parser.add_subparsers() parser_verify = subparsers.add_parser("verify")