interface.py 801 Bytes
Newer Older
1 2 3 4
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
"""
5 6 7 8
    Abstract class for graphical interface.
    
    Name: interface.py
    Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
9
"""
10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
import traceback

from abc import ABCMeta, abstractmethod

class Interface(object):
    
    __metaclass__ = ABCMeta
    
    @abstractmethod
    def show(self):
        pass


class InterfaceException(Exception):
    
    DEBUG = True
    
    @staticmethod
    def format_exception(message = None):
        if message is not None:
            return "Unexpected error:\n%s" % message.replace('%', '%%')
        elif InterfaceException.DEBUG == True:
            return "Unexpected error:\n%s" % traceback.format_exc().replace('%', '%%')
        else:
            return "Unexpected error\n"