diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-11-12 22:06:11 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-11-12 22:06:11 -0800 |
commit | aa6fe50ac4e09490a16c7b7200d57496d9f755bf (patch) | |
tree | 8741f0232ca1de144223ace65f2477fd6f8919f6 /cloudinit/util.py | |
parent | 8d5e1e108b0cdd3af872383da7654bec91355b5f (diff) | |
parent | 29b4adef881852169c6a0c5c95168c768cb6ffc5 (diff) | |
download | vyos-cloud-init-aa6fe50ac4e09490a16c7b7200d57496d9f755bf.tar.gz vyos-cloud-init-aa6fe50ac4e09490a16c7b7200d57496d9f755bf.zip |
Rebased with HEAD and resolved conflicts.
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)) |