예제 #1
0
파일: rss.py 프로젝트: claytonbrown/sabnzbd
def convert_filter(text):
    """ Return compiled regex.
        If string starts with re: it's a real regex
        else quote all regex specials, replace '*' by '.*'
    """
    if text[:3].lower() == 're:':
        txt = text[3:]
    else:
        txt = wildcard_to_re(text)
    try:
        return re.compile(txt, re.I)
    except:
        logging.error(Ta('Could not compile regex: %s'), text)
        return None
예제 #2
0
파일: rss.py 프로젝트: labrys/sabnzbd
def convert_filter(text):
    """ Return compiled regex.
        If string starts with re: it's a real regex
        else quote all regex specials, replace '*' by '.*'
    """
    text = text.strip().lower()
    if text.startswith('re:'):
        txt = text[3:].strip()
    else:
        txt = wildcard_to_re(text)
    try:
        return re.compile(txt, re.I)
    except:
        logging.debug('Could not compile regex: %s', text)
        return None
예제 #3
0
파일: rss.py 프로젝트: rivy/sabnzbd
def convert_filter(text):
    """ Return compiled regex.
        If string starts with re: it's a real regex
        else quote all regex specials, replace '*' by '.*'
    """
    text = text.strip().lower()
    if text.startswith('re:'):
        txt = text[3:].strip()
    else:
        txt = wildcard_to_re(text)
    try:
        return re.compile(txt, re.I)
    except:
        logging.debug('Could not compile regex: %s', text)
        return None
예제 #4
0
 def test_wildcard_to_re(self):
     assert "\\\\\\^\\$\\.\\[" == misc.wildcard_to_re("\\^$.[")
     assert "\\]\\(\\)\\+.\\|\\{\\}.*" == misc.wildcard_to_re("]()+?|{}*")