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