[infinispan-commits] Infinispan SVN: r224 - trunk/bin.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu May 7 10:01:59 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-05-07 10:01:59 -0400 (Thu, 07 May 2009)
New Revision: 224
Added:
trunk/bin/listCommandIDs.py
Log:
Added: trunk/bin/listCommandIDs.py
===================================================================
--- trunk/bin/listCommandIDs.py (rev 0)
+++ trunk/bin/listCommandIDs.py 2009-05-07 14:01:59 UTC (rev 224)
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+import re
+import sys
+from pythonTools import *
+
+
+command_file_name = re.compile('(commands/[a-zA-Z0-9/]*Command.java)')
+
+def trimName(nm):
+ res = command_file_name.search(nm)
+ if res:
+ return res.group(1)
+ else:
+ return nm
+
+def get_next(ids_used):
+ # Cannot assume a command ID greater than the size of 1 byte!
+ for i in range(1, 128):
+ if i not in ids_used:
+ return i
+ return -1
+
+
+command_line_regexp = re.compile('COMMAND_ID\s*=\s*([0-9]+)\s*;')
+
+
+command_ids = {}
+
+for testFile in GlobDirectoryWalker(getSearchPath(sys.argv[0]) + 'core/src/main/java/org/infinispan/commands', '*Command.java'):
+ tf = open(testFile)
+ try:
+ for line in tf:
+ mo = command_line_regexp.search(line)
+ if mo:
+ command_ids[int(mo.group(1))] = trimName(testFile)
+ finally:
+ tf.close()
+
+print 'Scanned %s Command source files. IDs are (in order):' % len(command_ids)
+
+sortedKeys = command_ids.keys()
+sortedKeys.sort()
+
+i=1
+for k in sortedKeys:
+ print ' %s) Class [%s] has COMMAND_ID [%s]' % (i, command_ids[k], k)
+ i += 1
+
+print "\n"
+print "Next available ID is %s" % get_next(sortedKeys)
Property changes on: trunk/bin/listCommandIDs.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the infinispan-commits
mailing list