MCPcopy Create free account
hub / github.com/ActiveState/code / Expand

Function Expand

recipes/Python/577439_Simple_commsubmitter/recipe-577439.py:54–74  ·  view source on GitHub ↗

Replace all {?} macros in pCommand

(pCommand, pFilePath, pSep='\\')

Source from the content-addressed store, hash-verified

52import subprocess
53
54def Expand(pCommand, pFilePath, pSep='\\'):
55 'Replace all {?} macros in pCommand'
56# Split file path into parts
57 if len(pFilePath) > 0:
58 lFilePath = os.path.abspath(pFilePath)
59 lEndPos = lFilePath.rfind(pSep)
60 lPath = lFilePath[0:lEndPos]
61 lFileName = lFilePath[lEndPos+1:]
62 lEndPos = lFileName.rfind(".")
63 lName = lFileName[:lEndPos]
64 lFilePart = lPath + pSep + lName
65 lExtension = lFileName[lEndPos+1:]
66 lPathParts = lFilePath.split(pSep)
67 else:
68 lFilePath = lPath=lFileName=lName=lFilePart=lExtension=""
69 lPathParts = []
70
71 lParts = pCommand.split('{')
72 if len(lParts) == 1: # no replacements
73 lCommand = pCommand
74 else: # scan and replace
75 commands
76 lCommand = lParts[0]
77 for lPart in lParts[1:]: # for each

Callers 1

recipe-577439.pyFile · 0.70

Calls 2

rfindMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected