1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2026-02-10 00:33:22 +01:00

Make the sites system not require editing __init__.py

This commit is contained in:
David Lynch 2016-09-23 12:51:03 -05:00
parent 86f02812d2
commit 574cea3fc8

View file

@ -1,4 +1,6 @@
import glob
import os
import argparse
from bs4 import BeautifulSoup
@ -101,5 +103,12 @@ def get(url):
if site_class.matches(url):
return site_class
# And now, the things that will use this:
from . import xenforo, fanfictionnet, deviantart, stash, ao3 # noqa
# And now, a particularly hacky take on a plugin system:
# Make an __all__ out of all the python files in this directory that don't start
# with __. Then import * them.
modules = glob.glob(os.path.join(os.path.dirname(__file__), "*.py"))
__all__ = [os.path.basename(f)[:-3] for f in modules if not f.startswith("__")]
from . import * # noqa