summaryrefslogtreecommitdiff
path: root/tools/stringslint
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2021-01-21 19:06:26 -0800
committerHai Shalom <haishalom@google.com>2021-01-22 22:07:30 +0000
commitc960c92f9cc63cc891b0fba9c04d94127394f4ed (patch)
tree7b720c0a1b9a1b9e8c4311ce12c32dd0be2d6988 /tools/stringslint
parent286dc55bc983f7c0ea02cc920ff93b5a88472fa0 (diff)
Shift stringslint to using python3.
Bug: 169704254 Test: manual Change-Id: I175bdf75e7424bef6d4ac9f51797510766de2b14 (cherry picked from commit 85ccd0418097d774d8db8af77da2d6b5ed75d743) Merged-In: I354ef4b12c75505a069fdf657ab98a9b122785c7
Diffstat (limited to 'tools/stringslint')
-rw-r--r--tools/stringslint/stringslint.py12
-rwxr-xr-xtools/stringslint/stringslint_sha.sh2
2 files changed, 6 insertions, 8 deletions
diff --git a/tools/stringslint/stringslint.py b/tools/stringslint/stringslint.py
index afe91cda37b0..15088fc81e88 100644
--- a/tools/stringslint/stringslint.py
+++ b/tools/stringslint/stringslint.py
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
+#-*- coding: utf-8 -*-
# Copyright (C) 2018 The Android Open Source Project
#
@@ -33,9 +34,6 @@ In general:
import re, sys, codecs
import lxml.etree as ET
-reload(sys)
-sys.setdefaultencoding('utf8')
-
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
def format(fg=None, bg=None, bright=False, bold=False, dim=False, reset=False):
@@ -118,7 +116,7 @@ def lint(path):
raw = f.read()
if len(raw.strip()) == 0:
return warnings
- tree = ET.fromstring(raw)
+ tree = ET.fromstring(bytes(raw, encoding='utf-8'))
root = tree #tree.getroot()
last_comment = None
@@ -231,6 +229,6 @@ for b in before:
if len(after) > 0:
for a in sorted(after.keys()):
- print after[a]
- print
+ print(after[a])
+ print()
sys.exit(1)
diff --git a/tools/stringslint/stringslint_sha.sh b/tools/stringslint/stringslint_sha.sh
index bd80bb4e6f3f..bd0569873197 100755
--- a/tools/stringslint/stringslint_sha.sh
+++ b/tools/stringslint/stringslint_sha.sh
@@ -1,5 +1,5 @@
#!/bin/bash
LOCAL_DIR="$( dirname ${BASH_SOURCE} )"
git show --name-only --pretty=format: $1 | grep values/strings.xml | while read file; do
- python $LOCAL_DIR/stringslint.py <(git show $1:$file) <(git show $1^:$file)
+ python3 $LOCAL_DIR/stringslint.py <(git show $1:$file) <(git show $1^:$file)
done