Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: third_party/harfbuzz/contrib/tables/unicode_parse_common.py

Issue 384503008: Delete third_party/harfbuzz (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove public header Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/harfbuzz/contrib/tables/scripts-parse.py ('k') | third_party/harfbuzz/harfbuzz.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/harfbuzz/contrib/tables/unicode_parse_common.py
diff --git a/third_party/harfbuzz/contrib/tables/unicode_parse_common.py b/third_party/harfbuzz/contrib/tables/unicode_parse_common.py
deleted file mode 100644
index ac26ecae3d935de1926ed531abb263102527a548..0000000000000000000000000000000000000000
--- a/third_party/harfbuzz/contrib/tables/unicode_parse_common.py
+++ /dev/null
@@ -1,70 +0,0 @@
-def lines_get(f):
- '''Parse a file like object, removing comments and returning a list of
- lines.'''
- def cut_comment(line):
- first_hash = line.find('#')
- if first_hash == -1:
- return line
- return line[:first_hash]
-
- return [x for x in [cut_comment(x[:-1]) for x in f.readlines()] if len(x)]
-
-def line_split(line):
- '''Split a line based on a semicolon separator.'''
- def normalise(word):
- return word.lstrip().rstrip()
- return [normalise(x) for x in line.split(';')]
-
-def codepoints_parse(token):
- '''Parse a Unicode style code-point range. Return either a single value or a
- tuple of (start, end) for a range of code-points.'''
- def fromHex(token):
- return int(token, 16)
- parts = token.split('..')
- if len(parts) == 2:
- return (fromHex(parts[0]), fromHex(parts[1]))
- elif len(parts) == 1:
- return fromHex(parts[0])
- else:
- raise ValueError(token)
-
-def unicode_file_parse(input, map, default_value = None):
- '''Parse a file like object, @input where the first column is a code-point
- range and the second column is mapped via the given dict, @map.'''
- ranges = []
- tokens = [line_split(x) for x in lines_get(input)]
- for line in tokens:
- if len(line) == 2:
- codepoints = codepoints_parse(line[0])
- value = map[line[1]]
- if value == default_value:
- continue
-
- if type(codepoints) == int:
- codepoints = (codepoints, codepoints)
-
- ranges.append((codepoints[0], codepoints[1], value))
- else:
- raise ValueError(line)
-
- return ranges
-
-def sort_and_merge(ranges):
- '''Given a list of (start, end, value), merge elements where the ranges are
- continuous and the values are the same.'''
- output = []
- ranges.sort()
- current = None
- for v in ranges:
- if current is None:
- current = v
- continue
- if current[1] + 1 == v[0] and current[2] == v[2]:
- current = (current[0], v[1], v[2])
- else:
- output.append(current)
- current = v
- if current is not None:
- output.append(current)
-
- return output
« no previous file with comments | « third_party/harfbuzz/contrib/tables/scripts-parse.py ('k') | third_party/harfbuzz/harfbuzz.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698