Replace once only

main
Bob Mottram 2020-09-14 14:05:12 +01:00
parent c07a8192f9
commit a3b95e65a2
1 changed files with 4 additions and 3 deletions

View File

@ -78,6 +78,9 @@ def setCSSparam(css: str, param: str, value: str) -> str:
searchStr = '--' + param + ':'
if searchStr not in css:
return css
if onceOnly:
s = css.split(searchStr, 1)
else:
s = css.split(searchStr)
newcss = ''
for sectionStr in s:
@ -92,8 +95,6 @@ def setCSSparam(css: str, param: str, value: str) -> str:
searchStr + ' ' + value + ';' + sectionStr.split(';', 1)[1]
else:
newcss += searchStr + ' ' + sectionStr
if onceOnly:
break
return newcss.strip()