Make license-map compatible to both python2 and python3

Change-Id: I0871af54998b9a18aa71fd2d65baeb85a6c52877
This commit is contained in:
Han-Wen Nienhuys 2018-02-20 16:33:14 +01:00
parent 9b4a79532b
commit 49fa3930ac
2 changed files with 4 additions and 4 deletions

View File

@ -6,8 +6,8 @@ from __future__ import print_function
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 @@ for n in sorted(graph.keys()):
print()
print("[[%s_license]]" % safename)
print("----")
with open(n[2:].replace(":", "/")) as fd:
copyfileobj(fd, stdout)
with open(n[2:].replace(":", "/"), "rb") as input:
os.write(stdout.fileno(), input.read(-1))
print()
print("----")
print()

View File

@ -25,7 +25,7 @@ def license_map(name, targets = [], opts = [], **kwargs):
# post process the XML into our favorite format.
native.genrule(
name = "gen_license_txt_" + name,
cmd = "python2 $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
cmd = "python $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)),
outs = [ name + ".txt" ],
tools = tools,
**kwargs