diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-06-27 10:36:17 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-06-27 10:42:32 -0400 |
commit | cd14868d4db8eaa7e9421e1d5fe8653294ac1e38 (patch) | |
tree | 52ad2955c9d81a979d5242262a0209eafd3a12d4 /tools/upgrade/1.4/convert_bundles.py | |
parent | 02783685f003b740b2ced28566833a46d3da07f1 (diff) | |
download | bcfg2-cd14868d4db8eaa7e9421e1d5fe8653294ac1e38.tar.gz bcfg2-cd14868d4db8eaa7e9421e1d5fe8653294ac1e38.tar.bz2 bcfg2-cd14868d4db8eaa7e9421e1d5fe8653294ac1e38.zip |
Options: migrated tools to new parser
Diffstat (limited to 'tools/upgrade/1.4/convert_bundles.py')
-rwxr-xr-x | tools/upgrade/1.4/convert_bundles.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/upgrade/1.4/convert_bundles.py b/tools/upgrade/1.4/convert_bundles.py new file mode 100755 index 000000000..b9cb483f2 --- /dev/null +++ b/tools/upgrade/1.4/convert_bundles.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import os +import sys +import lxml.etree +import Bcfg2.Options + + +def main(): + parser = Bcfg2.Options.get_parser("Tool to remove bundle names") + parser.add_options([Bcfg2.Options.Common.repository]) + parser.parse() + + bundler_dir = os.path.join(Bcfg2.Options.setup.repository, "Bundler") + if os.path.exists(bundler_dir): + for root, _, files in os.walk(bundler_dir): + for fname in files: + bpath = os.path.join(root, fname) + newpath = bpath + if newpath.endswith(".genshi"): + newpath = newpath[:-6] + "xml" + print("Converting %s to %s" % (bpath, newpath)) + else: + print("Converting %s" % bpath) + xroot = lxml.etree.parse(bpath) + xdata = xroot.getroot() + if 'name' in xdata.attrib: + del xdata.attrib['name'] + xroot.write(bpath) + +if __name__ == '__main__': + sys.exit(main()) |