'''
Created on 31-Jan-2021

@author: bthakur
'''
from xv.util import UnicodeShapeHelper


class ArithmeticHelper:
    _DEFAULT_IMAGE_NAME = 'GIRL'
    _DEFAULT_SECTION_TAG = 'div'
    _DEFAULT_ROW_TAG = 'h2'
    _DEFAULT_NUM_TAG = 'span'
    
    def __init__(self):
        self._soup = None
        self._defaultImageName = None
        pass

    @classmethod
    def _getHtmlDisplay(cls, *args):
        try:
            from IPython.display import HTML as htmlDisplay
            return htmlDisplay
        except:
            return None
            pass

    @classmethod
    def _getImageOrDefault(cls, imageName = None):
        if not imageName:
            imageName = ArithmeticHelper._DEFAULT_IMAGE_NAME
            
        shape = UnicodeShapeHelper.searchFirst(search = imageName)
    
        if shape:
            return shape[2]
    
        imageDefault = ArithmeticHelper._DEFAULT_IMAGE_NAME
        shape = UnicodeShapeHelper.searchFirst(search = imageDefault)
        
        if not shape:
            sError = f"Shape not found: '{imageName}' or '{imageDefault}'"
            raise Exception(sError)
        
        return shape[2]
        pass
    
