/usr/lib64/python2.6/site-packages/lxml/html
NameSizeModeActions
builder.py43100644editdlrm
builder.pyc39180644editdlrm
builder.pyo39180644editdlrm
clean.py250170644editdlrm
clean.pyc189000644editdlrm
clean.pyo187990644editdlrm
defs.py38000644editdlrm
defs.pyc35780644editdlrm
defs.pyo35780644editdlrm
diff.py303750644editdlrm
diff.pyc286960644editdlrm
diff.pyo283460644editdlrm
ElementSoup.py3190644editdlrm
ElementSoup.pyc6220644editdlrm
ElementSoup.pyo6220644editdlrm
formfill.py97610644editdlrm
formfill.pyc100150644editdlrm
formfill.pyo97610644editdlrm
html5parser.py53040644editdlrm
html5parser.pyc58700644editdlrm
html5parser.pyo58700644editdlrm
soupparser.py42750644editdlrm
soupparser.pyc48310644editdlrm
soupparser.pyo48310644editdlrm
usedoctest.py2490644editdlrm
usedoctest.pyc4640644editdlrm
usedoctest.pyo4640644editdlrm
_dictmixin.py35390644editdlrm
_dictmixin.pyc46880644editdlrm
_dictmixin.pyo46880644editdlrm
_diffcommand.py20820644editdlrm
_diffcommand.pyc28560644editdlrm
_diffcommand.pyo28560644editdlrm
_html5builder.py31240644editdlrm
_html5builder.pyc44980644editdlrm
_html5builder.pyo44980644editdlrm
_setmixin.py24880644editdlrm
_setmixin.pyc51940644editdlrm
_setmixin.pyo51940644editdlrm
__init__.py521370644editdlrm
__init__.pyc563640644editdlrm
__init__.pyo561100644editdlrm
Edit: /usr/lib64/python2.6/site-packages/lxml/html/_diffcommand.py (2082B)
import optparse import sys import re import os from lxml.html.diff import htmldiff description = """\ """ parser = optparse.OptionParser( usage="%prog [OPTIONS] FILE1 FILE2\n" "%prog --annotate [OPTIONS] INFO1 FILE1 INFO2 FILE2 ...", description=description, ) parser.add_option( '-o', '--output', metavar="FILE", dest="output", default="-", help="File to write the difference to", ) parser.add_option( '-a', '--annotation', action="store_true", dest="annotation", help="Do an annotation") def main(args=None): if args is None: args = sys.argv[1:] options, args = parser.parse_args(args) if options.annotation: return annotate(options, args) if len(args) != 2: print 'Error: you must give two files' parser.print_help() sys.exit(1) file1, file2 = args input1 = read_file(file1) input2 = read_file(file2) body1 = split_body(input1)[1] pre, body2, post = split_body(input2) result = htmldiff(body1, body2) result = pre + result + post if options.output == '-': if not result.endswith('\n'): result += '\n' sys.stdout.write(result) else: f = open(options.output, 'wb') f.write(result) f.close() def read_file(filename): if filename == '-': c = sys.stdin.read() elif not os.path.exists(filename): raise OSError( "Input file %s does not exist" % filename) else: f = open(filename, 'rb') c = f.read() f.close() return c body_start_re = re.compile( r"", re.I|re.S) body_end_re = re.compile( r"", re.I|re.S) def split_body(html): match = body_start_re.search(html) if match: pre = html[:match.end()] html = html[match.end():] match = body_end_re.search(html) if match: post = html[match.start():] html = html[:match.start()] return pre, html, post def annotate(options, args): print "Not yet implemented" sys.exit(1)