mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 11:01:17 +02:00
26 lines
625 B
Python
26 lines
625 B
Python
# coding: utf-8
|
|
from __future__ import unicode_literals, print_function
|
|
|
|
|
|
class _Singleton(type):
|
|
""" A metaclass that creates a Singleton base class when called. """
|
|
_instances = {}
|
|
|
|
def __call__(cls, *args, **kwargs):
|
|
if cls not in cls._instances:
|
|
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
|
|
return cls._instances[cls]
|
|
|
|
|
|
class Singleton(_Singleton(str('SingletonMeta'), (object,), {})):
|
|
pass
|
|
|
|
|
|
def urlparse(url):
|
|
try:
|
|
from urlparse import urlparse
|
|
except ImportError:
|
|
from urllib.parse import urlparse
|
|
|
|
return urlparse(url)
|