cpython/Tools/clinic/libclinic/__init__.py
Victor Stinner 5fd1897ec5
gh-113317: Argument Clinic: Add libclinic.converters module (#117315)
Move the following converter classes to libclinic.converters:

* PyByteArrayObject_converter
* PyBytesObject_converter
* Py_UNICODE_converter
* Py_buffer_converter
* Py_complex_converter
* Py_ssize_t_converter
* bool_converter
* byte_converter
* char_converter
* defining_class_converter
* double_converter
* fildes_converter
* float_converter
* int_converter
* long_converter
* long_long_converter
* object_converter
* self_converter
* short_converter
* size_t_converter
* slice_index_converter
* str_converter
* unicode_converter
* unsigned_char_converter
* unsigned_int_converter
* unsigned_long_converter
* unsigned_long_long_converter
* unsigned_short_converter

Move also the following classes to libclinic.converters:

* buffer
* robuffer
* rwbuffer

Move the following functions to libclinic.converters:

* correct_name_for_self()
* r()
* str_converter_key()

Move Null and NULL to libclinic.utils.
2024-04-02 10:09:53 +00:00

92 lines
1.6 KiB
Python

from typing import Final
from .errors import (
ClinicError,
warn,
fail,
)
from .formatting import (
SIG_END_MARKER,
c_repr,
docstring_for_c_string,
format_escape,
indent_all_lines,
linear_format,
normalize_snippet,
pprint_words,
suffix_all_lines,
wrap_declarations,
wrapped_c_string_literal,
)
from .identifiers import (
ensure_legal_c_identifier,
is_legal_c_identifier,
is_legal_py_identifier,
)
from .utils import (
FormatCounterFormatter,
NULL,
Null,
Sentinels,
VersionTuple,
compute_checksum,
create_regex,
unknown,
unspecified,
write_file,
)
__all__ = [
# Error handling
"ClinicError",
"warn",
"fail",
# Formatting helpers
"SIG_END_MARKER",
"c_repr",
"docstring_for_c_string",
"format_escape",
"indent_all_lines",
"linear_format",
"normalize_snippet",
"pprint_words",
"suffix_all_lines",
"wrap_declarations",
"wrapped_c_string_literal",
# Identifier helpers
"ensure_legal_c_identifier",
"is_legal_c_identifier",
"is_legal_py_identifier",
# Utility functions
"FormatCounterFormatter",
"NULL",
"Null",
"Sentinels",
"VersionTuple",
"compute_checksum",
"create_regex",
"unknown",
"unspecified",
"write_file",
]
CLINIC_PREFIX: Final = "__clinic_"
CLINIC_PREFIXED_ARGS: Final = frozenset(
{
"_keywords",
"_parser",
"args",
"argsbuf",
"fastargs",
"kwargs",
"kwnames",
"nargs",
"noptargs",
"return_value",
}
)