Cleaned the file structure (#111)

This commit is contained in:
Frisk 2020-07-07 13:21:49 +02:00
parent 863917b2f3
commit 0c5048aa04
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
9 changed files with 31 additions and 77 deletions

View file

@ -8,6 +8,6 @@ test:
- sed -i -e "s/111111111111111111/$DISCORD1/g" settings.json.example - sed -i -e "s/111111111111111111/$DISCORD1/g" settings.json.example
- sed -i -e "s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/$DISCORD2/g" settings.json.example - sed -i -e "s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/$DISCORD2/g" settings.json.example
- mv settings.json.example settings.json - mv settings.json.example settings.json
- python3.6 rcgcdw.py --test - python3.6 start.py --test
only: only:
- testing - testing

View file

@ -51,7 +51,7 @@ def yes_no(answer):
print("Welcome in RcGcDw config builder! This script is still work in progress so beware! You can accept the default value if provided in the question by using Enter key without providing any other input.\nWARNING! Your current settings.json will be overwritten if you continue!") print("Welcome in RcGcDw config builder! This script is still work in progress so beware! You can accept the default value if provided in the question by using Enter key without providing any other input.\nWARNING! Your current settings.json will be overwritten if you continue!")
try: # load settings try: # load settings
with open("settings.json.example") as sfile: with open("../settings.json.example") as sfile:
settings = json.load(sfile) settings = json.load(sfile)
except FileNotFoundError: except FileNotFoundError:
if yes_no(default_or_custom(input("Template config (settings.json.example) could not be found. Download the most recent stable one from master branch? (https://gitlab.com/piotrex43/RcGcDw/raw/master/settings.json.example)? (Y/n)"), "y")): if yes_no(default_or_custom(input("Template config (settings.json.example) could not be found. Download the most recent stable one from master branch? (https://gitlab.com/piotrex43/RcGcDw/raw/master/settings.json.example)? (Y/n)"), "y")):

View file

@ -2,61 +2,15 @@ from setuptools import setup
setup( setup(
name='RcGcDw', name='RcGcDw',
version='1.5.2', version='1.12',
packages=['venv.lib.python3.7.site-packages.bs4', 'venv.lib.python3.7.site-packages.bs4.tests', packages=[''],
'venv.lib.python3.7.site-packages.bs4.builder', 'venv.lib.python3.7.site-packages.idna', url='https://gitlab.com/piotrex43/RcGcDw/',
'venv.lib.python3.7.site-packages.lxml', 'venv.lib.python3.7.site-packages.lxml.html', license='GNU GPLv3',
'venv.lib.python3.7.site-packages.lxml.includes', 'venv.lib.python3.7.site-packages.lxml.isoschematron',
'venv.lib.python3.7.site-packages.certifi', 'venv.lib.python3.7.site-packages.chardet',
'venv.lib.python3.7.site-packages.chardet.cli', 'venv.lib.python3.7.site-packages.urllib3',
'venv.lib.python3.7.site-packages.urllib3.util', 'venv.lib.python3.7.site-packages.urllib3.contrib',
'venv.lib.python3.7.site-packages.urllib3.contrib._securetransport',
'venv.lib.python3.7.site-packages.urllib3.packages',
'venv.lib.python3.7.site-packages.urllib3.packages.backports',
'venv.lib.python3.7.site-packages.urllib3.packages.ssl_match_hostname',
'venv.lib.python3.7.site-packages.requests', 'venv.lib.python3.7.site-packages.schedule',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.idna',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.pytoml',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.certifi',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.chardet',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.chardet.cli',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.distlib',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.distlib._backport',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.msgpack',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3.util',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3.contrib',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3.contrib._securetransport',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3.packages',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3.packages.backports',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.urllib3.packages.ssl_match_hostname',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.colorama',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.html5lib',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.html5lib._trie',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.html5lib.filters',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.html5lib.treewalkers',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.html5lib.treeadapters',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.html5lib.treebuilders',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.lockfile',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.progress',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.requests',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.packaging',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.cachecontrol',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.cachecontrol.caches',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.webencodings',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._vendor.pkg_resources',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal.req',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal.vcs',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal.utils',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal.models',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal.commands',
'venv.lib.python3.7.site-packages.pip-10.0.1-py3.7.egg.pip._internal.operations'],
url='https://gitlab.com/piotrex43/RcGcDw',
license='GNU Affero General Public License v3.0',
author='Frisk', author='Frisk',
author_email='piotrex43@protonmail.ch', author_email='piotrex43@protonmail.ch',
description='Brings Special:RecentChanges on the Discord using a webhook!' description='A set od scripts to fetch recent changes from MediaWiki wiki to a Discord channel using a webhook',
keywords=['MediaWiki', 'recent changes', 'Discord', 'webhook'],
package_dir={"": "src"},
install_requires=["beautifulsoup4 >= 4.6.0", "requests >= 2.18.4", "schedule >= 0.5.0", "lxml >= 4.2.1"],
python_requires="3.6"
) )

View file

@ -18,10 +18,10 @@
import logging, gettext, schedule, requests, json, datetime import logging, gettext, schedule, requests, json, datetime
from collections import defaultdict from collections import defaultdict
from configloader import settings from src.configloader import settings
from urllib.parse import quote_plus from urllib.parse import quote_plus
from misc import datafile, send_to_discord, DiscordMessage, WIKI_SCRIPT_PATH, escape_formatting, messagequeue from src.misc import datafile, send_to_discord, DiscordMessage, WIKI_SCRIPT_PATH, escape_formatting, messagequeue
from session import session from src.session import session
# Initialize translation # Initialize translation

View file

@ -21,7 +21,7 @@ from html.parser import HTMLParser
from urllib.parse import urlparse, urlunparse from urllib.parse import urlparse, urlunparse
import requests import requests
from collections import defaultdict from collections import defaultdict
from configloader import settings from src.configloader import settings
import gettext import gettext
# Initialize translation # Initialize translation

View file

@ -23,23 +23,19 @@
import time, logging.config, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys, ipaddress, base64 import time, logging.config, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys, ipaddress, base64
from html.parser import HTMLParser from html.parser import HTMLParser
import misc import src.misc
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from collections import defaultdict, Counter from collections import defaultdict, Counter
from urllib.parse import quote_plus from urllib.parse import quote_plus
from configloader import settings from src.configloader import settings
from misc import link_formatter, ContentParser, safe_read, add_to_dict, datafile, \ from src.misc import link_formatter, ContentParser, safe_read, add_to_dict, datafile, \
WIKI_API_PATH, WIKI_SCRIPT_PATH, WIKI_JUST_DOMAIN, create_article_path, messagequeue, send_to_discord_webhook, \ WIKI_API_PATH, WIKI_SCRIPT_PATH, WIKI_JUST_DOMAIN, create_article_path, messagequeue, send_to_discord_webhook, \
send_to_discord, DiscordMessage, send_simple send_to_discord, DiscordMessage, send_simple
from session import session from src.session import session
if settings["fandom_discussions"]["enabled"]: if settings["fandom_discussions"]["enabled"]:
import discussions import discussions
if __name__ != "__main__": # return if called as a module
logging.critical("The file is being executed as a module. Please execute the script using the console.")
sys.exit(1)
TESTING = True if "--test" in sys.argv else False # debug mode, pipeline testing TESTING = True if "--test" in sys.argv else False # debug mode, pipeline testing
# Prepare logging # Prepare logging
@ -951,19 +947,19 @@ def daily_overview_sync(edits, files, admin, changed_bytes, new_articles, unique
storage["daily_overview"].update({"edits": edits, "new_files": files, "admin_actions": admin, "bytes_changed": changed_bytes, "new_articles": new_articles, "unique_editors": unique_contributors, "day_score": day_score}) storage["daily_overview"].update({"edits": edits, "new_files": files, "admin_actions": admin, "bytes_changed": changed_bytes, "new_articles": new_articles, "unique_editors": unique_contributors, "day_score": day_score})
edits, files, admin, changed_bytes, new_articles, unique_contributors, day_score = str(edits), str(files), str(admin), str(changed_bytes), str(new_articles), str(unique_contributors), str(day_score) edits, files, admin, changed_bytes, new_articles, unique_contributors, day_score = str(edits), str(files), str(admin), str(changed_bytes), str(new_articles), str(unique_contributors), str(day_score)
else: else:
edits_avg = misc.weighted_average(storage["daily_overview"]["edits"], weight, edits) edits_avg = src.misc.weighted_average(storage["daily_overview"]["edits"], weight, edits)
edits = _("{value} (avg. {avg})").format(value=edits, avg=edits_avg) edits = _("{value} (avg. {avg})").format(value=edits, avg=edits_avg)
files_avg = misc.weighted_average(storage["daily_overview"]["new_files"], weight, files) files_avg = src.misc.weighted_average(storage["daily_overview"]["new_files"], weight, files)
files = _("{value} (avg. {avg})").format(value=files, avg=files_avg) files = _("{value} (avg. {avg})").format(value=files, avg=files_avg)
admin_avg = misc.weighted_average(storage["daily_overview"]["admin_actions"], weight, admin) admin_avg = src.misc.weighted_average(storage["daily_overview"]["admin_actions"], weight, admin)
admin = _("{value} (avg. {avg})").format(value=admin, avg=admin_avg) admin = _("{value} (avg. {avg})").format(value=admin, avg=admin_avg)
changed_bytes_avg = misc.weighted_average(storage["daily_overview"]["bytes_changed"], weight, changed_bytes) changed_bytes_avg = src.misc.weighted_average(storage["daily_overview"]["bytes_changed"], weight, changed_bytes)
changed_bytes = _("{value} (avg. {avg})").format(value=changed_bytes, avg=changed_bytes_avg) changed_bytes = _("{value} (avg. {avg})").format(value=changed_bytes, avg=changed_bytes_avg)
new_articles_avg = misc.weighted_average(storage["daily_overview"]["new_articles"], weight, new_articles) new_articles_avg = src.misc.weighted_average(storage["daily_overview"]["new_articles"], weight, new_articles)
new_articles = _("{value} (avg. {avg})").format(value=new_articles, avg=new_articles_avg) new_articles = _("{value} (avg. {avg})").format(value=new_articles, avg=new_articles_avg)
unique_contributors_avg = misc.weighted_average(storage["daily_overview"]["unique_editors"], weight, unique_contributors) unique_contributors_avg = src.misc.weighted_average(storage["daily_overview"]["unique_editors"], weight, unique_contributors)
unique_contributors = _("{value} (avg. {avg})").format(value=unique_contributors, avg=unique_contributors_avg) unique_contributors = _("{value} (avg. {avg})").format(value=unique_contributors, avg=unique_contributors_avg)
day_score_avg = misc.weighted_average(storage["daily_overview"]["day_score"], weight, day_score) day_score_avg = src.misc.weighted_average(storage["daily_overview"]["day_score"], weight, day_score)
day_score = _("{value} (avg. {avg})").format(value=day_score, avg=day_score_avg) day_score = _("{value} (avg. {avg})").format(value=day_score, avg=day_score_avg)
storage["daily_overview"].update({"edits": edits_avg, "new_files": files_avg, "admin_actions": admin_avg, "bytes_changed": changed_bytes_avg, storage["daily_overview"].update({"edits": edits_avg, "new_files": files_avg, "admin_actions": admin_avg, "bytes_changed": changed_bytes_avg,
"new_articles": new_articles_avg, "unique_editors": unique_contributors_avg, "day_score": day_score_avg}) "new_articles": new_articles_avg, "unique_editors": unique_contributors_avg, "day_score": day_score_avg})

View file

@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import requests import requests
from configloader import settings from src.configloader import settings
session = requests.Session() session = requests.Session()
session.headers.update(settings["header"]) session.headers.update(settings["header"])

4
start.py Normal file
View file

@ -0,0 +1,4 @@
import src.rcgcdw, sys
if __name__ != "__main__": # return if called as a module
sys.exit(1)