Merge "Revert "Make license-map compatible to both python2 and python3""
diff --git a/tools/bzl/license-map.py b/tools/bzl/license-map.py
index 79aed37..1c8db72 100644
--- a/tools/bzl/license-map.py
+++ b/tools/bzl/license-map.py
@@ -6,8 +6,8 @@
import argparse
from collections import defaultdict
+from shutil import copyfileobj
from sys import stdout, stderr
-import os
import xml.etree.ElementTree as ET
@@ -113,8 +113,8 @@
print()
print("[[%s_license]]" % safename)
print("----")
- with open(n[2:].replace(":", "/"), "rb") as input:
- os.write(stdout.fileno(), input.read(-1))
+ with open(n[2:].replace(":", "/")) as fd:
+ copyfileobj(fd, stdout)
print()
print("----")
print()
diff --git a/tools/bzl/license.bzl b/tools/bzl/license.bzl
index 38dfbe5..3578173 100644
--- a/tools/bzl/license.bzl
+++ b/tools/bzl/license.bzl
@@ -25,7 +25,7 @@
# post process the XML into our favorite format.
native.genrule(
name = "gen_license_txt_" + name,
- cmd = "python $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
+ cmd = "python2 $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
outs = [ name + ".txt" ],
tools = tools,
**kwargs