Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
bump 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonleao committed Mar 19, 2020
1 parent 7a419c4 commit 918c956
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pyshorteners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pkgutil

logger = logging.getLogger(__name__)
__version__ = '1.0.0'
__author__ = 'Ellison Leão'
__email__ = 'ellisonleao@gmail.com'
__license__ = 'GPLv3'
__version__ = "1.0.1"
__author__ = "Ellison Leão"
__email__ = "ellisonleao@gmail.com"
__license__ = "GPLv3"


class Shortener(object):
Expand All @@ -26,21 +26,22 @@ class Shortener(object):
def __init__(self, **kwargs):
self.kwargs = kwargs
# validate some required fields
self.kwargs['debug'] = bool(kwargs.pop('debug', False))
self.kwargs['timeout'] = int(kwargs.pop('timeout', 2))
self.kwargs['verify'] = bool(kwargs.pop('verify', True))
module = importlib.import_module('pyshorteners.shorteners')
self.available_shorteners = [i.name for i in
pkgutil.iter_modules(module.__path__)]
self.kwargs["debug"] = bool(kwargs.pop("debug", False))
self.kwargs["timeout"] = int(kwargs.pop("timeout", 2))
self.kwargs["verify"] = bool(kwargs.pop("verify", True))
module = importlib.import_module("pyshorteners.shorteners")
self.available_shorteners = [
i.name for i in pkgutil.iter_modules(module.__path__)
]

def __getattr__(self, attr):
if attr not in self.available_shorteners:
return self.__getattribute__(attr)

# get instance of shortener class
short_module = importlib.import_module(
'{}.{}'.format('pyshorteners.shorteners', attr)
"{}.{}".format("pyshorteners.shorteners", attr)
)
instance = getattr(short_module, 'Shortener')(**self.kwargs)
instance = getattr(short_module, "Shortener")(**self.kwargs)

return instance

0 comments on commit 918c956

Please sign in to comment.