Esempio n. 1
0
def strip_encoding_cookie():
    """Remove encoding comment if found in first two lines
    
    If the first or second line has the `# coding: utf-8` comment,
    it will be removed.
    """
    line = ''
    while True:
        line = (yield line)
        # check comment on first two lines
        for i in range(2):
            if line is None:
                break
            if cookie_comment_re.match(line):
                line = (yield "")
            else:
                line = (yield line)
        
        # no-op on the rest of the cell
        while line is not None:
            line = (yield line)
Esempio n. 2
0
def strip_encoding_cookie():
    """Remove encoding comment if found in first two lines
    
    If the first or second line has the `# coding: utf-8` comment,
    it will be removed.
    """
    line = ''
    while True:
        line = (yield line)
        # check comment on first two lines
        for i in range(2):
            if line is None:
                break
            if cookie_comment_re.match(line):
                line = (yield "")
            else:
                line = (yield line)

        # no-op on the rest of the cell
        while line is not None:
            line = (yield line)