in hack/create_kptfile.py [0:0]
def strip_comments(path):
"""Strip the existing comments from YAML files"""
for root, _, files in os.walk(path):
for f in files:
ext = os.path.splitext(f)[-1]
logging.info(f"{ext}")
if ext != ".yaml":
continue
p = os.path.join(root, f)
logging.info(f"Proccessing {p}")
with open(p) as hf:
lines = hf.readlines()
new_lines = []
for l in lines:
if re.match("[^#]+#.*x-kustomize.*", l):
pieces = l.split("#", 1)
new_lines.append(pieces[0].rstrip() + "\n")
else:
new_lines.append(l)
with open(p, "w") as hf:
hf.writelines(new_lines)