import marshal,os, pprint,sys from readp4marshal import runp4cmd # Task: output list of 'opened' files, using local pathnames. # # status: tested on Win/NT using python 2.0 # num of calls to 'p4': 2 # room for optimization/improvement: add getopts call # Copyright 2004 Perforce Corporation, Inc. All rights reserved. #----------------------------------------------------------- # first call to P4: 'p4 client -o' # Note that it's easier to get the client root dir from # the 'client spec', hence the "FetchClient" call. #----------------------------------------------------------- [cl_spec] = runp4cmd("p4 -G client -o") cl_root = cl_spec['Root'] cl_name = cl_spec['Client'] #----------------------------------------------------------- # second call to P4: 'p4 opened' #----------------------------------------------------------- oldtag = "//%s" % cl_name ret = runp4cmd('p4 -G opened') #----------------------------------------------------------- # Now, loop through the output of 'p4 opened'. The tagged # output gives us a client-syntax version of the name # in the form "//clientName/rest-of-local-path", # so we substitute the client root dir before printing. #----------------------------------------------------------- for o in ret: clientName = o['client'] localName = o['clientFile'] print localName.replace(oldtag, cl_root)