forked from openlp/openlp
removed CLI interface of the mailto library
This commit is contained in:
parent
c28b129421
commit
af202e3358
@ -319,57 +319,3 @@ def mailto(address, to=None, cc=None, bcc=None, subject=None, body=None,
|
||||
mailto_string = mailto_format(**locals())
|
||||
return open(mailto_string)
|
||||
|
||||
|
||||
if __name__ == u'__main__':
|
||||
"""
|
||||
Option handler for CLI usage
|
||||
"""
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
version = u'%%prog %s' % __version__
|
||||
usage = (
|
||||
u'\n\n%prog FILENAME [FILENAME(s)] -- for opening files'
|
||||
u'\n\n%prog -m [OPTIONS] ADDRESS [ADDRESS(es)] -- for sending e-mails'
|
||||
)
|
||||
|
||||
parser = OptionParser(usage=usage, version=version, description=__doc__)
|
||||
parser.add_option(u'-m', u'--mailto', dest=u'mailto_mode', default=False,
|
||||
action=u'store_true', help=u'set mailto mode. If not set any other '
|
||||
u'option is ignored')
|
||||
parser.add_option(u'--cc', dest=u'cc', help=u'specify a recipient to be '
|
||||
u'copied on the e-mail')
|
||||
parser.add_option(u'--bcc', dest=u'bcc', help=u'specify a recipient to be '
|
||||
u'blindly copied on the e-mail')
|
||||
parser.add_option(u'--subject', dest=u'subject', help=u'specify a subject '
|
||||
u'for the e-mail')
|
||||
parser.add_option(u'--body', dest=u'body', help=u'specify a body for the '
|
||||
u'e-mail. Since the user will be able to make changes before actually '
|
||||
u'sending the e-mail, this can be used to provide the user with a '
|
||||
u'template for the e-mail text may contain linebreaks')
|
||||
parser.add_option(u'--attach', dest=u'attach', help=u'specify an '
|
||||
u'attachment for the e-mail. file must point to an existing file')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if not args:
|
||||
parser.print_usage()
|
||||
parser.exit(1)
|
||||
|
||||
if options.mailto_mode:
|
||||
if not mailto(args, None, options.cc, options.bcc, options.subject,
|
||||
options.body, options.attach):
|
||||
sys.exit(u'Unable to open the e-mail client')
|
||||
else:
|
||||
for name in (u'cc', u'bcc', u'subject', u'body', u'attach'):
|
||||
if getattr(options, name):
|
||||
parser.error(u'The "cc", "bcc", "subject", "body" and "attach" '
|
||||
u'options are only accepten in mailto mode')
|
||||
success = False
|
||||
for arg in args:
|
||||
if not open(arg):
|
||||
print u'Unable to open "%s"' % arg
|
||||
else:
|
||||
success = True
|
||||
sys.exit(success)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user