unicodedata-reader 1.3.3__tar.gz → 1.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (17) hide show
  1. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/PKG-INFO +1 -1
  2. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/pyproject.toml +1 -1
  3. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/entry.py +14 -10
  4. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/LICENSE +0 -0
  5. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/README.md +0 -0
  6. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/__init__.py +0 -0
  7. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/__main__.py +0 -0
  8. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/bidi_brackets.py +0 -0
  9. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/cli.py +0 -0
  10. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/compressor.py +0 -0
  11. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/east_asian_width.py +0 -0
  12. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/emoji.py +0 -0
  13. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/general_category.py +0 -0
  14. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/line_break.py +0 -0
  15. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/reader.py +0 -0
  16. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/set.py +0 -0
  17. {unicodedata_reader-1.3.3 → unicodedata_reader-1.3.4}/unicodedata_reader/vertical_orientation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unicodedata-reader
3
- Version: 1.3.3
3
+ Version: 1.3.4
4
4
  Summary:
5
5
  Home-page: https://github.com/kojiishi/unicodedata-reader
6
6
  License: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "unicodedata-reader"
7
- version = "1.3.3"
7
+ version = "1.3.4"
8
8
  description = ""
9
9
  authors = ["Koji Ishii <kojii@chromium.org>"]
10
10
  readme = "README.md"
@@ -16,7 +16,7 @@ from typing import Tuple
16
16
  _logger = logging.getLogger('UnicodeDataEntry')
17
17
 
18
18
 
19
- def u_hex(value):
19
+ def u_hex(value: int) -> str:
20
20
  return f'{value:04X}'
21
21
 
22
22
 
@@ -79,16 +79,24 @@ class UnicodeDataEntry(object):
79
79
  def is_in_range(self, code: int) -> bool:
80
80
  return code >= self.min and code <= self.max
81
81
 
82
+ @staticmethod
83
+ def to_codes(entries: Iterable['UnicodeDataEntry']):
84
+ return itertools.chain(*(e.range() for e in entries))
85
+
82
86
  @property
83
87
  def count(self):
84
88
  self.assert_range()
85
89
  return self.max - self.min + 1
86
90
 
87
- def range_as_str(self):
91
+ def range_as_str(self, converter: Callable[[int], str] = u_hex):
88
92
  self.assert_range()
93
+ min = converter(self.min)
89
94
  if self.min == self.max:
90
- return u_hex(self.min)
91
- return f'{u_hex(self.min)}..{u_hex(self.max)}'
95
+ return min
96
+ max = converter(self.max)
97
+ if min == max:
98
+ return min
99
+ return f'{min}..{max}'
92
100
 
93
101
  def to_str(self, separator: str = ';'):
94
102
  return separator.join((self.range_as_str(), str(self.value)))
@@ -268,18 +276,14 @@ class UnicodeDataEntries(object):
268
276
  """Returns an `Iterable` of `UnicodeDataEntry` for the given `pred`."""
269
277
  return (entry for entry in self if pred(entry.value))
270
278
 
271
- def codes_for(self, pred: Callable[[Any], bool]) -> Iterable[int]:
272
- """Returns an `Iterable` of Unicode code points for the given `pred`."""
273
- return itertools.chain(*(e.range() for e in self.filter(pred)))
274
-
275
279
  def add_to_set(self, pred: Callable[[Any], bool], set: set) -> None:
276
280
  """Add values `pred` returns `True` to `set[int]`."""
277
- for code in self.codes_for(pred):
281
+ for code in UnicodeDataEntry.to_codes(self.filter(pred)):
278
282
  set.add(code)
279
283
 
280
284
  def remove_from_set(self, pred: Callable[[Any], bool], set: set) -> None:
281
285
  """Remove values `pred` returns `True` from `set[int]`."""
282
- for code in self.codes_for(pred):
286
+ for code in UnicodeDataEntry.to_codes(self.filter(pred)):
283
287
  set.discard(code)
284
288
 
285
289
  def to_set(self, pred: Callable[[Any], bool]) -> set: