# Copyright 2004 Perforce Corporation, Inc. All rights reserved. import os import marshal def runp4cmd(p4cmd): """ Return the output from the Perforce command, and assume that the user put the '-G' in the options to get us marshall output. We always return an array for the results.""" fd = os.popen(p4cmd, 'rb') results = [] while 1: try: d = marshal.load(fd) results.append(d) except EOFError: break fd.close() return results def SubtractTwoHashes(list1, list2): '''find the things in list1 that aren't in list2, those in list2 (but not list1), and in common. Return those three results as a three-tuple. ''' OnlyList1res = [] OnlyList2res = [] Duplicates = [] for l in list1.keys(): if list2.has_key(l) and list2[l]: Duplicates.append(l) else: OnlyList1res.append(l) for l in list2.keys(): if list1.has_key(l) and list1[l]: pass # no need to duplicate the above entirely else: OnlyList2res.append(l) return [OnlyList1res, OnlyList2res, Duplicates]