summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVincent Petithory <vincent.petithory@gmail.com>2013-03-28 13:17:45 +0100
committerVincent Petithory <vincent.petithory@gmail.com>2013-03-28 13:17:45 +0100
commit1dccaa5060ba18df40755154c0072e868d8b697b (patch)
tree4e6c5c50ad762fffe742a1014f5c9312258772de /tools
parentf30024b704a1307d4500c008615b1ae9ef503bf3 (diff)
downloadclientdata-1dccaa5060ba18df40755154c0072e868d8b697b.tar.gz
clientdata-1dccaa5060ba18df40755154c0072e868d8b697b.tar.bz2
clientdata-1dccaa5060ba18df40755154c0072e868d8b697b.tar.xz
clientdata-1dccaa5060ba18df40755154c0072e868d8b697b.zip
Add a tool to get data about the maps database.
* Add a command to list maps that do not have a minimap
Diffstat (limited to 'tools')
-rwxr-xr-xtools/map-db.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/map-db.py b/tools/map-db.py
new file mode 100755
index 00000000..5215e72d
--- /dev/null
+++ b/tools/map-db.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+import sys
+import os
+import subprocess
+import tempfile
+import re
+
+CLIENT_DATA_ROOT = os.path.realpath(
+ os.path.join(
+ os.path.dirname(__file__),
+ u'..',
+ )
+)
+
+MAP_RE = re.compile(r'^(\d{3})-(\d{1})$')
+
+def list_missing_minimaps(maps, minimaps):
+ def minimap_wanted(m):
+ match = MAP_RE.match(m)
+ if match:
+ d = match.group(2)
+ # We ignore indoor maps
+ if not d == '2':
+ return True
+ return False
+
+ missing_minimaps = set([m for m in maps if minimap_wanted(m)]) - set(minimaps)
+ retcode = len(missing_minimaps)
+ print '\n'.join(sorted(missing_minimaps))
+ return retcode
+
+def usage():
+ sys.stderr.write(u'''Usage: %(prgm_name)s CMD
+
+ Where CMD is one of:
+ list-missing-minimaps, lm: Lists all maps which do not
+ have a minimap.
+
+ \n''' % {'prgm_name': sys.argv[0]})
+
+def main():
+ if not len(sys.argv) > 1:
+ usage()
+ return 127
+ action = sys.argv[1].lower()
+ maps = [os.path.splitext(p)[0] for p in os.listdir(os.path.join(CLIENT_DATA_ROOT, u'maps'))]
+ minimaps = [os.path.splitext(p)[0] for p in os.listdir(os.path.join(CLIENT_DATA_ROOT, u'graphics', u'minimaps'))]
+ status = 0
+ if action in ('list-missing-minimaps', 'lm'):
+ status = list_missing_minimaps(maps, minimaps)
+ else:
+ usage()
+ return 127
+ return status
+
+if __name__ == '__main__':
+ sys.exit(main())