ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/ValBot/Python/check_intrawiki_section_links.py
(Generate patch)

Comparing ValBot/Python/check_intrawiki_section_links.py (file contents):
Revision 1185 by iritscen, Tue Aug 15 02:03:16 2023 UTC vs.
Revision 1192 by iritscen, Mon Sep 16 23:08:26 2024 UTC

# Line 35 | Line 35 | chapter_names = ['CHAPTER_00_._COMBAT_TR
35   # Tuple of patterns for recognizing wikilinks
36   # Pattern 1: Detect "[[anything]]", "[[any:thing]]", "[[any|thing]]", "[[any:thi|ng]]"
37   # Pattern 2: Detect "{{SectionLink|Page|Section name}}", "{{SectionLink||Section name}}"
38 < link_patterns = ("\[\[[^|\]]*(\||\])", "\{\{SectionLink\|[^|\}]*\|[^|\}]*\}\}")
38 > link_patterns = (r"\[\[[^|\]]*(\||\])", r"\{\{SectionLink\|[^|\}]*\|[^|\}]*\}\}")
39  
40   # Initialize globals
41   debug = 0
# Line 64 | Line 64 | def find_section(page_text, page_name, p
64     target_page_name_human = target_page_name.replace('_', ' ')
65     if debug: pywikibot.stdout('         Searching for section link {} on page.'.format(anchor_name))
66  
67   # Convert slash character to the dot-notation hex encoding that MediaWiki uses
68   anchor_name = anchor_name.replace('/', '.2F')
69
67     # Read linked page to see if it really has this anchor link
68     soup = BeautifulSoup(page_text, 'html.parser')
69     found_section = False
# Line 86 | Line 83 | def find_section(page_text, page_name, p
83              break
84     if found_section == False:
85        possibly_print(page_name)
86 <      pywikibot.stdout('   ERROR: Could not find section "{0}" on page {1}!'.format(anchor_name, pre_section))
86 >      pywikibot.stdout('   ERROR: Could not find section "{0}" on page {1}!'.format(anchor_name, target_page_name_human))
87        errors_issued += 1
88     elif debug and print_result:
89        pywikibot.stdout('   The section "{0}" was found on page "{1}".'.format(anchor_name, target_page_name_human))

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)