bidi/algorithm.py
def get_embedding_levels(text, storage, upper_is_rtl=False, debug=False):
    """Get the paragraph base embedding level and direction,
    set the storage to the array of chars"""

    prev_surrogate = False
    base_level = storage['base_level']

    # preset the storage's chars
    for _ch in text:
        if _IS_UCS2 and (_SURROGATE_MIN <= ord(_ch) <= _SURROGATE_MAX):
            prev_surrogate = _ch
            continue
        elif prev_surrogate:
            _ch = prev_surrogate + _ch
            prev_surrogate = False

        if upper_is_rtl and _ch.isupper():
            bidi_type = 'R'
        else:
            bidi_type = bidirectional(_ch)

        storage['chars'].append({
            'ch': _ch,
            'level': base_level,
            'type': bidi_type,
            'orig': bidi_type
        })
    if debug:
        debug_storage(storage, base_info=True)
def get_embedding_levels(text, storage, upper_is_rtl=False, debug=False):
    """Get the paragraph base embedding level and direction,
    set the storage to the array of chars"""

    prev_surrogate = False
    base_level = storage['base_level']

    # preset the storage's chars
    for _ch in text:
        if _IS_UCS2 and (_SURROGATE_MIN <= ord(_ch) <= _SURROGATE_MAX):
            prev_surrogate = _ch
            continue
        elif prev_surrogate:
            _ch = prev_surrogate + _ch
            prev_surrogate = False

        if upper_is_rtl and _ch.isupper():
            bidi_type = 'R'
        else:
            bidi_type = bidirectional(_ch)

        storage['chars'].append({
            'ch': _ch,
            'level': base_level,
            'type': bidi_type,
            'orig': bidi_type
        })
    if debug:
        debug_storage(storage, base_info=True)
def get_embedding_levels ( text , storage , upper_is_rtl = False , debug = False ) : prev_surrogate = False base_level = storage [ 'base_level' ] # preset the storage's chars for _ch in text : if _IS_UCS2 and ( _SURROGATE_MIN <= ord ( _ch ) <= _SURROGATE_MAX ) : prev_surrogate = _ch continue elif prev_surrogate : _ch = prev_surrogate + _ch prev_surrogate = False if upper_is_rtl and _ch . isupper ( ) : bidi_type = 'R' else : bidi_type = bidirectional ( _ch ) storage [ 'chars' ] . append ( { 'ch' : _ch , 'level' : base_level , 'type' : bidi_type , 'orig' : bidi_type } ) if debug : debug_storage ( storage , base_info = True )
Get the paragraph base embedding level and direction,
    set the storage to the array of chars
Get the paragraph base embedding level and direction set the storage to the array of chars