Bug 893830 - implement mach uuid. r=gps DONTBUILD
authorGraeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
Mon, 15 Jul 2013 18:00:09 +0100
changeset 138558 a639cb76d4d9620a8961f3fbf08cbfe3d08f1964
parent 138557 38e84638eb6da79a54966a8065b07258f264e6f0
child 138559 77a5ea5dc277600bb67bffe97bac1ebfa5c9e685
push idunknown
push userunknown
push dateunknown
reviewersgps
bugs893830
milestone25.0a1
Bug 893830 - implement mach uuid. r=gps DONTBUILD
tools/mach_commands.py
--- a/tools/mach_commands.py
+++ b/tools/mach_commands.py
@@ -54,8 +54,25 @@ class SearchProvider(object):
         'This will open 3 new browser tabs and search for the term on Google, '
         'MDN, and MXR.')
     @CommandArgument('term', nargs='+', help='Term(s) to search for.')
     def search(self, term):
         self.google(term)
         self.mdn(term)
         self.mxr(term)
 
+
+@CommandProvider
+class UUIDProvider(object):
+    @Command('uuid', category='misc',
+        description='Generate a uuid.')
+    @CommandArgument('--format', '-f', choices=['idl', 'cpp'], default='idl',
+                     help='Output format for the generated uuid.')
+    def uuid(self, format):
+        import uuid
+        u = uuid.uuid4()
+        if format == 'idl':
+            print(u)
+        else:
+            u = u.hex
+            print('{ 0x%s, 0x%s, 0x%s, \\' % (u[0:8], u[8:12], u[12:16]))
+            pairs = tuple(map(lambda n: u[n:n+2], range(16, 32, 2)))
+            print(('  { ' + '0x%s, ' * 7 + '0x%s } }') % pairs)