Commit 37daad34 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

Make invokation a little more flexible

Add options to control output, allowing us to use the parser to
generate patch hashes.
Signed-off-by: default avatarJeremy Kerr <>
parent a2d3b37e
......@@ -205,11 +205,31 @@ def hash_patch(str):
return hash
if __name__ == '__main__':
import sys
def main(args):
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-p', '--patch', action = 'store_true',
dest = 'print_patch', help = 'print parsed patch')
parser.add_option('-c', '--comment', action = 'store_true',
dest = 'print_comment', help = 'print parsed comment')
parser.add_option('-#', '--hash', action = 'store_true',
dest = 'print_hash', help = 'print patch hash')
(options, args) = parser.parse_args()
(patch, comment) = parse_patch(
if patch:
if options.print_hash and patch:
print hash_patch(patch).hexdigest()
if options.print_patch and patch:
print "Patch: ------\n" + patch
print "hash: %s" % hash_patch(patch).hexdigest()
if comment:
if options.print_comment and comment:
print "Comment: ----\n" + comment
if __name__ == '__main__':
import sys
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment