Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capture_auto #11

Open
kolibril13 opened this issue Nov 3, 2022 · 0 comments
Open

capture_auto #11

kolibril13 opened this issue Nov 3, 2022 · 0 comments

Comments

@kolibril13
Copy link
Member

kolibril13 commented Nov 3, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant