# -*- coding: utf-8 -*- # Copyright 2019 Avram Lubkin, All Rights Reserved # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """ An pure Python implementation of tparm Based on documentation in man(5) terminfo and comparing behavior of curses.tparm """ from collections import deque import operator import re OPERATORS = {b'+': operator.add, b'-': operator.sub, b'*': operator.mul, b'/': operator.floordiv, b'm': operator.mod, b'&': operator.and_, b'|': operator.or_, b'^': operator.xor, b'=': operator.eq, b'>': operator.gt, b'<': operator.lt, b'~': operator.inv, b'!': operator.not_, b'A': lambda x, y: bool(x and y), b'O': lambda x, y: bool(x or y)} FILTERS = (('_literal_percent', br'%%'), ('_pop_c', br'%c'), ('_increment_one_two', br'%i'), ('_binary_op', br'%([\+\-\*/m\&\|\^=>