Python sre_parse.parse_template() Examples

The following are 30 code examples of sre_parse.parse_template(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sre_parse , or try the search function .
Example #1
Source File: re.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #2
Source File: re.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #3
Source File: re.py    From ImageFusion with MIT License 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #4
Source File: re.py    From ImageFusion with MIT License 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #5
Source File: re.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #6
Source File: re.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #7
Source File: re.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #8
Source File: re.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #9
Source File: re.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def _compile_repl(repl, pattern):
    # internal: compile replacement pattern
    try:
        return _cache_repl[repl, pattern]
    except KeyError:
        pass
    p = sre_parse.parse_template(repl, pattern)
    if len(_cache_repl) >= _MAXCACHE:
        _cache_repl.clear()
    _cache_repl[repl, pattern] = p
    return p 
Example #10
Source File: re.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #11
Source File: re.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #12
Source File: re.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #13
Source File: re.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def _compile_repl(repl, pattern):
    # internal: compile replacement pattern
    try:
        return _cache_repl[repl, pattern]
    except KeyError:
        pass
    p = sre_parse.parse_template(repl, pattern)
    if len(_cache_repl) >= _MAXCACHE:
        _cache_repl.clear()
    _cache_repl[repl, pattern] = p
    return p 
Example #14
Source File: re.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #15
Source File: re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #16
Source File: re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #17
Source File: re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #18
Source File: re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #19
Source File: re.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #20
Source File: re.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #21
Source File: re.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #22
Source File: re.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #23
Source File: re.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #24
Source File: re.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #25
Source File: re.py    From pmatic with GNU General Public License v2.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #26
Source File: re.py    From jawfish with MIT License 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #27
Source File: re.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
Example #28
Source File: re.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #29
Source File: re.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _compile_repl(repl, pattern):
    # internal: compile replacement pattern
    try:
        return _cache_repl[repl, pattern]
    except KeyError:
        pass
    p = sre_parse.parse_template(repl, pattern)
    if len(_cache_repl) >= _MAXCACHE:
        _cache_repl.clear()
    _cache_repl[repl, pattern] = p
    return p 
Example #30
Source File: re.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match)