Skip to content

Upgrade --save - #57

Merged
JamesMcClung merged 17 commits into
mainfrom
save-upgrade
Aug 12, 2026
Merged

JamesMcClung merged 17 commits into
mainfrom
save-upgrade

Conversation

@JamesMcClung

@JamesMcClung JamesMcClung commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Upgrade --save. It now:

  • Can take an arbitrary string to set dir, name, or format. Format/ext is greedily parsed first (substring after the last .), then the name/stem, then the dir.
  • Can specify individual components more clearly with dir=<dir>, name=<name>, and format=<format>.

Remove --save-format.

Note that this is a breaking change: -s dir (literally "dir") will now create dir.png/dir.mp4 in the current working directory instead of dir/<autogenerated stem>.<ext>. To achieve the previous behavior, append a / to the end of directories, e.g. -s dir/, or use -s dir=dir.

Here's a helpful diagram of behavior:

-s arguments dir stem ext
(none)
out/ out
fig fig
.gif gif
fig.gif fig gif
out/.gif out gif
out/fig.gif out fig gif
. .
./.. ./..
dir=out name=fig format=gif out fig gif
name=fig.i fig.i

Note that the default dir is ., default name is automatically generated, and default format is determined by the plot type.

JamesMcClung and others added 17 commits August 11, 2026 15:36
argparse only converts ArgumentTypeError inside its own type= conversion, so one
raised in an Action escaped as a traceback. Affected every multi-arg adaptor.

Co-Authored-By: Claude <noreply@anthropic.com>
Needed as a public predicate by parse_save, which must detect whether an arg is a
key=value attempt without raising.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
--save now absorbs --save-format as format=, and gains dir=/name= plus a bare
'[dir/][stem][.ext]' fragment. --save-dpi is untouched, pending a --dpi that
would also apply to live figures.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
bash leaves ~ alone after a '=' (dir=~/figs) and inside quotes, so without this
the save dir was a literal '~' directory that mkdir(parents=True) then created.
A dir legitimately named '~foo' stays literal: expanduser() raises RuntimeError
for an unknown user rather than passing it through like os.path.expanduser.

Co-Authored-By: Claude <noreply@anthropic.com>
Matches argparse's own _get_action_name, which joins option_strings in
registration order. The reversal only existed to satisfy a test that pinned
the order; that test now asserts order-agnostically.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Save had grown four test files across two layers. Now one file in three
sections: the parse_save grammar, the derived filename stem, and end-to-end
pipeline saves. No test content changed.

Co-Authored-By: Claude <noreply@anthropic.com>
@JamesMcClung JamesMcClung added the enhancement New feature or request label Aug 12, 2026
@JamesMcClung
JamesMcClung merged commit e190c7c into main Aug 12, 2026
2 checks passed
@JamesMcClung
JamesMcClung deleted the save-upgrade branch August 12, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant