diff options
Diffstat (limited to 'scripts/cleanup-patterns.py')
-rwxr-xr-x | scripts/cleanup-patterns.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/cleanup-patterns.py b/scripts/cleanup-patterns.py new file mode 100755 index 0000000..ab1e5ec --- /dev/null +++ b/scripts/cleanup-patterns.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + +import yaml +import sys, os +import optparse + + +def sort_pkgs(patterns_dir='patterns'): + for f in os.listdir(patterns_dir): + if not f.endswith('.yaml'): + continue + print f + stream = file("%s/%s" %(patterns_dir,f), 'r+') + y = yaml.load(stream) + if y.has_key('Packages'): + y['Packages'] = sorted(y['Packages']) + yf = yaml.dump(y, default_flow_style=False) + stream.seek(0) + stream.write(yf) + stream.close() + + + +if __name__ == '__main__': + parser = optparse.OptionParser() + + parser.add_option("-s", "--sort", action="store_true", default=False, + help="sort packages") + + (options, args) = parser.parse_args() + + if options.sort: + sort_pkgs() + |