Skip to content

[Task]: Replace manual filename parsing in tsave() with pathlib-based handling #320

Description

@sepandhaghighi

Describe the feature you want to add

Refactor filename and extension handling in tsave() to make file path processing cleaner, safer, and easier to maintain.

Describe your proposed solution

Import Path from Python's pathlib module and replace the manual string-based filename parsing:

  • Splitting filenames with .
  • Reversing strings to find extensions
    -Manually building filenames and extensions

with Path methods:

  • Path(filename).suffix to detect extensions
  • Path(filename).with_suffix("") to get the filename without extension

Use Path.exists() instead of checking against os.listdir() when determining whether a filename already exists.

This simplifies the code and avoids edge cases with filenames containing multiple dots.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions