Skip to content
XulbuX edited this page Sep 15, 2025 · 3 revisions

File

This class includes methods to work with files and file paths.


rename_extension()

This method will rename the extension of the given file.
Params:

  • file: str the path to the file
  • new_extension: str the new extension of the file
  • full_extension: bool = False whether to rename the full extension (e.g. .tar.gz) or just the last part (e.g. .gz)
  • camel_case_filename: bool = False whether to additionally make the filename CamelCase

Returns:no return value


create()

This method will create a file with ot without content.
Params:

  • file: str the path for the new file with file extension
  • content: str = "" the content of the created file
  • force: bool = False whether to overwrite the file if it already exists

Returns: the full filepath of the newly created file
Raises:

  • FileExistsError if a file already with the same filename already exists (and force is false)
  • SameContentFileExistsError if a file with the same filename and same content already exists (and force is false)

★⠀Python Library by XulbuX⠀★

Project Links

Testing and Formatting

Classifiers

  • Intended Audience:
    • Developers
  • License:
    • OSI Approved
    • MIT License
  • Operating Systems:
    • Full Library: OS Independent
  • Supported Python Versions:
    • Python 3.13
    • Python 3.12
    • Python 3.11
    • Python 3.10
  • Topics:
    • Libraries
    • Python Modules
    • Software Development

The XulbuX Logo
Clone this wiki locally