license and doc: Add support for python3

With homebrew's recent change of making python3 the default
over python2, lets support python3.

Bug: Issue 8474
Change-Id: I8dba441c8d717ae06d156c9201a02926884fd5f0
This commit is contained in:
Paladox none
2018-03-02 15:48:43 +00:00
committed by David Pursehouse
parent de255d9b8b
commit 03b8b2caad
3 changed files with 16 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
# coding=utf-8
# Copyright (C) 2013 The Android Open Source Project
#
@@ -229,12 +229,16 @@ opts.add_option('--no-searchbox', action="store_false", dest='searchbox',
options, _ = opts.parse_args()
try:
out_file = open(options.out, 'w')
src_file = open(options.src, 'r')
try:
out_file = open(options.out, 'w', errors='ignore')
src_file = open(options.src, 'r', errors='ignore')
except TypeError:
out_file = open(options.out, 'w')
src_file = open(options.src, 'r')
last_line = ''
ignore_next_line = False
last_title = ''
for line in src_file.xreadlines():
for line in src_file:
if PAT_GERRIT.match(last_line):
# Case of "GERRIT\n------" at the footer
out_file.write(GERRIT_UPLINK)

View File

@@ -113,8 +113,13 @@ for n in sorted(graph.keys()):
print()
print("[[%s_license]]" % safename)
print("----")
with open(n[2:].replace(":", "/")) as fd:
copyfileobj(fd, stdout)
filename = n[2:].replace(":", "/")
try:
with open(filename, errors='ignore') as fd:
copyfileobj(fd, stdout)
except TypeError:
with open(filename) as fd:
copyfileobj(fd, stdout)
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