Skip to content

Refactor File Path Handling: Replace os.path with pathlib.Path#2812

Merged
kerizane merged 1 commit intoTuxemon:developmentfrom
JaskRendix:path
May 29, 2025
Merged

Refactor File Path Handling: Replace os.path with pathlib.Path#2812
kerizane merged 1 commit intoTuxemon:developmentfrom
JaskRendix:path

Conversation

@JaskRendix
Copy link
Copy Markdown
Collaborator

@JaskRendix JaskRendix commented May 24, 2025

PR refactors multiple files by replacing os.path functions such as os.path.join, os.path.basename, and os.path.exists, etc. with pathlib.Path.

Key changes:

  • replaced os.path.join() with Path() / "filename"
  • used .name instead of os.path.basename() for cleaner path extraction
  • switched from os.path.exists() to Path.exists() for improved clarity
  • updated os.remove() calls to Path.unlink() for better deletion handling
  • refactored loops using Path.iterdir() instead of os.listdir()

this is going to fix #1229 (probably), because:

  • LIBDIR.parent / "mods" correctly moves up one level from lib/tuxemon to the parent directory (exe.win-amd64-3.12), then joins "mods" to it
  • ensures that mods is a sibling of lib, not mistakenly placed inside it
  • using pathlib ensures compatibility across different OS without requiring os.path.join or normalization

@JaskRendix JaskRendix force-pushed the path branch 5 times, most recently from e087195 to 7774e7b Compare May 24, 2025 12:08
@JaskRendix JaskRendix marked this pull request as ready for review May 24, 2025 12:17
@JaskRendix JaskRendix force-pushed the path branch 9 times, most recently from 95ee43e to 42f5e5c Compare May 25, 2025 09:07
@kerizane kerizane merged commit 5d9cb16 into Tuxemon:development May 29, 2025
10 checks passed
@JaskRendix JaskRendix deleted the path branch May 29, 2025 08:34
la-xirsoi added a commit that referenced this pull request Jun 20, 2025
Enhancing Path Consistency in PR #2812
Rhys-T added a commit to Rhys-T/nur-packages that referenced this pull request Jul 3, 2025
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

Successfully merging this pull request may close these issues.

Failed to start on windows: OSError: cannot load file I18n

2 participants