summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiyamed Sinir <siyamed@google.com>2015-11-20 14:15:32 -0800
committerSiyamed Sinir <siyamed@google.com>2015-11-25 11:32:02 -0800
commitef8ab805d2b114e9d0dd98ae067c056b4a09a377 (patch)
treec1fb05cf4cda525fff0577e27e0501b51eb6d90b
parent2718f10addffed64f80979f3429f4546051c5681 (diff)
downloadandroid_frameworks_ex-ef8ab805d2b114e9d0dd98ae067c056b4a09a377.tar.gz
android_frameworks_ex-ef8ab805d2b114e9d0dd98ae067c056b4a09a377.tar.bz2
android_frameworks_ex-ef8ab805d2b114e9d0dd98ae067c056b4a09a377.zip
Output shorter lines for TLD pattern
The output had line breaks at every alpha character and this caused lines that were too long to be in the code. This CL, tries to produce shorter lines by adding a new line if the current line is longer than a hundred characters. Change-Id: I87e8a1782ddc4f9369c0fd6018c499a2c0f75936
-rwxr-xr-xcommon/tools/make-iana-tld-pattern.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/common/tools/make-iana-tld-pattern.py b/common/tools/make-iana-tld-pattern.py
index d7cca93..9847b95 100755
--- a/common/tools/make-iana-tld-pattern.py
+++ b/common/tools/make-iana-tld-pattern.py
@@ -25,6 +25,29 @@ URL_PREFIX = r"""
"""
URL_SUFFIX = ';'
+TAB = ' '
+
+class BucketOutput:
+ def __init__(self):
+ self.buffer = TAB
+ self.lineLength = len(TAB)
+
+ def __iadd__(self, other):
+ self.buffer += other
+ self.lineLength += len(other)
+ return self
+
+ def addPipe(self):
+ if self.lineLength > 90:
+ self.buffer += '"\n'
+ self.buffer += TAB
+ self.buffer += '+ "'
+ self.lineLength = len(TAB)
+
+ self += '|'
+
+ def value(self):
+ return self.buffer
class Bucket:
def __init__(self, baseLetter):
@@ -39,7 +62,7 @@ class Bucket:
self.words.sort()
self.letters.sort()
- output = ' ';
+ output = BucketOutput()
if isFirst:
if isWebUrl:
@@ -58,7 +81,7 @@ class Bucket:
firstWord = 1
for word in self.words:
if firstWord == 0:
- output += '|'
+ output.addPipe()
firstWord = 0
for letter in word:
if letter == '-':
@@ -66,7 +89,7 @@ class Bucket:
output += letter
if len(self.words) > 0 and len(self.letters) > 0:
- output += '|'
+ output.addPipe()
if len(self.letters) == 1:
output += '%c%c' % (self.base, self.letters[0])
@@ -85,7 +108,7 @@ class Bucket:
output += '"'
output += '\n'
- return output;
+ return output.value();
def add(self, line):
length = len(line)