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

Method __init__

Tools/clinic/libclinic/app.py:82–157  ·  view source on GitHub ↗
(
        self,
        language: CLanguage,
        printer: BlockPrinter | None = None,
        *,
        filename: str,
        limited_capi: bool,
        verify: bool = True,
    )

Source from the content-addressed store, hash-verified

80"""
81
82 def __init__(
83 self,
84 language: CLanguage,
85 printer: BlockPrinter | None = None,
86 *,
87 filename: str,
88 limited_capi: bool,
89 verify: bool = True,
90 ) -> None:
91 # maps strings to Parser objects.
92 # (instantiated from the "parsers" global.)
93 self.parsers: dict[str, Parser] = {}
94 self.language: CLanguage = language
95 if printer:
96 fail("Custom printers are broken right now")
97 self.printer = printer or BlockPrinter(language)
98 self.verify = verify
99 self.limited_capi = limited_capi
100 self.filename = filename
101 self.modules: ModuleDict = {}
102 self.classes: ClassDict = {}
103 self.functions: list[Function] = []
104 self.codegen = CodeGen(self.limited_capi)
105
106 self.line_prefix = self.line_suffix = ''
107
108 self.destinations: DestinationDict = {}
109 self.add_destination("block", "buffer")
110 self.add_destination("suppress", "suppress")
111 self.add_destination("buffer", "buffer")
112 if filename:
113 self.add_destination("file", "file", "{dirname}/clinic/{basename}.h")
114
115 d = self.get_destination_buffer
116 self.destination_buffers = {
117 'cpp_if': d('file'),
118 'docstring_prototype': d('suppress'),
119 'docstring_definition': d('file'),
120 'methoddef_define': d('file'),
121 'impl_prototype': d('file'),
122 'parser_prototype': d('suppress'),
123 'parser_definition': d('file'),
124 'cpp_endif': d('file'),
125 'methoddef_ifndef': d('file', 1),
126 'impl_definition': d('block'),
127 }
128
129 DestBufferType = dict[str, list[str]]
130 DestBufferList = list[DestBufferType]
131
132 self.destination_buffers_stack: DestBufferList = []
133
134 self.presets: dict[str, dict[Any, Any]] = {}
135 preset = None
136 for line in self.presets_text.strip().split('\n'):
137 line = line.strip()
138 if not line:
139 continue

Callers 1

__post_init__Method · 0.45

Calls 8

add_destinationMethod · 0.95
failFunction · 0.90
BlockPrinterClass · 0.90
CodeGenClass · 0.90
dFunction · 0.50
splitMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected