summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-07-23 12:05:04 -0400
committerScott Moser <smoser@ubuntu.com>2013-07-23 12:05:04 -0400
commit838d6c7ddcac8544afb99cb78e8d044fd63b835f (patch)
treec44bde5e0e7a64a70d1981c38d468311435fafd5 /cloudinit/util.py
parenta8d2b2f8d7b9315d729873b15ed8dedb9c1b069f (diff)
parent27f096a1ab2e60222f85d87c961e388fdefaf92c (diff)
downloadvyos-cloud-init-838d6c7ddcac8544afb99cb78e8d044fd63b835f.tar.gz
vyos-cloud-init-838d6c7ddcac8544afb99cb78e8d044fd63b835f.zip
use constants for startswith in handlers. add strip_prefix_suffix.
Just cleans up some repeated strings into module constants + a util function to do the boothook prefix cleanup (before writing).
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index c45aae06..47d71ef4 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1530,6 +1530,14 @@ def shellify(cmdlist, add_header=True):
return content
+def strip_prefix_suffix(line, prefix=None, suffix=None):
+ if prefix and line.startswith(prefix):
+ line = line[len(prefix):]
+ if suffix and line.endswith(suffix):
+ line = line[:-len(suffix)]
+ return line
+
+
def is_container():
"""
Checks to see if this code running in a container of some sort