Skip to content

R35-T046: Simplify one responsibility in rename_files (File_Renamer.py) - #87

Open
challengerthe026-maker wants to merge 1 commit into
S-AI-Projects:mainfrom
challengerthe026-maker:student/e26b07f0577/R35-T046
Open

challengerthe026-maker wants to merge 1 commit into
S-AI-Projects:mainfrom
challengerthe026-maker:student/e26b07f0577/R35-T046

Conversation

@challengerthe026-maker

Copy link
Copy Markdown

Description

This PR refactors rename_files in FileRenamer/File_Renamer.py by extracting target filename formatting into a dedicated helper function compute_renamed_filename, separating string computation from filesystem side effects while strictly preserving public behavior.

Related Issue

Fixes: #46

Type of Change

  • Bug Fix
  • New Feature
  • UI/UX Improvement
  • Performance Improvement
  • Tests
  • Documentation
  • Refactoring / Maintenance
  • CI/CD

Changes Made

  • Extracted target filename calculation and extension parsing into pure helper compute_renamed_filename(filename, new_name, counter).
  • Maintained exact rename_files(directory, pattern, new_name) signature, parameter order, iteration semantics, and os.rename operations.
  • Guarded interactive input() calls under if __name__ == '__main__': for headless import safety.
  • Added regression and unit tests in FileRenamer/test_file_renamer.py covering smallest valid input (1 matching file), ordinary valid input (multiple files with mixed matches), non-matching files, and extracted helper formatting.
  • Implemented work/R35-T046/check.py and work/R35-T046/evidence.md with complete verification logs and automated pass/fail checks.

Screenshots / Recordings

There are no UI changes.

Testing

  1. python3 work/R35-T046/check.py: PASS (all assertion groups passed, ran 4 unittest cases).
  2. FORCE_WRONG=1 python3 work/R35-T046/check.py: FAIL (correctly caught deliberate mismatch and exited with code 1).
  3. python3 -m unittest discover -s "FileRenamer" -p "test_*.py": PASS (Ran 4 tests, OK).

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes

Work evidence and standalone check runner are located under work/R35-T046/.

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

Labels

None yet

1 participant