#!/p4/common/python/bin/python3 import sys import re from P4 import P4, P4Exception p4 = P4() p4.user='bruno' p4.port='8223' p4.client='bruno_jam.test_cbd.ugnldptperforce01' p4.connect() import P4 #cspec = p4.fetch_client('bruno_jam.test_cbd.ugnldptperforce01') #cspec = p4.fetch_client('bruno_ws') cspec = p4.fetch_client('earl_jams') for f in cspec['View']: print("View Entry = %s" % f) map = P4.Map() for f in cspec['View']: map.insert(f) print ("Map = %s" % map) rootDir = re.sub (r'\\', r'/', cspec['Root']) root = P4.Map() for f in cspec['View']: tmpMap = P4.Map() tmpMap.insert(f) tmpL = tmpMap.lhs()[0] tmpR = tmpMap.rhs()[0] tmpR2 = re.sub ('//.*?/', rootDir + '/', tmpR) print ("L=[%s]\nR=[%s]\nR2=[%s]\n" % (tmpL, tmpR, tmpR2)) root.insert (tmpR, tmpR2) local_map = P4.Map.join (map, root) depotPath = '//jam/rel2.1/src/command.c' localPath = local_map.translate(depotPath) print ("D = %s\nL = %s\n" % (depotPath, localPath)) localPath = 'c:/p4/CT/pb/somewhere/under/here/command.c' depotPath = local_map.translate(localPath, 0) print ("D = %s\nL = %s\n" % (depotPath, localPath))