openmath/helpers.py
def convertAsOpenMath(term, converter):
    """ Converts a term into OpenMath, using either a converter or the interpretAsOpenMath method """
    
    # if we already have openmath, or have some of our magic helpers, use interpretAsOpenMath
    if hasattr(term, "_ishelper") and term._ishelper or isinstance(term, om.OMAny):
        return interpretAsOpenMath(term)
        
    # next try to convert using the converter
    if converter is not None:
        try:
            _converted = converter.to_openmath(term)
        except Exception as e:
            _converted = None
        
        if isinstance(_converted, om.OMAny):
            return _converted
    
    # fallback to the openmath helper
    return interpretAsOpenMath(term)
def convertAsOpenMath(term, converter):
    # if we already have openmath, or have some of our magic helpers, use interpretAsOpenMath
    if hasattr(term, "_ishelper") and term._ishelper or isinstance(term, om.OMAny):
        return interpretAsOpenMath(term)
        
    # next try to convert using the converter
    if converter is not None:
        try:
            _converted = converter.to_openmath(term)
        except Exception as e:
            _converted = None
        
        if isinstance(_converted, om.OMAny):
            return _converted
    
    # fallback to the openmath helper
    return interpretAsOpenMath(term)
def convertAsOpenMath ( term , converter ) : # if we already have openmath, or have some of our magic helpers, use interpretAsOpenMath if hasattr ( term , "_ishelper" ) and term . _ishelper or isinstance ( term , om . OMAny ) : return interpretAsOpenMath ( term ) # next try to convert using the converter if converter is not None : try : _converted = converter . to_openmath ( term ) except Exception as e : _converted = None if isinstance ( _converted , om . OMAny ) : return _converted # fallback to the openmath helper return interpretAsOpenMath ( term )
Converts a term into OpenMath, using either a converter or the interpretAsOpenMath method
Converts a term into OpenMath using either a converter or the interpretAsOpenMath method