Skip to content

capture_auto #11

@kolibril13

Description

@kolibril13

Automatically detects the format of the output.
Two options here:

  1. the capture output format is determined by the file name ending, e.g.
    %%capture_auto--path "foo.txt" will detect it is txt.
  2. the capture output format is determined by the cell output, e.g.
    %%capture_auto--path "foo" will save the output to foo.mp4 if the output is of type video, or to foo.png if the output type is an image.

Another thought: Option 2 could be extended in the following way: if there are multiple outputs, they can be all saved in respective files, e.g. foo.txt , foo.mp4 and foo.png.

Here is an implementation start point:

    @magic_arguments.magic_arguments()  ################### Auto
    @magic_arguments.argument(
        "--path",
        "-p",
        default=None,
        help=(
            "Auto detect what to capture based on file ending"
        ),
    )
    @cell_magic
    def capture_auto(self, line, cell):
        args = magic_arguments.parse_argstring(CaptureMagic.capture_auto, line)
        path_str = args.path.strip('"')
        p_pathlib = path_preprocessing(path_str)
        if p_pathlib.suffix == ".png":
            pass
        if p_pathlib.suffix == ".mp4":
            pass
        if p_pathlib.suffix == ".txt":
            pass
        if p_pathlib.suffix == ".py":
            pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions