diff options
author | Joshua Harlow <harlowja@gmail.com> | 2013-07-24 00:48:54 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2013-07-24 00:48:54 -0700 |
commit | b898aa96412367fb0cb0e920bb7d3b24933df414 (patch) | |
tree | 858b0eb1b71e5b16de95a55146ce0ea7a1f9b749 /cloudinit/helpers.py | |
parent | a4310ee3db0b394dcebd4f6b49d3b25bba37fedf (diff) | |
download | vyos-cloud-init-b898aa96412367fb0cb0e920bb7d3b24933df414.tar.gz vyos-cloud-init-b898aa96412367fb0cb0e920bb7d3b24933df414.zip |
Use the same method for registering custom vs default.
Instead of having a register default handler and a register
custom handler, just use the same function to do both but
provide a parameter to affect how overwritting of previously
existing content-types (which default handlers use to not
overwrite custom ones).
Diffstat (limited to 'cloudinit/helpers.py')
-rw-r--r-- | cloudinit/helpers.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py index 1c46efde..e500220a 100644 --- a/cloudinit/helpers.py +++ b/cloudinit/helpers.py @@ -292,11 +292,16 @@ class ContentHandlers(object): def is_registered(self, content_type): return content_type in self.registered - def register(self, mod, initialized=False): + def register(self, mod, initialized=False, overwrite=True): types = set() for t in mod.list_types(): + if overwrite: + types.add(t) + else: + if not self.is_registered(t): + types.add(t) + for t in types: self.registered[t] = mod - types.add(t) if initialized and mod not in self.initialized: self.initialized.append(mod) return types |