]> git.lizzy.rs Git - nhentai.git/blob - nhentai/utils.py
urlparse for python3(再犯错我直播吃屎)
[nhentai.git] / nhentai / utils.py
1 # coding: utf-8
2
3 class _Singleton(type):
4     """ A metaclass that creates a Singleton base class when called. """
5     _instances = {}
6
7     def __call__(cls, *args, **kwargs):
8         if cls not in cls._instances:
9             cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
10         return cls._instances[cls]
11
12
13 class Singleton(_Singleton('SingletonMeta', (object,), {})):
14     pass
15
16
17 def urlparse(url):
18     try:
19         from urlparse import urlparse
20     except ImportError:
21         from urllib.parse import urlparse
22
23     return urlparse(url)