From c1a783b0389a507bdbe8e7643a53a66f03a2e308 Mon Sep 17 00:00:00 2001 From: Elvish_Hunter Date: Wed, 5 Aug 2015 17:12:38 +0200 Subject: [PATCH] all main wml tools: use filter(), map() and zip() from Python 3 The main difference is that these functions return generators instead of lists. This actually breaks wmlscope's collision detection, which will be fixed in my next commit. --- data/tools/wesnoth/wmliterator.py | 1 + data/tools/wesnoth/wmltools.py | 1 + data/tools/wmlindent | 1 + data/tools/wmllint | 1 + data/tools/wmlscope | 3 ++- 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/data/tools/wesnoth/wmliterator.py b/data/tools/wesnoth/wmliterator.py index 41b41ba02012..409e0207a5ec 100644 --- a/data/tools/wesnoth/wmliterator.py +++ b/data/tools/wesnoth/wmliterator.py @@ -21,6 +21,7 @@ """ from __future__ import print_function, unicode_literals +from future_builtins import filter, map, zip from functools import total_ordering import sys, re, copy, codecs diff --git a/data/tools/wesnoth/wmltools.py b/data/tools/wesnoth/wmltools.py index ec29a7284aea..c1681e5fba04 100644 --- a/data/tools/wesnoth/wmltools.py +++ b/data/tools/wesnoth/wmltools.py @@ -4,6 +4,7 @@ """ from __future__ import print_function, unicode_literals +from future_builtins import filter, map, zip from functools import total_ordering import collections, codecs diff --git a/data/tools/wmlindent b/data/tools/wmlindent index ef2bc2196ab2..bb9b0bd63c81 100755 --- a/data/tools/wmlindent +++ b/data/tools/wmlindent @@ -62,6 +62,7 @@ indent already zero; these two conditions strongly suggest unbalanced WML. """ from __future__ import print_function, unicode_literals +from future_builtins import filter, map, zip import sys, os, getopt, filecmp, re, codecs from wesnoth import wmltools diff --git a/data/tools/wmllint b/data/tools/wmllint index 43e2d735fe55..afceccc6a67e 100755 --- a/data/tools/wmllint +++ b/data/tools/wmllint @@ -182,6 +182,7 @@ # from __future__ import print_function, unicode_literals +from future_builtins import filter, map, zip import sys, os, re, getopt, string, copy, difflib, time, gzip, codecs from wesnoth.wmltools import * diff --git a/data/tools/wmlscope b/data/tools/wmlscope index c793b0f66215..dfb4a4a7b9e3 100755 --- a/data/tools/wmlscope +++ b/data/tools/wmlscope @@ -94,6 +94,7 @@ # sets the warning level. from __future__ import print_function, unicode_literals +from future_builtins import filter, map, zip import sys, os, time, re, getopt, hashlib, glob, codecs from wesnoth.wmltools import * @@ -448,7 +449,7 @@ Usage: wmlscope [options] dirpath collisions = [] for (namespace, filename) in xref.filelist.generator(): with open(filename, "rb") as ifp: # this one may be an image or a sound, so don't assume UTF8 encoding - collisions.append(hashlib.md5(ifp.read()).digest()) + collisions.append(hashlib.md5(ifp.read()).hexdigest()) # hexdigest can be easily printed, unlike digest collisions = zip(xref.filelist.flatten(), collisions) hashcounts = {} for (n, h) in collisions: