def parse_latex_file(fname):
    # vt_begin_re = re.compile(r"% -- VISTRAILS BEGIN --")
    # vt_end_re = re.compile(r"% -- VISTRAILS END --")
    vt_begin_re = re.compile(r"^(?:(?:\\%)|[^%])*(\\vistrail[\[\{])")

    # we'll just assume balanced parens here...
    # vt_end_re = re.compile(r"\}")
    vt_bracket_re = re.compile(r"[\[\]]")
    vt_brace_re = re.compile(r"[\{\}]")
    f = open(fname)
    
    raw_text = [""]
    raw_idx = 0
    vt_text = []
    for line in f:
        m = vt_begin_re.search(line)
        if not m:
            raw_text[raw_idx] += line
        else:
            # print 'found:', m.start(1), m.end(1), line[m.end(1) - 1]

            # first end the current raw_text block
            raw_text[raw_idx] += line[:m.start(1)]
            raw_text.append("")
            raw_idx += 1

            cmd_text = ""
            # line = line[m.start(1):]
            line = line[1-m.end(1):]

            # we'll just assume balanced parens here...
            if line[0] == '[':
                brackets_complete = False
                found_start = False
                brackets = 0
                while not brackets_complete:
                    for m in vt_bracket_re.finditer(line):
                        bracket_char = line[m.start()]
                        if bracket_char == '[':
                            brackets += 1
                            found_start = True
                        else:
                            brackets -= 1
                        if found_start and brackets == 0:
                            brackets_complete = True
                            cmd_text += line[:m.end()]
                            line = line[m.end():]
                            break
                    if brackets_complete:
                        break
                    cmd_text += line
                    line = f.next()
            
            opt_cmd_text = cmd_text
            cmd_text = ""
            braces_complete = False
            found_start = False
            braces = 0
            while not braces_complete:
                for m in vt_brace_re.finditer(line):
                    brace_char = line[m.start()]
                    if brace_char == '{':
                        braces += 1
                        found_start = True
                    else:
                        braces -= 1
                    if found_start and braces == 0:
                        braces_complete = True
                        cmd_text += line[:m.end()]
                        break
                if braces_complete:
                    break
                cmd_text += line
                line = f.next()
            # print cmd_text
            vt_text.append((opt_cmd_text,cmd_text))
            raw_text[raw_idx] += line[m.end():]
            
        # if vt_begin_re.search(line):
        #     line = f.next()
        #     while not vt_end_re.search(line):
        #         print line.strip()
        #         line = f.next()
    f.close()

    # vt_text.append(("", ""))
    #for t, vt in izip(raw_text, vt_text + [("", "")]):
        #print "RAW:", t
        #print "VT:", parse_vt_command(*vt)
    return (raw_text, vt_text)
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/publishing/parse_latex.py/parse_latex_file/swapped operands of `-`