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

Method directive_output

Tools/clinic/libclinic/dsl_parser.py:365–409  ·  view source on GitHub ↗
(
        self,
        command_or_name: str,
        destination: str = ''
    )

Source from the content-addressed store, hash-verified

363
364
365 def directive_output(
366 self,
367 command_or_name: str,
368 destination: str = ''
369 ) -> None:
370 fd = self.clinic.destination_buffers
371
372 if command_or_name == "preset":
373 preset = self.clinic.presets.get(destination)
374 if not preset:
375 fail(f"Unknown preset {destination!r}!")
376 fd.update(preset)
377 return
378
379 if command_or_name == "push":
380 self.clinic.destination_buffers_stack.append(fd.copy())
381 return
382
383 if command_or_name == "pop":
384 if not self.clinic.destination_buffers_stack:
385 fail("Can't 'output pop', stack is empty!")
386 previous_fd = self.clinic.destination_buffers_stack.pop()
387 fd.update(previous_fd)
388 return
389
390 # secret command for debugging!
391 if command_or_name == "print":
392 self.block.output.append(pprint.pformat(fd))
393 self.block.output.append('\n')
394 return
395
396 d = self.clinic.get_destination_buffer(destination)
397
398 if command_or_name == "everything":
399 for name in list(fd):
400 fd[name] = d
401 return
402
403 if command_or_name not in fd:
404 allowed = ["preset", "push", "pop", "print", "everything"]
405 allowed.extend(fd)
406 fail(f"Invalid command or destination name {command_or_name!r}. "
407 "Must be one of:\n -",
408 "\n - ".join([repr(word) for word in allowed]))
409 fd[command_or_name] = d
410
411 def directive_dump(self, name: str) -> None:
412 self.block.output.append(self.clinic.get_destination(name).dump())

Callers

nothing calls this directly

Calls 11

failFunction · 0.90
listClass · 0.85
pformatMethod · 0.80
getMethod · 0.45
updateMethod · 0.45
appendMethod · 0.45
copyMethod · 0.45
popMethod · 0.45
extendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected