map_fun.py #1

  • //
  • cbd/
  • main/
  • scripts/
  • map_fun.py
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/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))
# Change User Description Committed
#1 21633 C. Thomas Tyler Populate -o //guest/perforce_software/cbd/main/...
//cbd/main/....
//guest/perforce_software/cbd/main/scripts/map_fun.py
#3 16705 C. Thomas Tyler Set to use SDP standard Python/P4Python.
#2 16702 C. Thomas Tyler Configured to ensure python3 is used.
#1 15276 C. Thomas Tyler Copy Up using 'p4 copy -r -b perforce_software-cbd-dev'.
//guest/perforce_software/cbd/dev/scripts/map_fun.py
#1 15275 C. Thomas Tyler Added R&D script for playing with P4.Map().