aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-05-23 21:50:12 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-05-23 21:50:12 +0000
commit1a0062a29e5676836926349d12dc9d8c77bb69f5 (patch)
treecc6483e175f3aea1e1ef4b82f91dc4df9ad88e88 /utils
parentc0492741dc594cd02736521048fe0d8f4c9a0a61 (diff)
downloadlldb-1a0062a29e5676836926349d12dc9d8c77bb69f5.tar.gz
Add a Python utility to help convert the Mail.app saved 'Raw Message Source' .eml file to a git-am friendly file.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131924 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rwxr-xr-xutils/git-svn/convert.py65
-rwxr-xr-xutils/test/lldb-disasm.py10
2 files changed, 70 insertions, 5 deletions
diff --git a/utils/git-svn/convert.py b/utils/git-svn/convert.py
new file mode 100755
index 000000000..f72f435c7
--- /dev/null
+++ b/utils/git-svn/convert.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+"""
+Convert the raw message sources from git patch emails to git-am friendly files.
+
+Usage:
+
+1. Mail.app -> Save As -> api.eml (Raw Message Source)
+2. .../convert.py api.eml
+3. git am --signoff < api.eml
+4. git commit -a
+"""
+
+import os, re, sys
+import StringIO
+
+def usage(problem_file=None):
+ if problem_file:
+ print "%s is not a file" % problem_file
+ print "Usage: convert.py raw-message-source [raw-message-source2 ...]"
+ sys.exit(0)
+
+def do_convert(file):
+ """Skip all preceding mail message headers until 'From: ' is encountered.
+ Then for each line ('From: ' header included), replace the dos style CRLF
+ end-of-line with unix style LF end-of-line.
+ """
+ print "converting %s ..." % file
+
+ with open(file, 'r') as f_in:
+ content = f_in.read()
+
+ # The new content to be written back to the same file.
+ new_content = StringIO.StringIO()
+
+ # Boolean flag controls whether to start printing lines.
+ from_header_seen = False
+
+ # By default, splitlines() don't include line breaks. CRLF should be gone.
+ for line in content.splitlines():
+ # Wait till we scan the 'From: ' header before start printing the lines.
+ if not from_header_seen:
+ if not line.startswith('From: '):
+ continue
+ else:
+ from_header_seen = True
+
+ print >> new_content, line
+
+ with open(file, 'w') as f_out:
+ f_out.write(new_content.getvalue())
+
+ print "done"
+
+def main():
+ if len(sys.argv) == 1:
+ usage()
+ # Convert the raw message source one by one.
+ for file in sys.argv[1:]:
+ if not os.path.isfile(file):
+ usage(file)
+ do_convert(file)
+
+if __name__ == '__main__':
+ main()
diff --git a/utils/test/lldb-disasm.py b/utils/test/lldb-disasm.py
index 022a70f7b..48c286172 100755
--- a/utils/test/lldb-disasm.py
+++ b/utils/test/lldb-disasm.py
@@ -137,11 +137,11 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, sy
count = count + 1
print "returning symbol:", s.GetName()
yield s.GetName()
- #print "start address:", s.GetStartAddress()
- #print "end address:", s.GetEndAddress()
- #s.GetDescription(stream)
- #print "symbol description:", stream.GetData()
- #stream.Clear()
+ print "start address:", s.GetStartAddress()
+ print "end address:", s.GetEndAddress()
+ s.GetDescription(stream)
+ print "symbol description:", stream.GetData()
+ stream.Clear()
# Disassembly time.
for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target):