\n') 1441 | out.append(body) 1442 | out.append('\n') 1443 | 1444 | # out.append('\n') 1445 | # out.append('\n') 1446 | 1447 | return ''.join(out) 1448 | 1449 | 1450 | 1451 | # put the tags generated by changeTags into the text and create HTML 1452 | def applyTags(s, tags, side): 1453 | tags = sorted(tags, key = lambda t: (t.idx, -t.start)) 1454 | curr = 0 1455 | out = [] 1456 | for t in tags: 1457 | while curr < t.idx and curr < len(s): 1458 | out.append(escape(s[curr])) 1459 | curr += 1 1460 | out.append(t.tag) 1461 | 1462 | while curr < len(s): 1463 | out.append(escape(s[curr])) 1464 | curr += 1 1465 | return ''.join(out) 1466 | 1467 | 1468 | 1469 | 1470 | #--------------------- tag generation functions ---------------------- 1471 | 1472 | def changeTags(s, changes, side): 1473 | tags = [] 1474 | for r in changes: 1475 | key = r.orig if side == 'left' else r.cur 1476 | if hasattr(key, 'lineno'): 1477 | start = nodeStart(key) 1478 | if IS(key, FunctionDef): 1479 | end = start + len('def') 1480 | elif IS(key, ClassDef): 1481 | end = start + len('class') 1482 | else: 1483 | end = nodeEnd(key) 1484 | 1485 | if r.orig <> None and r.cur <> None: 1486 | # for change and move 1487 | tags.append(Tag(linkTagStart(r, side), start)) 1488 | tags.append(Tag("", end, start)) 1489 | else: 1490 | # for deletion and insertion 1491 | tags.append(Tag(spanStart(r), start)) 1492 | tags.append(Tag('', end, start)) 1493 | 1494 | return tags 1495 | 1496 | 1497 | 1498 | def lineTags(s): 1499 | out = [] 1500 | lineno = 1; 1501 | curr = 0 1502 | while curr < len(s): 1503 | if curr == 0 or s[curr-1] == '\n': 1504 | out.append(Tag('
') 1772 | outfile1.write(report) 1773 | outfile1.write('