Category talk:Manuals: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
No edit summary
(removed nonsense code and added a suggestion)
Line 1: Line 1:
<pre>
== Are manuals actually necessary for this wiki? ==
#!/usr/bin/env python3
While the idea of manuals in this wiki is reasonable, I fail to see the point of having them here. In my opinnion, these manual pages are useless. I do not think anyone will read them from here, and certanly not in this form where all the pages are scattered as their own files. I suggest that we will remove the files. Any counter arguments? –[[User:Kapteeni Ruoska|Kapteeni Ruoska]] ([[User talk:Kapteeni Ruoska|talk]]) 10:24, 5 November 2017 (CET)
 
import sys
import re
import pathlib
 
path_to_files = '/projects/manuals'
 
def main():
    fix_pages('Restoration of Erathia', 'RoE', 144)
    fix_pages("Armageddon's Blade", 'AB', 28)
    fix_pages('Shadow of Death', 'SoD', 36)
    fix_pages('Tutorial', 'Tutorial', 12)
 
def fix_pages(name, short_name, total_pages):
    folder = f'{path_to_files}/{short_name}'
    path = pathlib.PurePath(f'{folder}/_{short_name}.txt')
    file = open(path, encoding='utf-8')
    text = file.read()
    pages = re.split('\n\n\n\d\d?\d?\d?\n\n\n', text)
    page_count = len(pages) - 1
    if page_count != total_pages:
        print(f'{name} has the wrong number of pages!')
        print(f'Expected: {total_pages}')
        print(f'Actual: {page_count}')
        sys.exit()
    page_number = 1
    for page in pages:
        padding = ''
        if page_number < 10:
            padding = padding + '0'
        if page_number < 100:
            padding = padding + '0'
        page_name = f'{short_name}_{padding}{page_number}.txt'
        if page_number == 1:
            previous_page = 'TOC'
        else:
            previous_page = 'Page ' + str(page_number - 1) + '|Previous Page'
        if page_number == len(pages) - 1:
            next_page = 'TOC'
        else:
            next_page = 'Page ' + str(page_number + 1) + '|Next Page'
        page_path = pathlib.PurePath(f'{folder}/{page_name}')
        text = f'[[{name} Manual {previous_page}]]\n\n[[{name} Manual {next_page}]]\n\n\n[[File:{short_name}1_{page_number}.png|768px]]\n\n\n'
        category = f'\n\n\n[[Category:{name} Manual|{name} Manual {padding}{page_number}]]'
        page_file = open(page_path, 'w', encoding='utf-8')
        page_file.write(text + page + category)
        page_number = page_number + 1
        if page_number > page_count:
            break
 
if __name__ == "__main__":
    main()
 
# Project Structure
# /projects/manuals/AB/_AB.txt
# /projects/manuals/AB/AB_001.txt
# ...
# /projects/manuals/AB/AB_028.txt
# /projects/manuals/RoE/_RoE.txt
# /projects/manuals/RoE/RoE_001.txt
# ...
# /projects/manuals/RoE/RoE_144.txt
# /projects/manuals/SoD/_SoD.txt
# /projects/manuals/SoD/SoD_001.txt
# ...
# /projects/manuals/SoD/SoD_036.txt
# /projects/manuals/Tutorial/_Tutorial.txt
# /projects/manuals/Tutorial/Tutorial_001.txt
# ...
# /projects/manuals/Tutorial/Tutorial_012.txt
</pre>

Revision as of 09:24, 5 November 2017

Are manuals actually necessary for this wiki?

While the idea of manuals in this wiki is reasonable, I fail to see the point of having them here. In my opinnion, these manual pages are useless. I do not think anyone will read them from here, and certanly not in this form where all the pages are scattered as their own files. I suggest that we will remove the files. Any counter arguments? –Kapteeni Ruoska (talk) 10:24, 5 November 2017 (CET)