rouault / dump_gdbtable

Python script to dump the content of a .gdbtable
138 stars 24 forks source link

Print uuid as uuid (patch) #5

Closed tigerfoot closed 2 years ago

tigerfoot commented 8 years ago

In one dump I have to make it would be better to grab directly the uuid correctly formatted Here how I've done it.

diff --git i/dump_gdbtable.py w/dump_gdbtable.py
index ab00ac1..36137dd 100644
--- i/dump_gdbtable.py
+++ w/dump_gdbtable.py
@@ -34,6 +34,7 @@

 import struct
 import sys
+import uuid

 if len(sys.argv) != 2:
     print('Usage: dump_gdbtable.py some_file.gdbtable')
@@ -590,7 +591,7 @@ for fid in range(nfeaturesx):

         elif fields[ifield].type == 10 or fields[ifield].type == 11:
             val = f.read(16)
-            print('Field %s : "%s"' % (fields[ifield].name, ''.join(x.encode('hex') for x in val)))
+            print('Field %s : "%s"' % (fields[ifield].name, uuid.UUID(bytes=val)))

         elif fields[ifield].type == 7:
             geom_len = read_varuint(f)