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:

committed by
David Pursehouse

parent
de255d9b8b
commit
03b8b2caad
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
# Copyright (C) 2013 The Android Open Source Project
|
# 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()
|
options, _ = opts.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
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')
|
out_file = open(options.out, 'w')
|
||||||
src_file = open(options.src, 'r')
|
src_file = open(options.src, 'r')
|
||||||
last_line = ''
|
last_line = ''
|
||||||
ignore_next_line = False
|
ignore_next_line = False
|
||||||
last_title = ''
|
last_title = ''
|
||||||
for line in src_file.xreadlines():
|
for line in src_file:
|
||||||
if PAT_GERRIT.match(last_line):
|
if PAT_GERRIT.match(last_line):
|
||||||
# Case of "GERRIT\n------" at the footer
|
# Case of "GERRIT\n------" at the footer
|
||||||
out_file.write(GERRIT_UPLINK)
|
out_file.write(GERRIT_UPLINK)
|
||||||
|
@@ -113,7 +113,12 @@ for n in sorted(graph.keys()):
|
|||||||
print()
|
print()
|
||||||
print("[[%s_license]]" % safename)
|
print("[[%s_license]]" % safename)
|
||||||
print("----")
|
print("----")
|
||||||
with open(n[2:].replace(":", "/")) as fd:
|
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)
|
copyfileobj(fd, stdout)
|
||||||
print()
|
print()
|
||||||
print("----")
|
print("----")
|
||||||
|
@@ -25,7 +25,7 @@ def license_map(name, targets = [], opts = [], **kwargs):
|
|||||||
# post process the XML into our favorite format.
|
# post process the XML into our favorite format.
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = "gen_license_txt_" + name,
|
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" ],
|
outs = [ name + ".txt" ],
|
||||||
tools = tools,
|
tools = tools,
|
||||||
**kwargs
|
**kwargs
|
||||||
|
Reference in New Issue
Block a user