id
int64
1
6.07M
name
stringlengths
1
295
code
stringlengths
12
426k
language
stringclasses
1 value
source_file
stringlengths
5
202
start_line
int64
1
158k
end_line
int64
1
158k
repo
dict
9,801
notifyTestFailedExpectedly
def notifyTestFailedExpectedly(self, test, err): super(TkTestRunner, self).notifyTestFailedExpectedly(test, err) self.expectFailCountVar.set(1 + self.expectFailCountVar.get())
python
Tools/unittestgui/unittestgui.py
400
402
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,802
notifyTestFinished
def notifyTestFinished(self, test): self.remainingCountVar.set(self.remainingCountVar.get() - 1) self.runCountVar.set(1 + self.runCountVar.get()) fractionDone = float(self.runCountVar.get())/float(self.totalTests) fillColor = len(self.errorInfo) and "red" or "green" self.progress...
python
Tools/unittestgui/unittestgui.py
405
410
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,803
showSelectedError
def showSelectedError(self): selection = self.errorListbox.curselection() if not selection: return selected = int(selection[0]) txt = self.errorListbox.get(selected) window = tk.Toplevel(self.root) window.title(txt) window.protocol('WM_DELETE_WINDOW', window.quit)...
python
Tools/unittestgui/unittestgui.py
412
430
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,804
__init__
def __init__(self, *args, **kwargs): tk.Frame.__init__(self, *args, **kwargs) self.canvas = tk.Canvas(self, height='20', width='60', background='white', borderwidth=3) self.canvas.pack(fill=tk.X, expand=1) self.rect = self.text = None self.canvas.b...
python
Tools/unittestgui/unittestgui.py
437
444
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,805
setProgressFraction
def setProgressFraction(self, fraction, color='blue'): self.fraction = fraction self.color = color self.paint() self.canvas.update_idletasks()
python
Tools/unittestgui/unittestgui.py
446
450
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,806
paint
def paint(self, *args): totalWidth = self.canvas.winfo_width() width = int(self.fraction * float(totalWidth)) height = self.canvas.winfo_height() if self.rect is not None: self.canvas.delete(self.rect) if self.text is not None: self.canvas.delete(self.text) self.rect = se...
python
Tools/unittestgui/unittestgui.py
452
463
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,807
main
def main(initialTestName=""): root = tk.Tk() root.title("PyUnit") runner = TkTestRunner(root, initialTestName) root.protocol('WM_DELETE_WINDOW', root.quit) root.mainloop()
python
Tools/unittestgui/unittestgui.py
465
470
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,808
usage
def usage(code, msg=''): print(__doc__, file=sys.stderr) if msg: print(msg, file=sys.stderr) sys.exit(code)
python
Tools/i18n/msgfmt.py
41
45
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,809
add
def add(ctxt, id, str, fuzzy): "Add a non-fuzzy translation to the dictionary." global MESSAGES if not fuzzy and str: if ctxt is None: MESSAGES[id] = str else: MESSAGES[b"%b\x04%b" % (ctxt, id)] = str
python
Tools/i18n/msgfmt.py
48
55
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,810
generate
def generate(): "Return the generated output." global MESSAGES # the keys are sorted in the .mo file keys = sorted(MESSAGES.keys()) offsets = [] ids = strs = b'' for id in keys: # For each string, we need size and file offset. Each string is NUL # terminated; the NUL does no...
python
Tools/i18n/msgfmt.py
58
96
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,811
make
def make(filename, outfile): ID = 1 STR = 2 CTXT = 3 # Compute .mo name from .po name and arguments if filename.endswith('.po'): infile = filename else: infile = filename + '.po' if outfile is None: outfile = os.path.splitext(infile)[0] + '.mo' try: with...
python
Tools/i18n/msgfmt.py
99
215
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,812
main
def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'hVo:', ['help', 'version', 'output-file=']) except getopt.error as msg: usage(1, msg) outfile = None # parse options for opt, arg in opts: if opt in ('-h', '--help'): us...
python
Tools/i18n/msgfmt.py
218
242
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,813
parse
def parse(filename): with open(filename, encoding='latin1') as f: lines = list(f) # Remove mojibake in /usr/share/X11/locale/locale.alias. # b'\xef\xbf\xbd' == '\ufffd'.encode('utf-8') lines = [line for line in lines if '\xef\xbf\xbd' not in line] data = {} for line in lines: li...
python
Tools/i18n/makelocalealias.py
18
54
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,814
parse_glibc_supported
def parse_glibc_supported(filename): with open(filename, encoding='latin1') as f: lines = list(f) data = {} for line in lines: line = line.strip() if not line: continue if line[:1] == '#': continue line = line.replace('/', ' ').strip() ...
python
Tools/i18n/makelocalealias.py
56
87
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,815
pprint
def pprint(data): items = sorted(data.items()) for k, v in items: print(' %-40s%a,' % ('%a:' % k, v))
python
Tools/i18n/makelocalealias.py
89
92
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,816
print_differences
def print_differences(data, olddata): items = sorted(olddata.items()) for k, v in items: if k not in data: print('# removed %a' % k) elif olddata[k] != data[k]: print('# updated %a -> %a to %a' % \ (k, olddata[k], data[k])) # Additions are ...
python
Tools/i18n/makelocalealias.py
94
102
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,817
optimize
def optimize(data): locale_alias = locale.locale_alias locale.locale_alias = data.copy() for k, v in data.items(): del locale.locale_alias[k] if locale.normalize(k) != v: locale.locale_alias[k] = v newdata = locale.locale_alias errors = check(data) locale.locale_alias...
python
Tools/i18n/makelocalealias.py
104
116
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,818
check
def check(data): # Check that all alias definitions from the X11 file # are actually mapped to the correct alias locales. errors = 0 for k, v in data.items(): if locale.normalize(k) != v: print('ERROR: %a -> %a != %a' % (k, locale.normalize(k), v), file=sys.stderr) ...
python
Tools/i18n/makelocalealias.py
118
127
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,819
eval_ast_expr
def eval_ast_expr( node: ast.expr, *, filename: str = '-' ) -> Any: """ Takes an ast.Expr node. Compiles it into a function object, then calls the function object with 0 arguments. Returns the result of that function call. globals represents the globals dict the expression should s...
python
Tools/clinic/libclinic/dsl_parser.py
148
169
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,820
__init__
def __init__(self) -> None: self.indents: list[int] = [] self.margin: str | None = None
python
Tools/clinic/libclinic/dsl_parser.py
173
175
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,821
_ensure
def _ensure(self) -> None: if not self.indents: fail('IndentStack expected indents, but none are defined.')
python
Tools/clinic/libclinic/dsl_parser.py
177
179
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,822
measure
def measure(self, line: str) -> int: """ Returns the length of the line's margin. """ if '\t' in line: fail('Tab characters are illegal in the Argument Clinic DSL.') stripped = line.lstrip() if not len(stripped): # we can't tell anything from an em...
python
Tools/clinic/libclinic/dsl_parser.py
181
193
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,823
infer
def infer(self, line: str) -> int: """ Infer what is now the current margin based on this line. Returns: 1 if we have indented (or this is the first margin) 0 if the margin has not changed -N if we have dedented N times """ indent = self.measure...
python
Tools/clinic/libclinic/dsl_parser.py
195
225
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,824
depth
def depth(self) -> int: """ Returns how many margins are currently defined. """ return len(self.indents)
python
Tools/clinic/libclinic/dsl_parser.py
228
232
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,825
dedent
def dedent(self, line: str) -> str: """ Dedents a line by the currently defined margin. """ assert self.margin is not None, "Cannot call .dedent() before calling .infer()" margin = self.margin indent = self.indents[-1] if not line.startswith(margin): f...
python
Tools/clinic/libclinic/dsl_parser.py
234
243
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,826
__init__
def __init__(self, clinic: Clinic) -> None: self.clinic = clinic self.directives = {} for name in dir(self): # functions that start with directive_ are added to directives _, s, key = name.partition("directive_") if s: self.directives[key] = g...
python
Tools/clinic/libclinic/dsl_parser.py
265
280
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,827
reset
def reset(self) -> None: self.function = None self.state = self.state_dsl_start self.keyword_only = False self.positional_only = False self.deprecated_positional = None self.deprecated_keyword = None self.group = 0 self.parameter_state: ParamState = ParamS...
python
Tools/clinic/libclinic/dsl_parser.py
282
298
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,828
directive_module
def directive_module(self, name: str) -> None: fields = name.split('.')[:-1] module, cls = self.clinic._module_and_class(fields) if cls: fail("Can't nest a module inside a class!") if name in module.modules: fail(f"Already defined module {name!r}!") m = ...
python
Tools/clinic/libclinic/dsl_parser.py
300
311
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,829
directive_class
def directive_class( self, name: str, typedef: str, type_object: str ) -> None: fields = name.split('.') name = fields.pop() module, cls = self.clinic._module_and_class(fields) parent = cls or module if name in parent.classes: fail...
python
Tools/clinic/libclinic/dsl_parser.py
313
329
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,830
directive_set
def directive_set(self, name: str, value: str) -> None: if name not in ("line_prefix", "line_suffix"): fail(f"unknown variable {name!r}") value = value.format_map({ 'block comment start': '/*', 'block comment end': '*/', }) self.clinic.__dict__[n...
python
Tools/clinic/libclinic/dsl_parser.py
331
340
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,831
directive_destination
def directive_destination( self, name: str, command: str, *args: str ) -> None: match command: case "new": self.clinic.add_destination(name, *args) case "clear": self.clinic.get_destination(name).clear() case...
python
Tools/clinic/libclinic/dsl_parser.py
342
354
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,832
directive_output
def directive_output( self, command_or_name: str, destination: str = '' ) -> None: fd = self.clinic.destination_buffers if command_or_name == "preset": preset = self.clinic.presets.get(destination) if not preset: fail(f"Unknown preset ...
python
Tools/clinic/libclinic/dsl_parser.py
357
401
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,833
directive_dump
def directive_dump(self, name: str) -> None: self.block.output.append(self.clinic.get_destination(name).dump())
python
Tools/clinic/libclinic/dsl_parser.py
403
404
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,834
directive_printout
def directive_printout(self, *args: str) -> None: self.block.output.append(' '.join(args)) self.block.output.append('\n')
python
Tools/clinic/libclinic/dsl_parser.py
406
408
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,835
directive_preserve
def directive_preserve(self) -> None: if self.preserve_output: fail("Can't have 'preserve' twice in one block!") self.preserve_output = True
python
Tools/clinic/libclinic/dsl_parser.py
410
413
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,836
at_classmethod
def at_classmethod(self) -> None: if self.kind is not CALLABLE: fail("Can't set @classmethod, function is not a normal callable") self.kind = CLASS_METHOD
python
Tools/clinic/libclinic/dsl_parser.py
415
418
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,837
at_critical_section
def at_critical_section(self, *args: str) -> None: if len(args) > 2: fail("Up to 2 critical section variables are supported") self.target_critical_section.extend(args) self.critical_section = True
python
Tools/clinic/libclinic/dsl_parser.py
420
424
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,838
at_getter
def at_getter(self) -> None: match self.kind: case FunctionKind.GETTER: fail("Cannot apply @getter twice to the same function!") case FunctionKind.SETTER: fail("Cannot apply both @getter and @setter to the same function!") case _: ...
python
Tools/clinic/libclinic/dsl_parser.py
426
433
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,839
at_setter
def at_setter(self) -> None: match self.kind: case FunctionKind.SETTER: fail("Cannot apply @setter twice to the same function!") case FunctionKind.GETTER: fail("Cannot apply both @getter and @setter to the same function!") case _: ...
python
Tools/clinic/libclinic/dsl_parser.py
435
442
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,840
at_staticmethod
def at_staticmethod(self) -> None: if self.kind is not CALLABLE: fail("Can't set @staticmethod, function is not a normal callable") self.kind = STATIC_METHOD
python
Tools/clinic/libclinic/dsl_parser.py
444
447
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,841
at_coexist
def at_coexist(self) -> None: if self.coexist: fail("Called @coexist twice!") self.coexist = True
python
Tools/clinic/libclinic/dsl_parser.py
449
452
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,842
at_text_signature
def at_text_signature(self, text_signature: str) -> None: if self.forced_text_signature: fail("Called @text_signature twice!") self.forced_text_signature = text_signature
python
Tools/clinic/libclinic/dsl_parser.py
454
457
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,843
parse
def parse(self, block: Block) -> None: self.reset() self.block = block self.saved_output = self.block.output block.output = [] block_start = self.clinic.block_parser.line_number lines = block.input.split('\n') for line_number, line in enumerate(lines, self.clinic....
python
Tools/clinic/libclinic/dsl_parser.py
459
484
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,844
in_docstring
def in_docstring(self) -> bool: """Return true if we are processing a docstring.""" return self.state in { self.state_parameter_docstring, self.state_function_docstring, }
python
Tools/clinic/libclinic/dsl_parser.py
486
491
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,845
valid_line
def valid_line(self, line: str) -> bool: # ignore comment-only lines if line.lstrip().startswith('#'): return False # Ignore empty lines too # (but not in docstring sections!) if not self.in_docstring() and not line.strip(): return False return T...
python
Tools/clinic/libclinic/dsl_parser.py
493
503
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,846
next
def next( self, state: StateKeeper, line: str | None = None ) -> None: self.state = state if line is not None: self.state(line)
python
Tools/clinic/libclinic/dsl_parser.py
505
512
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,847
state_dsl_start
def state_dsl_start(self, line: str) -> None: if not self.valid_line(line): return # is it a directive? fields = shlex.split(line) directive_name = fields[0] directive = self.directives.get(directive_name, None) if directive: try: ...
python
Tools/clinic/libclinic/dsl_parser.py
514
529
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,848
parse_function_names
def parse_function_names(self, line: str) -> FunctionNames: left, as_, right = line.partition(' as ') full_name = left.strip() c_basename = right.strip() if as_ and not c_basename: fail("No C basename provided after 'as' keyword") if not c_basename: fields...
python
Tools/clinic/libclinic/dsl_parser.py
531
548
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,849
normalize_function_kind
def normalize_function_kind(self, fullname: str) -> None: # Fetch the method name and possibly class. fields = fullname.split('.') name = fields.pop() _, cls = self.clinic._module_and_class(fields) # Check special method requirements. if name in unsupported_special_metho...
python
Tools/clinic/libclinic/dsl_parser.py
550
570
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,850
resolve_return_converter
def resolve_return_converter( self, full_name: str, forced_converter: str ) -> CReturnConverter: if forced_converter: if self.kind in {GETTER, SETTER}: fail(f"@{self.kind.name.lower()} method cannot define a return type") if self.kind is METHOD_INIT: ...
python
Tools/clinic/libclinic/dsl_parser.py
572
599
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,851
parse_cloned_function
def parse_cloned_function(self, names: FunctionNames, existing: str) -> None: full_name, c_basename = names fields = [x.strip() for x in existing.split('.')] function_name = fields.pop() module, cls = self.clinic._module_and_class(fields) parent = cls or module for exist...
python
Tools/clinic/libclinic/dsl_parser.py
601
642
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,852
state_modulename_name
def state_modulename_name(self, line: str) -> None: # looking for declaration, which establishes the leftmost column # line should be # modulename.fnname [as c_basename] [-> return annotation] # square brackets denote optional syntax. # # alternatively: # ...
python
Tools/clinic/libclinic/dsl_parser.py
644
699
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,853
add_function
def add_function(self, func: Function) -> None: # Insert a self converter automatically. tp, name = correct_name_for_self(func) if func.cls and tp == "PyObject *": func.self_converter = self_converter(name, name, func, type=func.cls.ty...
python
Tools/clinic/libclinic/dsl_parser.py
701
718
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,854
state_parameters_start
def state_parameters_start(self, line: str) -> None: if not self.valid_line(line): return # if this line is not indented, we have no parameters if not self.indent.infer(line): return self.next(self.state_function_docstring, line) assert self.function is not None...
python
Tools/clinic/libclinic/dsl_parser.py
775
789
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,855
to_required
def to_required(self) -> None: """ Transition to the "required" parameter state. """ if self.parameter_state is not ParamState.REQUIRED: self.parameter_state = ParamState.REQUIRED assert self.function is not None for p in self.function.parameters.value...
python
Tools/clinic/libclinic/dsl_parser.py
792
800
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,856
state_parameter
def state_parameter(self, line: str) -> None: assert isinstance(self.function, Function) if not self.valid_line(line): return if self.parameter_continuation: line = self.parameter_continuation + ' ' + line.lstrip() self.parameter_continuation = '' a...
python
Tools/clinic/libclinic/dsl_parser.py
802
845
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,857
parse_parameter
def parse_parameter(self, line: str) -> None: assert self.function is not None match self.parameter_state: case ParamState.START | ParamState.REQUIRED: self.to_required() case ParamState.LEFT_SQUARE_BEFORE: self.parameter_state = ParamState.GROUP_...
python
Tools/clinic/libclinic/dsl_parser.py
847
1,125
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,858
bad_node
def bad_node(self, node: ast.AST) -> None: self.bad = True
python
Tools/clinic/libclinic/dsl_parser.py
959
960
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,859
parse_converter
def parse_converter( annotation: ast.expr | None ) -> tuple[str, bool, ConverterArgs]: match annotation: case ast.Constant(value=str() as value): return value, True, {} case ast.Name(name): return name, False, {} case ast.Call(func=...
python
Tools/clinic/libclinic/dsl_parser.py
1,128
1,146
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,860
parse_version
def parse_version(self, thenceforth: str) -> VersionTuple: """Parse Python version in `[from ...]` marker.""" assert isinstance(self.function, Function) try: major, minor = thenceforth.split(".") return int(major), int(minor) except ValueError: fail( ...
python
Tools/clinic/libclinic/dsl_parser.py
1,148
1,159
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,861
parse_star
def parse_star(self, function: Function, version: VersionTuple | None) -> None: """Parse keyword-only parameter marker '*'. The 'version' parameter signifies the future version from which the marker will take effect (None means it is already in effect). """ if version is None: ...
python
Tools/clinic/libclinic/dsl_parser.py
1,161
1,184
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,862
parse_opening_square_bracket
def parse_opening_square_bracket(self, function: Function) -> None: """Parse opening parameter group symbol '['.""" match self.parameter_state: case ParamState.START | ParamState.LEFT_SQUARE_BEFORE: self.parameter_state = ParamState.LEFT_SQUARE_BEFORE case ParamSt...
python
Tools/clinic/libclinic/dsl_parser.py
1,186
1,198
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,863
parse_closing_square_bracket
def parse_closing_square_bracket(self, function: Function) -> None: """Parse closing parameter group symbol ']'.""" if not self.group: fail(f"Function {function.name!r} has a ']' without a matching '['.") if not any(p.group == self.group for p in function.parameters.values()): ...
python
Tools/clinic/libclinic/dsl_parser.py
1,200
1,216
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,864
parse_slash
def parse_slash(self, function: Function, version: VersionTuple | None) -> None: """Parse positional-only parameter marker '/'. The 'version' parameter signifies the future version from which the marker will take effect (None means it is already in effect). """ if version is Non...
python
Tools/clinic/libclinic/dsl_parser.py
1,218
1,273
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,865
state_parameter_docstring_start
def state_parameter_docstring_start(self, line: str) -> None: assert self.indent.margin is not None, "self.margin.infer() has not yet been called to set the margin" self.parameter_docstring_indent = len(self.indent.margin) assert self.indent.depth == 3 return self.next(self.state_paramet...
python
Tools/clinic/libclinic/dsl_parser.py
1,275
1,279
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,866
docstring_append
def docstring_append(self, obj: Function | Parameter, line: str) -> None: """Add a rstripped line to the current docstring.""" # gh-80282: We filter out non-ASCII characters from the docstring, # since historically, some compilers may balk on non-ASCII input. # If you're using Argument C...
python
Tools/clinic/libclinic/dsl_parser.py
1,281
1,298
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,867
state_parameter_docstring
def state_parameter_docstring(self, line: str) -> None: if not self.valid_line(line): return indent = self.indent.measure(line) if indent < self.parameter_docstring_indent: self.indent.infer(line) assert self.indent.depth < 3 if self.indent.depth ...
python
Tools/clinic/libclinic/dsl_parser.py
1,303
1,319
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,868
state_function_docstring
def state_function_docstring(self, line: str) -> None: assert self.function is not None if self.group: fail(f"Function {self.function.name!r} has a ']' without a matching '['.") if not self.valid_line(line): return self.docstring_append(self.function, line)
python
Tools/clinic/libclinic/dsl_parser.py
1,322
1,331
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,869
format_docstring_signature
def format_docstring_signature( f: Function, parameters: list[Parameter] ) -> str: lines = [] lines.append(f.displayname) if f.forced_text_signature: lines.append(f.forced_text_signature) elif f.kind in {GETTER, SETTER}: # @getter and @setter do not ne...
python
Tools/clinic/libclinic/dsl_parser.py
1,334
1,500
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,870
fix_right_bracket_count
def fix_right_bracket_count(desired: int) -> str: nonlocal right_bracket_count s = '' while right_bracket_count < desired: s += '[' right_bracket_count += 1 while right_bracket_count > desired: s ...
python
Tools/clinic/libclinic/dsl_parser.py
1,367
1,376
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,871
add_parameter
def add_parameter(text: str) -> None: nonlocal line_length nonlocal first_parameter if first_parameter: s = text first_parameter = False else: s = ' ' + text if line_length + l...
python
Tools/clinic/libclinic/dsl_parser.py
1,401
1,414
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,872
format_docstring_parameters
def format_docstring_parameters(params: list[Parameter]) -> str: """Create substitution text for {parameters}""" return "".join(p.render_docstring() + "\n" for p in params if p.docstring)
python
Tools/clinic/libclinic/dsl_parser.py
1,503
1,505
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,873
format_docstring
def format_docstring(self) -> str: assert self.function is not None f = self.function # For the following special cases, it does not make sense to render a docstring. if f.kind in {METHOD_INIT, METHOD_NEW, GETTER, SETTER} and not f.docstring: return f.docstring # Enf...
python
Tools/clinic/libclinic/dsl_parser.py
1,507
1,554
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,874
check_remaining_star
def check_remaining_star(self, lineno: int | None = None) -> None: assert isinstance(self.function, Function) if self.keyword_only: symbol = '*' elif self.deprecated_positional: symbol = '* [from ...]' else: return for p in reversed(self.func...
python
Tools/clinic/libclinic/dsl_parser.py
1,556
1,576
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,875
check_previous_star
def check_previous_star(self, lineno: int | None = None) -> None: assert isinstance(self.function, Function) for p in self.function.parameters.values(): if p.kind == inspect.Parameter.VAR_POSITIONAL: fail(f"Function {self.function.name!r} uses '*' more than once.")
python
Tools/clinic/libclinic/dsl_parser.py
1,578
1,583
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,876
do_post_block_processing_cleanup
def do_post_block_processing_cleanup(self, lineno: int) -> None: """ Called when processing the block is done. """ if not self.function: return self.check_remaining_star(lineno) try: self.function.docstring = self.format_docstring() except...
python
Tools/clinic/libclinic/dsl_parser.py
1,586
1,599
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,877
is_legal_py_identifier
def is_legal_py_identifier(identifier: str) -> bool: return all(is_legal_c_identifier(field) for field in identifier.split("."))
python
Tools/clinic/libclinic/identifiers.py
8
9
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,878
ensure_legal_c_identifier
def ensure_legal_c_identifier(identifier: str) -> str: # For now, just complain if what we're given isn't legal. if not is_legal_c_identifier(identifier): raise ClinicError(f"Illegal C identifier: {identifier}") # But if we picked a C keyword, pick something else. if identifier in _c_keywords: ...
python
Tools/clinic/libclinic/identifiers.py
24
31
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,879
add_c_return_converter
def add_c_return_converter( f: ReturnConverterType, name: str | None = None ) -> ReturnConverterType: if not name: name = f.__name__ if not name.endswith('_return_converter'): return f name = name.removesuffix('_return_converter') return_converters[name] = f retur...
python
Tools/clinic/libclinic/return_converters.py
21
31
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,880
__init__
def __init__( cls: ReturnConverterType, name: str, bases: tuple[type[object], ...], classdict: dict[str, Any] ) -> None: add_c_return_converter(cls)
python
Tools/clinic/libclinic/return_converters.py
35
41
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,881
__init__
def __init__( self, *, py_default: str | None = None, **kwargs: Any ) -> None: self.py_default = py_default try: self.return_converter_init(**kwargs) except TypeError as e: s = ', '.join(name + '=' + repr(value) for name, value in kwarg...
python
Tools/clinic/libclinic/return_converters.py
55
66
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,882
return_converter_init
def return_converter_init(self) -> None: ...
python
Tools/clinic/libclinic/return_converters.py
68
68
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,883
declare
def declare(self, data: CRenderData) -> None: line: list[str] = [] add = line.append add(self.type) if not self.type.endswith('*'): add(' ') add(data.converter_retval + ';') data.declarations.append(''.join(line)) data.return_value = data.converter_ret...
python
Tools/clinic/libclinic/return_converters.py
70
78
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,884
err_occurred_if
def err_occurred_if( self, expr: str, data: CRenderData ) -> None: line = f'if (({expr}) && PyErr_Occurred()) {{\n goto exit;\n}}\n' data.return_conversion.append(line)
python
Tools/clinic/libclinic/return_converters.py
80
86
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,885
err_occurred_if_null_pointer
def err_occurred_if_null_pointer( self, variable: str, data: CRenderData ) -> None: line = f'if ({variable} == NULL) {{\n goto exit;\n}}\n' data.return_conversion.append(line)
python
Tools/clinic/libclinic/return_converters.py
88
94
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,886
render
def render( self, function: Function, data: CRenderData ) -> None: ...
python
Tools/clinic/libclinic/return_converters.py
96
100
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,887
render
def render(self, function: Function, data: CRenderData) -> None: self.declare(data) self.err_occurred_if(f"{data.converter_retval} == -1", data) data.return_conversion.append( f'return_value = PyBool_FromLong((long){data.converter_retval});\n' )
python
Tools/clinic/libclinic/return_converters.py
109
114
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,888
render
def render(self, function: Function, data: CRenderData) -> None: self.declare(data) self.err_occurred_if(f"{data.converter_retval} == {self.unsigned_cast}-1", data) data.return_conversion.append( f'return_value = {self.conversion_fn}({self.cast}{data.converter_retval});\n' )
python
Tools/clinic/libclinic/return_converters.py
123
128
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,889
render
def render(self, function: Function, data: CRenderData) -> None: self.declare(data) self.err_occurred_if(f"{data.converter_retval} == -1.0", data) data.return_conversion.append( f'return_value = PyFloat_FromDouble({self.cast}{data.converter_retval});\n' )
python
Tools/clinic/libclinic/return_converters.py
163
168
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,890
add_c_converter
def add_c_converter( f: CConverterClassT, name: str | None = None ) -> CConverterClassT: if not name: name = f.__name__ if not name.endswith('_converter'): return f name = name.removesuffix('_converter') converters[name] = f return f
python
Tools/clinic/libclinic/converter.py
30
40
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,891
add_default_legacy_c_converter
def add_default_legacy_c_converter(cls: CConverterClassT) -> CConverterClassT: # automatically add converter for default format unit # (but without stomping on the existing one if it's already # set, in case you subclass) if ((cls.format_unit not in ('O&', '')) and (cls.format_unit not in legacy...
python
Tools/clinic/libclinic/converter.py
43
50
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,892
__init__
def __init__( cls, name: str, bases: tuple[type[object], ...], classdict: dict[str, Any] ) -> None: converter_cls = cast(type["CConverter"], cls) add_c_converter(converter_cls) add_default_legacy_c_converter(converter_cls)
python
Tools/clinic/libclinic/converter.py
54
59
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,893
__init__
def __init__(self, # Positional args: name: str, py_name: str, function: Function, default: object = unspecified, *, # Keyword only args: c_default: str | None = None, py_default: str | None = None, ann...
python
Tools/clinic/libclinic/converter.py
167
213
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,894
__getattr__
def __getattr__(self, attr): if attr == "function": fail( f"{self.__class__.__name__!r} object has no attribute 'function'.\n" f"Note: accessing self.function inside converter_init is disallowed!" ) return super().__getattr_...
python
Tools/clinic/libclinic/converter.py
222
228
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,895
converter_init
def converter_init(self) -> None: pass
python
Tools/clinic/libclinic/converter.py
233
234
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,896
is_optional
def is_optional(self) -> bool: return (self.default is not unspecified)
python
Tools/clinic/libclinic/converter.py
236
237
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,897
_render_self
def _render_self(self, parameter: Parameter, data: CRenderData) -> None: self.parameter = parameter name = self.parser_name # impl_arguments s = ("&" if self.impl_by_reference else "") + name data.impl_arguments.append(s) if self.length: data.impl_arguments.a...
python
Tools/clinic/libclinic/converter.py
239
252
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,898
_render_non_self
def _render_non_self( self, parameter: Parameter, data: CRenderData ) -> None: self.parameter = parameter name = self.name # declarations d = self.declaration(in_parser=True) data.declarations.append(d) # initializers init...
python
Tools/clinic/libclinic/converter.py
254
301
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,899
render
def render(self, parameter: Parameter, data: CRenderData) -> None: """ parameter is a clinic.Parameter instance. data is a CRenderData instance. """ self._render_self(parameter, data) self._render_non_self(parameter, data)
python
Tools/clinic/libclinic/converter.py
303
309
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
9,900
length_name
def length_name(self) -> str: """Computes the name of the associated "length" variable.""" assert self.length is not None return self.parser_name + "_length"
python
Tools/clinic/libclinic/converter.py
312
315
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }