diff options
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 4f5b15ee..ab918433 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -52,6 +52,7 @@ from cloudinit import importer from cloudinit import log as logging from cloudinit import safeyaml from cloudinit import url_helper as uhelp +from cloudinit import version from cloudinit.settings import (CFG_BUILTIN) @@ -272,11 +273,7 @@ def uniq_merge(*lists): # Kickout the empty ones a_list = [a for a in a_list if len(a)] combined_list.extend(a_list) - uniq_list = [] - for i in combined_list: - if i not in uniq_list: - uniq_list.append(i) - return uniq_list + return uniq_list(combined_list) def clean_filename(fn): @@ -989,6 +986,16 @@ def peek_file(fname, max_bytes): return ifh.read(max_bytes) +def uniq_list(in_list): + out_list = [] + for i in in_list: + if i in out_list: + continue + else: + out_list.append(i) + return out_list + + def load_file(fname, read_cb=None, quiet=False): LOG.debug("Reading from %s (quiet=%s)", fname, quiet) ofh = StringIO() @@ -1428,6 +1435,14 @@ def subp(args, data=None, rcs=None, env=None, capture=True, shell=False, return (out, err) +def make_header(comment_char="#", base='created'): + ci_ver = version.version_string() + header = str(comment_char) + header += " %s by cloud-init v. %s" % (base.title(), ci_ver) + header += " on %s" % time_rfc2822() + return header + + def abs_join(*paths): return os.path.abspath(os.path.join(*paths)) |