1
0
Fork 0
mirror of synced 2024-12-22 06:01:07 -05:00

Fix compatibility

This commit fixes usage of the Singleton metaclass so that it is
compatible with both Python 2 and Python 3.
This commit is contained in:
Anish Athalye 2015-01-26 10:36:36 -05:00
parent c638e25941
commit 69502854aa
2 changed files with 7 additions and 3 deletions

View file

@ -1,11 +1,10 @@
import sys
from ..util.singleton import Singleton
from ..util.compat import with_metaclass
from .color import Color
from .level import Level
class Messenger(object):
__metaclass__ = Singleton
class Messenger(with_metaclass(Singleton, object)):
def __init__(self, level = Level.LOWINFO):
self.set_level(level)

5
dotbot/util/compat.py Normal file
View file

@ -0,0 +1,5 @@
def with_metaclass(meta, *bases):
class metaclass(meta):
def __new__(cls, name, this_bases, d):
return meta(name, bases, d)
return type.__new__(metaclass, 'temporary_class', (), {})