User:GalliumBot/scope/scope.py

From Wikipedia, the free encyclopedia
"""
Copyright (c) 2022 theleekycauldron

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"""
import pywikibot as pwb
files_to_publish = open("/data/project/leekbot/source_code_publisher/files_to_publish.txt","r").read().splitlines()
site = pwb.Site("en","wikipedia")
for file in files_to_publish:
    file = file.split(" ")
    wiki_page = pwb.Page(site,file[1])
    source_page = open(file[0],"r").read()
    source_page = "<syntax"+"highlight lang=\"python\">\n" + source_page +"\n</syntax"+"highlight>"
    wiki_page.text = source_page
    wiki_page.save(summary="updates from toolforge")