Expand single command line argument
(pArg, pFilePath, pDefaultPath, pLeft='{', pSep=';', pQuote='"',
pPref='{<-}', pJoin='\\')
| 59 | return lPath |
| 60 | |
| 61 | def ExpandArg(pArg, pFilePath, pDefaultPath, pLeft='{', pSep=';', pQuote='"', |
| 62 | pPref='{<-}', pJoin='\\'): |
| 63 | ''' |
| 64 | Expand single command line argument |
| 65 | ''' |
| 66 | # Expand argument |
| 67 | if pArg.find(pLeft) >= 0: |
| 68 | lArg = Do.Expand(pArg, pFilePath) |
| 69 | else: |
| 70 | lArg = pArg |
| 71 | |
| 72 | # If starts with {<-} and single path scan parent folders for |
| 73 | # first matching file. Each folder above specified path will |
| 74 | # be checked until file is found. |
| 75 | if lArg.startswith(pPref) and lArg.find(pSep) < 0: |
| 76 | lArg = os.path.abspath(lArg[2:]) |
| 77 | print 'Parent Search 1' |
| 78 | lArg = ParentSearch(lArg, pDefaultPath, pJoin=pJoin) |
| 79 | |
| 80 | # If multiple paths separated by pSep(';') select first valid path |
| 81 | lFound = '' |
| 82 | if lArg.find(pSep) >= 0: |
| 83 | lPaths = lArg.split(pSep) |
| 84 | for lPath in lPaths: |
| 85 | if lPath.startswith(pPref): |
| 86 | lPath = os.path.abspath(lPath[4:]) |
| 87 | lPath = ParentSearch(lPath, pDefaultPath, pJoin=pJoin) # 01/19/11 |
| 88 | if lPath == '': # |
| 89 | continue # |
| 90 | lPath = os.path.abspath(lPath) |
| 91 | if os.path.exists(lPath): |
| 92 | lFound = lPath |
| 93 | break |
| 94 | else: |
| 95 | lFound = os.path.abspath(pDefaultPath) |
| 96 | else: |
| 97 | lFound = lArg |
| 98 | |
| 99 | # If argument contains space enclose it within quotes |
| 100 | lFound = lFound.strip() |
| 101 | if lFound.find(' ') > 0 and lFound[0] != pQuote: |
| 102 | lFound = pQuote + lFound + pQuote |
| 103 | return lFound |
| 104 | |
| 105 | def submitnow(pCommand): |
| 106 | ''' |
no test coverage detected