summaryrefslogtreecommitdiff
path: root/client/map-db.py
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-12-14 10:24:48 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-12-14 10:24:48 -0800
commit78875e3c896656458d000c1987b1b0856fdb2bbe (patch)
tree9da2a6949fec98f2f48fc5f3f3799829a139be6c /client/map-db.py
parentbf2e24c6ed00e67466c1dbf967c23eef29aaf73e (diff)
parent709373a850e6c96aa03b56c8e0865a09db91b341 (diff)
downloadtools-78875e3c896656458d000c1987b1b0856fdb2bbe.tar.gz
tools-78875e3c896656458d000c1987b1b0856fdb2bbe.tar.bz2
tools-78875e3c896656458d000c1987b1b0856fdb2bbe.tar.xz
tools-78875e3c896656458d000c1987b1b0856fdb2bbe.zip
Merge remote-tracking branch 'origin/client'
Diffstat (limited to 'client/map-db.py')
-rwxr-xr-xclient/map-db.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/client/map-db.py b/client/map-db.py
new file mode 100755
index 0000000..5215e72
--- /dev/null
+++ b/client/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())