(unicode, trace)
| 495 | # unicode character type tables |
| 496 | |
| 497 | def makeunicodetype(unicode, trace): |
| 498 | |
| 499 | FILE = "Objects/unicodetype_db.h" |
| 500 | |
| 501 | print("--- Preparing", FILE, "...") |
| 502 | |
| 503 | # extract unicode types |
| 504 | dummy = (0, 0, 0, 0, 0, 0) |
| 505 | table = [dummy] |
| 506 | cache = {dummy: 0} |
| 507 | index = [0] * len(unicode.chars) |
| 508 | numeric = {} |
| 509 | spaces = [] |
| 510 | linebreaks = [] |
| 511 | extra_casing = [] |
| 512 | |
| 513 | for char in unicode.chars: |
| 514 | record = unicode.table[char] |
| 515 | if record: |
| 516 | # extract database properties |
| 517 | category = record.general_category |
| 518 | bidirectional = unicode.bidi_classes[char] |
| 519 | properties = record.binary_properties |
| 520 | flags = 0 |
| 521 | if category in ["Lm", "Lt", "Lu", "Ll", "Lo"]: |
| 522 | flags |= ALPHA_MASK |
| 523 | if "Lowercase" in properties: |
| 524 | flags |= LOWER_MASK |
| 525 | if 'Line_Break' in properties or bidirectional == "B": |
| 526 | flags |= LINEBREAK_MASK |
| 527 | linebreaks.append(char) |
| 528 | if category == "Zs" or bidirectional in ("WS", "B", "S"): |
| 529 | flags |= SPACE_MASK |
| 530 | spaces.append(char) |
| 531 | if category == "Lt": |
| 532 | flags |= TITLE_MASK |
| 533 | if "Uppercase" in properties: |
| 534 | flags |= UPPER_MASK |
| 535 | if char == ord(" ") or category[0] not in ("C", "Z"): |
| 536 | flags |= PRINTABLE_MASK |
| 537 | if "XID_Start" in properties: |
| 538 | flags |= XID_START_MASK |
| 539 | if "XID_Continue" in properties: |
| 540 | flags |= XID_CONTINUE_MASK |
| 541 | if "Cased" in properties: |
| 542 | flags |= CASED_MASK |
| 543 | if "Case_Ignorable" in properties: |
| 544 | flags |= CASE_IGNORABLE_MASK |
| 545 | sc = unicode.special_casing.get(char) |
| 546 | cf = unicode.case_folding.get(char, [char]) |
| 547 | if record.simple_uppercase_mapping: |
| 548 | upper = int(record.simple_uppercase_mapping, 16) |
| 549 | else: |
| 550 | upper = char |
| 551 | if record.simple_lowercase_mapping: |
| 552 | lower = int(record.simple_lowercase_mapping, 16) |
| 553 | else: |
| 554 | lower = char |
no test coverage detected
searching dependent graphs…