Created
October 14, 2016 15:52
-
-
Save eirenik0/2cd80389ef48fcf8012ee785c094240b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdapterFabric(type): | |
""" | |
Return adapter object regarding to social network | |
""" | |
instances = 0 | |
def __new__(cls, social, bases=(), dct={}): | |
cls.instances += 1 | |
adapters = [YouTubeSocialAdapter, VKSocialAdapter] | |
for Adapter in adapters: | |
if getattr(Adapter, '__social__') == social: | |
bases += (Adapter,) | |
return type.__new__(cls, social, bases, dct) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment