Permalink
Browse files

fixed issue with Python 3.x ignoring 2.x style metaclasses

  • Loading branch information...
terencehonles committed May 15, 2011
1 parent 3cdf1e1 commit 101a30a56d2f6bfbda1b310089c498885d5367e1
Showing with 7 additions and 5 deletions.
  1. +7 −5 progressbar/widgets.py
View
@@ -25,18 +25,21 @@
import datetime
import math
-try: from abc import ABCMeta, abstractmethod
+try:
+ from abc import ABCMeta, abstractmethod
except ImportError:
- ABCMeta = None
- abstractmethod = lambda fn: fn
+ AbstractWidget = object
+ abstractmethod = lambda fn: fn
+else:
+ AbstractWidget = ABCMeta('AbstractWidget', (object,), {})
def format_updatable(updatable, pbar):
if hasattr(updatable, 'update'): return updatable.update(pbar)
else: return updatable
-class Widget(object):
+class Widget(AbstractWidget):
'''The base class for all widgets
The ProgressBar will call the widget's update value when the widget should
@@ -46,7 +49,6 @@ class Widget(object):
The boolean TIME_SENSITIVE informs the ProgressBar that it should be
updated more often because it is time sensitive.
'''
- if ABCMeta is not None: __metaclass__ = ABCMeta
TIME_SENSITIVE = False
__slots__ = ()

0 comments on commit 101a30a

Please sign in to comment.