Skip to content

Instantly share code, notes, and snippets.

@eirenik0
Created October 14, 2016 15:52
Show Gist options
  • Save eirenik0/2cd80389ef48fcf8012ee785c094240b to your computer and use it in GitHub Desktop.
Save eirenik0/2cd80389ef48fcf8012ee785c094240b to your computer and use it in GitHub Desktop.
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