コード例 #1
0
 def test_balanced(self):
     """ Separators are balanced.
     """
     from wheezy.template.utils import find_all_balanced
     assert 10 == find_all_balanced('test(a, b)', 4)
     assert 13 == find_all_balanced('test(a, b)[0]', 4)
     assert 12 == find_all_balanced('test(a, b())', 4)
     assert 17 == find_all_balanced('test(a, b())[0]()', 4)
コード例 #2
0
ファイル: core.py プロジェクト: wutongshu85/wheezy.template
def var_token(m: typing.Match[str]) -> Token:
    """Produces variable token."""
    start = m.start(1)
    pos = m.end()
    source = m.string
    while 1:
        end = find_all_balanced(source, pos)
        if pos == end:
            break
        mm = RE_VAR.match(source, end)
        if not mm:
            break
        pos = mm.end()
    value = source[start:end]
    mm = RE_VAR_FILTER.match(source, end)
    if mm:
        end = mm.end()
        value += "!" + mm.group()
    return end, "var", value
コード例 #3
0
ファイル: core.py プロジェクト: lendackya/Add-PMT-Files
def var_token(m):
    """ Produces variable token.
    """
    start = m.start(1)
    pos = m.end()
    source = m.string
    while 1:
        end = find_all_balanced(source, pos)
        if pos == end:
            break
        m = RE_VAR.match(source, end)
        if not m:
            break
        pos = m.end()
    value = str(source[start:end])
    m = RE_VAR_FILTER.match(source, end)
    if m:
        end = m.end()
        value += '!' + m.group()
    return end, 'var', value
コード例 #4
0
ファイル: core.py プロジェクト: AlanCristhian/andres-ruiz
def var_token(m):
    """ Produces variable token.
    """
    start = m.start(1)
    pos = m.end()
    source = m.string
    while 1:
        end = find_all_balanced(source, pos)
        if pos == end:
            break
        m = RE_VAR.match(source, end)
        if not m:
            break
        pos = m.end()
    value = str(source[start:end])
    m = RE_VAR_FILTER.match(source, end)
    if m:
        end = m.end()
        value += '!' + m.group()
    return end, 'var', value
コード例 #5
0
ファイル: test_utils.py プロジェクト: ExpressLRS/ExpressLRS
 def test_start_out(self) -> None:
     """The start index is out of range."""
     assert 10 == find_all_balanced("test", 10)
コード例 #6
0
ファイル: test_utils.py プロジェクト: ExpressLRS/ExpressLRS
 def test_balanced(self) -> None:
     """Separators are balanced."""
     assert 10 == find_all_balanced("test(a, b)", 4)
     assert 13 == find_all_balanced("test(a, b)[0]", 4)
     assert 12 == find_all_balanced("test(a, b())", 4)
     assert 17 == find_all_balanced("test(a, b())[0]()", 4)
コード例 #7
0
ファイル: test_utils.py プロジェクト: ExpressLRS/ExpressLRS
 def test_not_balanced(self) -> None:
     """Separators are not balanced."""
     assert 4 == find_all_balanced("test(a, b", 4)
     assert 4 == find_all_balanced("test[a, b()", 4)
コード例 #8
0
ファイル: test_utils.py プロジェクト: ExpressLRS/ExpressLRS
 def test_start_separator(self) -> None:
     """If text doesn't start with ``([`` return."""
     assert 0 == find_all_balanced("test([", 0)
     assert 3 == find_all_balanced("test([", 3)
コード例 #9
0
 def test_not_balanced(self):
     """ Separators are not balanced.
     """
     from wheezy.template.utils import find_all_balanced
     assert 4 == find_all_balanced('test(a, b', 4)
     assert 4 == find_all_balanced('test[a, b()', 4)
コード例 #10
0
 def test_start_separator(self):
     """ If text doesn't start with ``([`` return.
     """
     from wheezy.template.utils import find_all_balanced
     assert 0 == find_all_balanced('test([', 0)
     assert 3 == find_all_balanced('test([', 3)
コード例 #11
0
 def test_start_out(self):
     """ The start index is out of range.
     """
     from wheezy.template.utils import find_all_balanced
     assert 10 == find_all_balanced('test', 10)