(version, new, old)
| 802 | fprint('};') |
| 803 | |
| 804 | def merge_old_version(version, new, old): |
| 805 | # Changes to exclusion file not implemented yet |
| 806 | if old.exclusions != new.exclusions: |
| 807 | raise NotImplementedError("exclusions differ") |
| 808 | |
| 809 | # In these change records, 0xFF means "no change" |
| 810 | bidir_changes = [0xFF]*0x110000 |
| 811 | category_changes = [0xFF]*0x110000 |
| 812 | decimal_changes = [0xFF]*0x110000 |
| 813 | mirrored_changes = [0xFF]*0x110000 |
| 814 | east_asian_width_changes = [0xFF]*0x110000 |
| 815 | # In numeric data, 0 means "no change", |
| 816 | # -1 means "did not have a numeric value |
| 817 | numeric_changes = [0] * 0x110000 |
| 818 | # normalization_changes is a list of key-value pairs |
| 819 | normalization_changes = [] |
| 820 | for i in range(0x110000): |
| 821 | if new.table[i] is None: |
| 822 | # Characters unassigned in the new version ought to |
| 823 | # be unassigned in the old one |
| 824 | assert old.table[i] is None |
| 825 | continue |
| 826 | # check characters unassigned in the old version |
| 827 | if old.table[i] is None: |
| 828 | # category 0 is "unassigned" |
| 829 | category_changes[i] = 0 |
| 830 | continue |
| 831 | if old.bidi_classes[i] != new.bidi_classes[i]: |
| 832 | bidir_changes[i] = BIDIRECTIONAL_NAMES.index(old.bidi_classes[i]) |
| 833 | # check characters that differ |
| 834 | if old.table[i] != new.table[i]: |
| 835 | for k, field in enumerate(dataclasses.fields(UcdRecord)): |
| 836 | value = getattr(old.table[i], field.name) |
| 837 | new_value = getattr(new.table[i], field.name) |
| 838 | if value != new_value: |
| 839 | if k == 1 and i in PUA_15: |
| 840 | # the name is not set in the old.table, but in the |
| 841 | # new.table we are using it for aliases and named seq |
| 842 | assert value == '' |
| 843 | elif k == 2: |
| 844 | category_changes[i] = CATEGORY_NAMES.index(value) |
| 845 | elif k == 4: |
| 846 | # bidi_class changes handled via bidi_classes |
| 847 | pass |
| 848 | elif k == 5: |
| 849 | # We assume that all normalization changes are in 1:1 mappings |
| 850 | assert " " not in value |
| 851 | normalization_changes.append((i, value)) |
| 852 | elif k == 6: |
| 853 | # we only support changes where the old value is a single digit |
| 854 | assert value in "0123456789" |
| 855 | decimal_changes[i] = int(value) |
| 856 | elif k == 8: |
| 857 | # Since 0 encodes "no change", the old value is better not 0 |
| 858 | if not value: |
| 859 | numeric_changes[i] = -1 |
| 860 | else: |
| 861 | numeric_changes[i] = float(value) |
no test coverage detected
searching dependent graphs…