From 7f351786178c70e635fda0b7e27a8aaa45573d0a Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 19 Apr 2016 17:27:14 -0700 Subject: [PATCH] Fix package and image list comment cleanup When cleaning up comments from lines of the form: foo bar # this is a comment You want to remove remove everything after the first comment character not after the last comment character. This is because: foo bar # this is # a comment Should get everything after bar removed not everything after is. Unfortunately when you use str.rfind() you remove everything after is not everything after bar. Switch to regular trusty find to fix this. Change-Id: I78aa6b51b5be03bd3b8ce7885415442171218977 --- .../cache-devstack/extra-data.d/55-cache-devstack-repos | 4 ++-- nodepool/scripts/cache_devstack.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nodepool/elements/cache-devstack/extra-data.d/55-cache-devstack-repos b/nodepool/elements/cache-devstack/extra-data.d/55-cache-devstack-repos index 675879d15c..75b15094f0 100755 --- a/nodepool/elements/cache-devstack/extra-data.d/55-cache-devstack-repos +++ b/nodepool/elements/cache-devstack/extra-data.d/55-cache-devstack-repos @@ -81,7 +81,7 @@ def tokenize(fn, tokens, distribution, comment=None): if 'qpid' in line: continue # TODO: explain why this is here if comment and comment in line: - line = line[:line.rfind(comment)] + line = line[:line.find(comment)] line = line.strip() if line and line not in tokens: tokens.append(line) @@ -94,7 +94,7 @@ def _legacy_find_images(basedir): line = line.strip() if line.startswith('IMAGE_URLS'): if '#' in line: - line = line[:line.rfind('#')] + line = line[:line.find('#')] if line.endswith(';;'): line = line[:-2] line = line.split('=', 1)[1].strip() diff --git a/nodepool/scripts/cache_devstack.py b/nodepool/scripts/cache_devstack.py index 379d13aa06..0c7505959b 100755 --- a/nodepool/scripts/cache_devstack.py +++ b/nodepool/scripts/cache_devstack.py @@ -46,7 +46,7 @@ def tokenize(fn, tokens, distribution, comment=None): if 'qpid' in line: continue # TODO: explain why this is here if comment and comment in line: - line = line[:line.rfind(comment)] + line = line[:line.find(comment)] line = line.strip() if line and line not in tokens: tokens.append(line) @@ -59,7 +59,7 @@ def _legacy_find_images(basedir): line = line.strip() if line.startswith('IMAGE_URLS'): if '#' in line: - line = line[:line.rfind('#')] + line = line[:line.find('#')] if line.endswith(';;'): line = line[:-2] line = line.split('=', 1)[1].strip()