Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/openpyxl/formula/__pycache__/translate.cpython-37.pyc
Назад
B �5�g � @ sT d Z ddlZddlmZmZ ddlmZmZmZ G dd� de �Z G dd � d e�ZdS ) a! This module contains code to translate formulae across cells in a worksheet. The idea is that if A1 has formula "=B1+C1", then translating it to cell A2 results in formula "=B2+C2". The algorithm relies on the formula tokenizer to identify the parts of the formula that need to change. � N� )� Tokenizer�Token)�coordinate_to_tuple�column_index_from_string�get_column_letterc @ s e Zd ZdZdS )�TranslatorErrora Raised when a formula can't be translated across cells. This error arises when a formula's references would be translated outside the worksheet's bounds on the top or left. Excel represents these situations with a #REF! literal error. E.g., if the formula at B2 is '=A1', attempting to translate the formula to B1 raises TranslatorError, since there's no cell above A1. Similarly, translating the same formula from B2 to A2 raises TranslatorError, since there's no cell to the left of A1. N)�__name__� __module__�__qualname__�__doc__� r r �P/home/digitalm-up/venv/lib/python3.7/site-packages/openpyxl/formula/translate.pyr s r c @ sx e Zd ZdZdd� Zdd� Ze�d�Ze�d�Z e�d�Z ed d � �Zedd� �Z ed d� �Zedd� �Zddd�ZdS )� Translatora5 Modifies a formula so that it can be translated from one cell to another. `formula`: The str string to translate. Must include the leading '=' character. `origin`: The cell address (in A1 notation) where this formula was defined (excluding the worksheet name). c C s t |�\| _| _t|�| _d S )N)r �row�colr � tokenizer)�selfZformula�originr r r �__init__- s zTranslator.__init__c C s | j jS )z6Returns a list with the tokens comprising the formula.)r �items)r r r r � get_tokens4 s zTranslator.get_tokensz*(\$?[1-9][0-9]{0,6}):(\$?[1-9][0-9]{0,6})$z&(\$?[A-Za-z]{1,3}):(\$?[A-Za-z]{1,3})$z'(\$?[A-Za-z]{1,3})(\$?[1-9][0-9]{0,6})$c C s6 | � d�r| S t| �| }|dkr*td��t|�S dS )zL Translate a range row-snippet by the given number of rows. �$r zFormula out of rangeN)� startswith�intr �str)Zrow_str�rdeltaZnew_rowr r r � translate_row<