qBFj pddlZddlZddlmZmZmZejdejZGddZ dS)N)DictListTuple^c*eZdZdZdZdZdZdZdS) LineNumbersaJ Class to convert between character offsets in a text string, and pairs (line, column) of 1-based line and 0-based column numbers, as used by tokens and AST nodes. This class expects unicode for input and stores positions in unicode. But it supports translating to and from utf8 offsets, which are used by ast parsing. cdt|D|_||_t ||_i|_dS)Nc8g|]}|dS)r)start).0ms DC:\PYTHON\_runtimes\venv\Lib\site-packages\asttokens/line_numbers.py z(LineNumbers.__init__.. s"LLL!''!**LLL)_line_start_refinditer _line_offsets_textlen _text_len_utf8_offset_cache)selftexts r__init__zLineNumbers.__init__sKMLn.E.Ed.K.KLLLDDJYYDN Drc |j|}||t|jkr |j|n|j}|j|j|dz |}dt |D}|t|||j|<|tdtt|dz |S)z` Given a 1-based line number and 0-based utf8 column, returns a 0-based unicode column. NcHg|]\}}|dD]}| S)utf8)encode)r icbytes rrz-LineNumbers.from_utf8_col../s5PPPsqqxx?O?OPPtPPPPrr) rgetrrrr enumerateappendmaxmin)rline utf8_columnoffsets end_offset line_texts r from_utf8_colzLineNumbers.from_utf8_col%s %))$//G/3c$:L6M6M/M/M4%d++SWSaj*T/q9JFGiPPi 22PPPg nnS^^$$$&-dd# 3q#c'll1nk::;; <r@s $$$$$$$$$$D"$''5E5E5E5E5E5E5E5E5E5Er