Python sre_parse.expand_template() Examples

The following are 30 code examples of sre_parse.expand_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 _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
Example #2
Source File: re.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #3
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 #4
Source File: re.py    From ImageFusion with MIT License 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #5
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 #6
Source File: re.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #7
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 #8
Source File: re.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
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 _expand(pattern, match, template):
    # internal: match.expand implementation hook
    template = sre_parse.parse_template(template, pattern)
    return sre_parse.expand_template(template, match) 
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 _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #11
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 #12
Source File: re.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #13
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 #14
Source File: re.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #15
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 #16
Source File: re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #17
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 #18
Source File: re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #19
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 #20
Source File: re.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #21
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 #22
Source File: re.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #23
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 #24
Source File: re.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #25
Source File: re.py    From pmatic with GNU General Public License v2.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 #26
Source File: re.py    From jawfish with MIT License 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #27
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 #28
Source File: re.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling 
Example #29
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) 
Example #30
Source File: re.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _subx(pattern, template):
    # internal: pattern.sub/subn implementation helper
    template = _compile_repl(template, pattern)
    if not template[0] and len(template[1]) == 1:
        # literal replacement
        return template[1][0]
    def filter(match, template=template):
        return sre_parse.expand_template(template, match)
    return filter

# register myself for pickling