MCPcopy Index your code
hub / github.com/python/cpython / UcdFile

Class UcdFile

Tools/unicode/makeunicodedata.py:937–966  ·  view source on GitHub ↗

A file in the standard format of the UCD. See: https://www.unicode.org/reports/tr44/#Format_Conventions Note that, as described there, the Unihan data files have their own separate format.

Source from the content-addressed store, hash-verified

935
936
937class UcdFile:
938 '''
939 A file in the standard format of the UCD.
940
941 See: https://www.unicode.org/reports/tr44/#Format_Conventions
942
943 Note that, as described there, the Unihan data files have their
944 own separate format.
945 '''
946
947 def __init__(self, template: str, version: str) -> None:
948 self.template = template
949 self.version = version
950
951 def records(self) -> Iterator[List[str]]:
952 with open_data(self.template, self.version) as file:
953 for line in file:
954 line = line.split('#', 1)[0].strip()
955 if not line:
956 continue
957 yield [field.strip() for field in line.split(';')]
958
959 def __iter__(self) -> Iterator[List[str]]:
960 return self.records()
961
962 def expanded(self) -> Iterator[Tuple[int, List[str]]]:
963 for record in self.records():
964 char_range, rest = record[0], record[1:]
965 for char in expand_range(char_range):
966 yield char, rest
967
968
969@dataclasses.dataclass

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…