summaryrefslogtreecommitdiff
path: root/scripts/cleanup-patterns.py
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-09 11:44:55 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-09 11:44:55 -0800
commit44b560e25016645fa5a9984cd0ca2e380046a185 (patch)
tree75883f4c10375062d09100e852bbda2a2226ebdd /scripts/cleanup-patterns.py
downloadpattern-tools-44b560e25016645fa5a9984cd0ca2e380046a185.tar.gz
pattern-tools-44b560e25016645fa5a9984cd0ca2e380046a185.tar.bz2
pattern-tools-44b560e25016645fa5a9984cd0ca2e380046a185.zip
initial checkin 001
Diffstat (limited to 'scripts/cleanup-patterns.py')
-rwxr-xr-xscripts/cleanup-patterns.py34
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()
+