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

Function makeunicodetype

Tools/unicode/makeunicodedata.py:497–704  ·  view source on GitHub ↗
(unicode, trace)

Source from the content-addressed store, hash-verified

495# unicode character type tables
496
497def 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

Callers 1

maketablesFunction · 0.85

Calls 15

partialClass · 0.90
absFunction · 0.85
splitbinsFunction · 0.85
ArrayClass · 0.70
openFunction · 0.50
appendMethod · 0.45
getMethod · 0.45
extendMethod · 0.45
setdefaultMethod · 0.45
valuesMethod · 0.45
dumpMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…