示例#1
0
def tokenize(string):
    """ This function scans the entire message with a simple regex to find
    all Content-Types and boundaries.
    """
    tokens = deque()
    for m in pattern.finditer(string):
        if m.group(CTYPE):
            name, token = parsing.parse_header(m.group(CTYPE))
        else:
            token = Boundary(
                m.group(BOUNDARY).strip("\t\r\n"),
                grab_newline(m.start(), string, -1),
                grab_newline(m.end(), string, 1))
        tokens.append(token)
    return setup_boundaries(tokens)
示例#2
0
文件: scanner.py 项目: ad-m/flanker
def tokenize(string):
    """ This function scans the entire message with a simple regex to find
    all Content-Types and boundaries.
    """
    tokens = deque()
    for m in pattern.finditer(string):
        if m.group(CTYPE):
            name, token = parsing.parse_header(m.group(CTYPE))
        else:
            token = Boundary(
                m.group(BOUNDARY).strip("\t\r\n"),
                grab_newline(m.start(), string, -1),
                grab_newline(m.end(), string, 1))
        tokens.append(token)
    return setup_boundaries(tokens)
示例#3
0
def tokenize(string):
    """
    Scans the entire message to find all Content-Types and boundaries.
    """
    tokens = deque()
    for m in _RE_TOKENIZER.finditer(string):
        if m.group(_CTYPE):
            name, token = parsing.parse_header(m.group(_CTYPE))
        elif m.group(_BOUNDARY):
            token = Boundary(m.group(_BOUNDARY).strip("\t\r\n"),
                             _grab_newline(m.start(), string, -1),
                             _grab_newline(m.end(), string, 1))
        else:
            token = _EMPTY_LINE

        tokens.append(token)
    return _filter_false_tokens(tokens)
示例#4
0
def tokenize(string):
    """
    Scans the entire message to find all Content-Types and boundaries.
    """
    tokens = deque()
    for m in _RE_TOKENIZER.finditer(string):
        if m.group(_CTYPE):
            name, token = parsing.parse_header(m.group(_CTYPE))
        elif m.group(_BOUNDARY):
            token = Boundary(m.group(_BOUNDARY).strip("\t\r\n"),
                             _grab_newline(m.start(), string, -1),
                             _grab_newline(m.end(), string, 1))
        else:
            token = _EMPTY_LINE

        tokens.append(token)
    return _filter_false_tokens(tokens)
示例#5
0
文件: scanner.py 项目: plq/flanker
def tokenize(string):
    """
    Scans the entire message to find all Content-Types and boundaries.
    """
    if not six.PY2 and isinstance(string, six.binary_type):
        string = string.decode('utf-8')

    tokens = deque()
    for m in _RE_TOKENIZER.finditer(string):
        if m.group(_CTYPE):
            name, token = parsing.parse_header(m.group(_CTYPE))
        elif m.group(_BOUNDARY):
            token = Boundary(m.group(_BOUNDARY).strip('\t\r\n'),
                             _grab_newline(m.start(), string, -1),
                             _grab_newline(m.end(), string, 1))
        else:
            token = _EMPTY_LINE

        tokens.append(token)
    return _filter_false_tokens(tokens)
示例#6
0
def tokenize(string):
    """
    Scans the entire message to find all Content-Types and boundaries.
    """
    if not six.PY2 and isinstance(string, six.binary_type):
        string = string.decode('utf-8')

    tokens = deque()
    for m in _RE_TOKENIZER.finditer(string):
        if m.group(_CTYPE):
            name, token = parsing.parse_header(m.group(_CTYPE))
        elif m.group(_BOUNDARY):
            token = Boundary(
                m.group(_BOUNDARY).strip('\t\r\n'),
                _grab_newline(m.start(), string, -1),
                _grab_newline(m.end(), string, 1))
        else:
            token = _EMPTY_LINE

        tokens.append(token)
    return _filter_false_tokens(tokens)
示例#7
0
def test_content_type_star():
    _, ctype = parsing.parse_header('Content-Type: image/* ; name="Stuart *Wells.PNG"')
    eq_(ctype.value, "image/*")
示例#8
0
def test_content_type_star():
    _, ctype = parsing.parse_header('Content-Type: image/* ; name="Stuart *Wells.PNG"')
    eq_(ctype.value, 'image/*')