def emit_normal_tests_tables(dir):
    normal_tests_data = get_normal_tests_data()

    with open(join(dir, 'conformance_tests_data.rsv'), "w") as values_file:
        rustout.emit_table(
            __file__,
            values_file,
            normal_tests_data,
            print_fun=lambda datum: ('(' + ', '.join(
                [rustout.string_literal(codepoints)
                 for codepoints in datum]) + ')'),
        )
def emit_age_tables(dir):
    age_values = get_age_values()

    with open(join(dir, 'age_values.rsv'), "w") as values_file:
        rustout.emit_table(
            __file__,
            values_file,
            age_values,
            print_fun=lambda x: "(%s, %s, %s)" % (
                rustout.char_literal(x[0]),
                rustout.char_literal(x[1]),
                x[2],
            ),
        )
def emit_bidi_class_tables(dir):
    (bidi_class_type, bidi_class_values) = get_bidi_class_info()

    with open(join(dir, 'bidi_class_type.rsv'), "w") as type_file:
        rustout.emit_class(
            __file__,
            type_file,
            bidi_class_type,
        )

    with open(join(dir, 'bidi_class_values.rsv'), "w") as values_file:
        rustout.emit_table(
            __file__,
            values_file,
            bidi_class_values,
            print_fun=lambda x: "(%s, %s, %s)" % (
                rustout.char_literal(x[0]),
                rustout.char_literal(x[1]),
                x[2],
            ),
        )
Exemple #4
0
def emit_idna_map_tables(dir):
    (map, map_string) = get_idna_mapping_table()

    with open(join(dir, 'idna_map.rsv'), "w") as map_file:
        rustout.emit_table(
            __file__,
            map_file,
            map,
            print_fun=lambda x:
            ("Range { from: '%s', to: '%s', mapping: %s }" % (
                char_escape(x[0]),
                char_escape(x[1]),
                x[2],
            )),
        )

    with open(join(dir, 'idna_map_string.rsv'), "w") as map_string_file:
        rustout.emit_strings(
            __file__,
            map_string_file,
            map_string.iterkeys(),
        )
def emit_normal_form_tables(dir):
    (
        general_category_mark,
        canonical_combining_class,
        canonical_decomposition_mapping,
        compatibility_decomposition_mapping,
        compatibility_decomposition_type,
    ) = get_normal_form_info()

    with open(join(dir, 'general_category_mark.rsv'), "w") as values_file:
        rustout.emit_table(
            __file__,
            values_file,
            general_category_mark,
            print_fun=lambda x: "(%s, %s)" % (
                rustout.char_literal(x[0]),
                rustout.char_literal(x[1]),
            ),
        )

    with open(join(dir, 'canonical_combining_class_values.rsv'),
              "w") as values_file:
        rustout.emit_table(
            __file__,
            values_file,
            canonical_combining_class,
            print_fun=lambda x: "(%s, %s, %s)" % (
                rustout.char_literal(x[0]),
                rustout.char_literal(x[1]),
                x[2],
            ),
        )

    with open(join(dir, 'compatibility_decomposition_type_values.rsv'),
              "w") as values_file:
        rustout.emit_table(
            __file__,
            values_file,
            compatibility_decomposition_type,
            print_fun=lambda x: "(%s, %s, %s)" % (
                rustout.char_literal(x[0]),
                rustout.char_literal(x[1]),
                x[2],
            ),
        )

    with open(join(dir, 'canonical_decomposition_mapping_lookup.rsv'), "w") as lookup_file, \
            open(join(dir, 'canonical_decomposition_mapping_values.rsv'), "w") as values_file:
        rustout.emit_lookup_tables(
            __file__,
            lookup_file,
            values_file,
            canonical_decomposition_mapping,
        )

    with open(join(dir, 'compatibility_decomposition_mapping_lookup.rsv'), "w") as lookup_file, \
            open(join(dir, 'compatibility_decomposition_mapping_values.rsv'), "w") as values_file:
        rustout.emit_lookup_tables(
            __file__,
            lookup_file,
            values_file,
            compatibility_decomposition_mapping,
        )

    with open(join(dir, 'canonical_composition_mapping_lookup.rsv'), "w") as lookup_file, \
            open(join(dir, 'canonical_composition_mapping_values.rsv'), "w") as values_file:
        canonical_composition_mapping = get_canonical_composition_mapping()
        rustout.emit_lookup_tables(
            __file__,
            lookup_file,
            values_file,
            canonical_composition_mapping,
            value_fun=lambda char: sorted(canonical_composition_mapping[char],
                                          lambda x, y: x[0] - y[0]),
            value_print_fun=lambda pair: "(%s, %s)" % (
                rustout.char_literal(pair[0]),
                rustout.char_literal(pair[1]),
            ),
        )