/usr/lib/python3.9/site-packages/tuned/profiles/functions
Edit: /usr/lib/python3.9/site-packages/tuned/profiles/functions/parser.py (2145B)
import re
import tuned.logs
from tuned.utils.commands import commands
log = tuned.logs.get()
cmd = commands()
class Parser():
"""
Parser used for expanding strings containing functions.
"""
def __init__(self, repository):
self._repository = repository
def _parse_init(self, s = ""):
self._cnt = 0
self._str = s
self._len = len(s)
self._stack = []
self._esc = False
def _curr_char(self):
return self._str[self._cnt] if self._cnt < self._len else ""
def _curr_substr(self, _len):
return self._str[self._cnt:self._cnt + _len]
def _push_pos(self, esc):
self._stack.append((esc, self._cnt))
def _sub(self, a, b, s):
self._str = self._str[:a] + s + self._str[b + 1:]
self._len = len(self._str)
self._cnt += len(s) - (b - a + 1)
if self._cnt < 0:
self._cnt = 0
def _process_func(self, _from):
sl = re.split(r'(?