Conversation
Centralize API/bot loading and remove inline test code across utilities. Key changes: - pages_bots/page.py: replace LoginWrap usage with a cached ALL_APIS loader (functools.lru_cache), update MainPage/CatDepth/NEW_API to use the main_bot interface, and clean imports. - newapi/super/S_Page/super_page.py: rename local category key variables for clarity (tit -> category_title) and add a create() wrapper delegating to Create(). - newapi/super/bot.py, newapi/super/bot_new.py, newapi/super/mwclient/client.py: standardize log_error formatting to include params/action and adjust logger/import ordering; tidy logins_count placement. - Removed interactive / __main__ demo/test blocks from multiple utility modules to avoid side-effect execution (except_err.py, printe.py, txtlib.py, pformat.py, ar_err.py, catdepth_new.py). - Diagram.md: remove outdated ncc_page link. These changes reduce accidental execution of test code, centralize API instantiation with caching for reuse, and make error logging more informative for debugging.
Delete a set of legacy/duplicated newapi modules and page wrappers: newapi/accounts/user_account_ncc.py, newapi/accounts/user_account_new.py, newapi/mdwiki_page.py, newapi/ncc_page.py, newapi/new_wiki_pages.py, newapi/pages_bots/* (mdwiki_page.py, ncc_page.py, new_wiki_pages.py, toolforge_page.py, wiki_page.py), newapi/pages_bots_backup/mdwiki_page.py, newapi/toolforge_page.py, newapi/tt.py, and newapi/wiki_page.py. This is a cleanup to remove obsolete code and top-level shims; note that any imports or callers referencing these files will need to be updated to use the current implementations or removed to avoid import errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and simplifies the page and account modules in the
newapipackage. The main focus is on unifying and modernizing the implementation of page-related modules by removing duplicate logic, eliminating legacy code, and standardizing how user account information and API access are handled. Several files that previously contained redundant or outdated code have been removed, and the main page modules now use a consistent, cached approach to API initialization.Key changes include:
Major refactoring and code cleanup
Removed legacy or redundant files:
newapi/pages_bots/wiki_page.py,newapi/pages_bots/mdwiki_page.py,newapi/pages_bots/ncc_page.py,newapi/pages_bots/toolforge_page.py,newapi/pages_bots/new_wiki_pages.py, and the corresponding thin wrappersnewapi/mdwiki_page.py,newapi/ncc_page.py,newapi/new_wiki_pages.py. These files either duplicated logic or are now obsolete due to the new unified approach. [1] [2] [3] [4] [5] [6] [7] [8]Refactored
newapi/pages_bots/page.pyto use a single, cached API loader (load_main_api) for all page operations (MainPage,CatDepth,NEW_API), removing the need for manual login management and custom wrappers. [1] [2]User account management simplification
newapi/accounts/user_account_new.pyandnewapi/accounts/user_account_ncc.py, consolidating account management and reducing duplication. [1] [2]Documentation and diagram updates
Diagram.mdto remove references to obsolete modules, reflecting the new, simplified structure.Test and debug code removal
newapi/api_utils/except_err.py,newapi/api_utils/printe.py,newapi/api_utils/txtlib.py) to keep the codebase clean and production-ready. [1] [2] [3]