MCPcopy Create free account
hub / github.com/apache/cloudstack / replaceIfFound

Method replaceIfFound

systemvm/debian/opt/cloud/bin/cs/CsFile.py:119–131  ·  view source on GitHub ↗
(self, search, replace)

Source from the content-addressed store, hash-verified

117 self.new_config = [w.replace(search, replace) for w in self.new_config]
118
119 def replaceIfFound(self, search, replace):
120 found = False
121 replace_filtered = replace
122 if re.search("PSK \"", replace):
123 replace_filtered = re.sub(r'".*"', '"****"', replace)
124 logging.debug("Searching for %s and replacing with %s if found" % (search, replace_filtered))
125 for index, line in enumerate(self.new_config):
126 if line.lstrip().startswith("#"):
127 continue
128 if re.search(search, line):
129 if replace not in line:
130 self.new_config[index] = replace + "\n"
131 return False
132
133 def search(self, search, replace):
134 found = False

Callers 2

setupMethod · 0.95
processMethod · 0.80

Calls 2

debugMethod · 0.80
searchMethod · 0.65

Tested by

no test coverage detected