Skip to content

Commit 64a2e02

Browse files
committed
Handle multiple scoreResources, but remove unused ones
1 parent a6f43e6 commit 64a2e02

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/sasctl/utils/modelMigration.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ def convertScoreCode(zPath, scoreResource, pythonScoreCode):
107107
# Search for all directory paths in score code that contain the scoreResource
108108
oldString = re.findall(r"['\"]\/.*?\.[\w:]+['\"]", scoreCode)
109109
parsedOldString = []
110+
newString = []
110111
for resource in scoreResource:
111-
parsedOldString = parsedOldString + [s for s in oldString if resource in s]
112-
# Remove duplicates, as .replace() checks for all instances
113-
oldString = list(set(parsedOldString))
114-
# Replace Viya 3.5 style with Viya 4 style
115-
newString = "settings.pickle_path + '{}'".format(scoreResource)
116-
for oldStr in oldString:
112+
stringFound = []
113+
stringFound = [s for s in oldString if resource in s]
114+
parsedOldString = parsedOldString + stringFound
115+
if stringFound:
116+
newString.append("settings.pickle_path + '{}'".format(resource))
117+
for oldStr in parsedOldString:
117118
scoreCode = scoreCode.replace(oldStr, newString)
118119

119120
# Write new text of score code to file

0 commit comments

Comments
 (0)