diff options
author | Kahrl <kahrl@gmx.net> | 2011-09-26 13:24:21 +0200 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2011-09-26 13:24:21 +0200 |
commit | 561bb649632c942b8c45b52558d180b83b48b681 (patch) | |
tree | c7afe74d6f96dee3cd69d4c3dc3de8657e2e1326 | |
parent | d5899a53fd3c1c78b998a3384216ef719e46bf9f (diff) | |
download | minetest-561bb649632c942b8c45b52558d180b83b48b681.tar.gz minetest-561bb649632c942b8c45b52558d180b83b48b681.tar.bz2 minetest-561bb649632c942b8c45b52558d180b83b48b681.zip |
Support Python 2 and 3 in sectors2sqlite.py.
-rwxr-xr-x | util/sectors2sqlite.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/util/sectors2sqlite.py b/util/sectors2sqlite.py index 178842129..38261a498 100755 --- a/util/sectors2sqlite.py +++ b/util/sectors2sqlite.py @@ -3,7 +3,7 @@ # Loads block files from sectors folders into map.sqlite database. # The sectors folder should be safe to remove after this prints "Finished." -import time, os +import time, os, sys try: import sqlite3 @@ -114,8 +114,13 @@ for base in paths: continue f = open(root+'/'+block, 'rb') - cur.execute('INSERT OR IGNORE INTO `blocks` VALUES(?, ?)', (pos, f.read())) + blob = f.read() f.close() + if sys.version_info.major == 2: + blob = buffer(blob) + else: + blob = memoryview(blob) + cur.execute('INSERT OR IGNORE INTO `blocks` VALUES(?, ?)', (pos, blob)) count += 1 if(time.time() - t > 3): |