Skip to content

Commit

Permalink
Fix 3.12 FileFinder no find_module error
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiShi1313 committed Mar 17, 2024
1 parent 49c5f60 commit 7f9ba15
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# 如何安装差速器

> 可以移步我的[博客](https://lg.to/dft)查看详细的教程
> 可以移步我的[博客](https://2cn.io/dft)查看详细的教程
> 也可以到[Telegram群组](https://t.me/ptdft)来讨论各种问题
## Linux
Expand Down
2 changes: 1 addition & 1 deletion differential/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"create_folder",
)

URL_SHORTENER_PATH = "https://lg.to"
URL_SHORTENER_PATH = "https://2cn.io"


class ImageHosting(Enum):
Expand Down
6 changes: 3 additions & 3 deletions differential/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def __getattr__(self, item):

__all__ = []
for loader, name, is_pkg in pkgutil.walk_packages(__path__):
m = loader.find_module(name)
if not m:
spec = loader.find_spec(name)
if not spec:
continue
module = m.load_module(name)
module = spec.loader.load_module()
for name, value in inspect.getmembers(module):
if name.startswith('__'):
continue
Expand Down
29 changes: 9 additions & 20 deletions differential/utils/image/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
from pathlib import Path
from itertools import chain


class ImageUploaded:
def __init__(self, url, thumb=None):
self.url = url
self.thumb = thumb
from differential.utils.image.types import ImageUploaded
from differential.utils.image.byr import byr_upload
from differential.utils.image.hdbits import hdbits_upload
from differential.utils.image.imgbox import imgbox_upload
from differential.utils.image.smms import smms_upload
from differential.utils.image.ptpimg import ptpimg_upload
from differential.utils.image.imgurl import imgurl_upload
from differential.utils.image.chevereto import chevereto_api_upload, chevereto_cookie_upload, chevereto_username_upload
from differential.utils.image.cloudinary import cloudinary_upload

def __str__(self):
if self.thumb:
return f"[url={self.url}][img]{self.thumb}[/img][/url]"
return f"[img]{self.url}[/img]"


def get_all_images(folder: str) -> list:
image_types = ("png", "jpg", "jpeg", "gif", "webp")
for t in image_types:
for i in Path(folder).glob("*.{}".format(t)):
yield i

from differential.utils.image.byr import byr_upload
from differential.utils.image.hdbits import hdbits_upload
from differential.utils.image.imgbox import imgbox_upload
from differential.utils.image.smms import smms_upload
from differential.utils.image.ptpimg import ptpimg_upload
from differential.utils.image.imgurl import imgurl_upload
from differential.utils.image.chevereto import chevereto_api_upload, chevereto_cookie_upload, chevereto_username_upload
from differential.utils.image.cloudinary import cloudinary_upload
2 changes: 1 addition & 1 deletion differential/utils/image/byr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests
from loguru import logger

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded


def byr_upload(img: Path, authorization: str, url: Optional[str] = None) -> Optional[ImageUploaded]:
Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/chevereto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
from loguru import logger

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded

sessions = {}

Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/cloudinary.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests
from loguru import logger

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded


def cloudinary_upload(img: Path, folder: str, cloud_name: str, api_key: str, api_secret: str) -> Optional[ImageUploaded]:
Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/hdbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from loguru import logger
from lxml.html import fromstring

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded


def get_uploadid(cookie: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/imgbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from loguru import logger
from lxml.html import fromstring

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded


def get_csrf_token(session) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/imgurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests
from loguru import logger

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded

def imgurl_upload(img: Path, url: str, api_key: str) -> Optional[ImageUploaded]:
data = {'token': api_key}
Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/ptpimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests
from loguru import logger

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded

def ptpimg_upload(img: Path, api_key: str) -> Optional[ImageUploaded]:
data = {'api_key': api_key}
Expand Down
2 changes: 1 addition & 1 deletion differential/utils/image/smms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests
from loguru import logger

from differential.utils.image import ImageUploaded
from differential.utils.image.types import ImageUploaded


def smms_upload(img: Path, api_key: str) -> Optional[ImageUploaded]:
Expand Down
11 changes: 11 additions & 0 deletions differential/utils/image/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


class ImageUploaded:
def __init__(self, url, thumb=None):
self.url = url
self.thumb = thumb

def __str__(self):
if self.thumb:
return f"[url={self.url}][img]{self.thumb}[/img][/url]"
return f"[img]{self.url}[/img]"

0 comments on commit 7f9ba15

Please sign in to comment.