Skip to content

Update#5

Merged
MrIbrahem merged 12 commits intomainfrom
update
Feb 17, 2026
Merged

Update#5
MrIbrahem merged 12 commits intomainfrom
update

Conversation

@MrIbrahem
Copy link
Contributor

No description provided.

Moved and refactored bot edit permission logic from botEdit.py into a new 'bot_edit' package with modular files for template and time-based checks. Introduced EditPermissionChecker class in bot_edit/__init__.py for instance-based permission checking. Updated imports and usage in botEdit.py to use the new structure. Also changed logger.info to logger.error for error reporting in several files for better log level semantics.
Replaces txtlib with wikitextparser for extracting templates and parameters in bot_edit_by_templates.py. Updates logic to use wikitextparser's API and improves logging messages for template handling.
Introduces comprehensive unit tests for the is_bot_edit_allowed function, covering bypass conditions, template restrictions (nobots, bots, custom templates), bot job types, caching behavior, parameter combinations, edge cases, and Arabic-specific stop templates. Also refactors imports in bot_edit/__init__.py, txtlib.py, and edit_validator.py for consistency.
Migrated and refactored unit tests for is_bot_edit_allowed to use pytest, added fixtures for environment and template mocking, and split command-line bypass tests into a separate file. Improved coverage for template handling, cache behavior, and edge cases. Deprecated sys.argv-based bypass tests with a skip marker.
Moved template-related bot_edit tests into a dedicated subdirectory for better organization. Added a new test file stub for bot_edit_by_time, preparing for future time-based test implementations.
Cleaned up the data.py file by removing large blocks of commented-out docstrings and unused code related to data class attributes. This improves readability and maintainability without affecting functionality.
Enable optional file logging in setup_logging by adding a log_file parameter. Introduce prepare_log_file to create parent directories (using pathlib.expanduser) and handle errors. When log_file is provided, add a UTF-8 FileHandler for general logs and a separate .err FileHandler that captures WARNING and above. Also refactor console handler naming, preserve colored console formatting, change default logger name to "mw_api", and accept numeric logging levels as well as string names.
Replace fragile warn logs with full exception logging: change logger.warning(e) to logger.exception('Exception:', exc_info=True) across mw_api/super/bot.py and mw_api/super/bot_new.py to capture stack traces. Add an internal showDiff implementation in mw_api/api_utils/ask_bot.py (using difflib and logger) and replace calls to printe.showDiff. Remove obsolete mw_api/tt.py. These changes improve diagnostics and simplify diff handling.
@MrIbrahem MrIbrahem merged commit 1a10891 into main Feb 17, 2026
1 check failed
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.

1 participant