Skip to content

Commit

Permalink
fixed issue with Python 3.x ignoring 2.x style metaclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
terencehonles committed May 15, 2011
1 parent d24f999 commit 5e261da
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions progressbar/widgets.py
Expand Up @@ -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
Expand All @@ -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__ = ()
Expand Down

0 comments on commit 5e261da

Please sign in to comment.