+ bcc_addr = csv(options.bcc + [autobcc])
+ elif autobcc:
+ bcc_addr = autobcc
+
+ # replace existing headers
+ if to_addr:
+ tmpl, h = replace_header('To', to_addr, tmpl)
+ if h:
+ headers += h + '\n'
+ if cc_addr:
+ tmpl, h = replace_header('Cc', cc_addr, tmpl)
+ if h:
+ headers += h + '\n'
+ if bcc_addr:
+ tmpl, h = replace_header('Bcc', bcc_addr, tmpl)
+ if h:
+ headers += h + '\n'
+
+ return tmpl, headers
+
+def __get_signers_list(msg):
+ """Return the address list generated from signed-off-by and
+ acked-by lines in the message.
+ """
+ addr_list = []
+
+ r = re.compile('^(signed-off-by|acked-by):\s+(.+)$', re.I)
+ for line in msg.split('\n'):
+ m = r.match(line)
+ if m:
+ addr_list.append(m.expand('\g<2>'))
+
+ return addr_list
+
+def __build_extra_headers():
+ """Build extra headers like content-type etc.
+ """
+ headers = 'Content-Type: text/plain; charset=utf-8; format=fixed\n'
+ headers += 'Content-Transfer-Encoding: 8bit\n'
+ headers += 'User-Agent: StGIT/%s\n' % version.version
+
+ return headers
+
+def edit_message(msg):
+ fname = '.stgitmail.txt'
+
+ # create the initial file
+ f = file(fname, 'w')
+ f.write(msg)
+ f.close()
+
+ # the editor
+ if config.has_option('stgit', 'editor'):
+ editor = config.get('stgit', 'editor')
+ elif 'EDITOR' in os.environ:
+ editor = os.environ['EDITOR']
+ else:
+ editor = 'vi'
+ editor += ' %s' % fname
+
+ print 'Invoking the editor: "%s"...' % editor,
+ sys.stdout.flush()
+ print 'done (exit code: %d)' % os.system(editor)
+
+ # read the message back
+ f = file(fname)
+ msg = f.read()
+ f.close()
+
+ return msg
+
+def __build_cover(tmpl, total_nr, msg_id, options):
+ """Build the cover message (series description) to be sent via SMTP
+ """
+ maintainer = __get_maintainer()
+ if not maintainer:
+ maintainer = ''
+
+ tmpl, headers_end = __build_address_headers(tmpl, options)