re_fun.py #1

  • //
  • guest/
  • perforce_software/
  • cbd/
  • main/
  • scraps/
  • re_fun.py
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/p4/common/python/bin/python3

import re

pathArgList = ['...', '//foo/...@300', 'bogus', '/my/home/...#none', 'homedir', '...@3L', 'good/...', 'bad/..', '#have']

print ("\nS1: ...@")
for pathArg in pathArgList:
   if (re.search ('\.\.\.@', pathArg)):
      print ("MATCH   : %s" % pathArg)
   else:
      print ("NO MATCH: %s" % pathArg)

print ("\nS2: ...#")
for pathArg in pathArgList:
   if (re.search('\.\.\.#', pathArg)):
      print ("MATCH   : %s" % pathArg)
   else:
      print ("NO MATCH: %s" % pathArg)

print ("\nS3: ...$")
for pathArg in pathArgList:
   if (re.search('\.\.\.$', pathArg)):
      print ("MATCH   : %s" % pathArg)
   else:
      print ("NO MATCH: %s" % pathArg)

print ("\nS4: Combined Search ...@|# or ...")
for pathArg in pathArgList:
   if (re.search ('\.\.\.(@|#)', pathArg) or re.search('\.\.\.$', pathArg)):
      print ("MATCH   : %s" % pathArg)
   else:
      print ("NO MATCH: %s" % pathArg)

print ("\nS5: Finding revSpecPart")
for anArg in pathArgList:
   revSpecPart = ''
   if r'@' in anArg:
      revSpecPart = re.sub ('^.*@', '@', anArg)

   if r'#' in anArg:
      revSpecPart = re.sub ('^.*#', '#', anArg)

   print ("Rev Spec Part of [%s] is [%s]." % (anArg, revSpecPart))
# Change User Description Committed
#1 22191 C. Thomas Tyler Copy Up using 'p4 copy -r -b perforce_software-cbd-dev'.
//guest/perforce_software/cbd/dev/scraps/re_fun.py
#1 21806 C. Thomas Tyler Moved non-essential R&D and sample scripts to a
scraps directory to keep them separate from components of
the real system.
//guest/perforce_software/cbd/dev/scripts/re_fun.py
#2 19253 C. Thomas Tyler Routine merge-down from main to dev.
#1 15277 C. Thomas Tyler Reg R&D script.