artemis.py
changeset 61 18da6a9fa7b8
parent 60 f44b6f1f2115
equal deleted inserted replaced
60:f44b6f1f2115 61:18da6a9fa7b8
    15 from email.mime.text import MIMEText
    15 from email.mime.text import MIMEText
    16 
    16 
    17 from    termcolor       import colored
    17 from    termcolor       import colored
    18 
    18 
    19 
    19 
    20 state = {'new': 'new', 'fixed': ['fixed', 'resolved']}
    20 state = { 'new':   ['new'],
    21 state['default'] = state['new']
    21           'fixed': ['fixed', 'resolved'] }
       
    22 annotation = { 'resolved': 'resolution' }
       
    23 default_state = 'new'
    22 default_issues_dir = ".issues"
    24 default_issues_dir = ".issues"
    23 filter_prefix = ".filter"
    25 filter_prefix = ".filter"
    24 date_format = '%a, %d %b %Y %H:%M:%S %1%2'
    26 date_format = '%a, %d %b %Y %H:%M:%S %1%2'
    25 maildir_dirs = ['new','cur','tmp']
    27 maildir_dirs = ['new','cur','tmp']
    26 
    28 
   117 
   119 
   118     user = ui.username()
   120     user = ui.username()
   119 
   121 
   120     default_issue_text  =         "From: %s\nDate: %s\n" % (user, util.datestr(format = date_format))
   122     default_issue_text  =         "From: %s\nDate: %s\n" % (user, util.datestr(format = date_format))
   121     if not id:
   123     if not id:
   122         default_issue_text +=     "State: %s\n" % state['default']
   124         default_issue_text +=     "State: %s\n" % default_state
   123     default_issue_text +=         "Subject: brief description\n\n"
   125     default_issue_text +=         "Subject: brief description\n\n"
   124     default_issue_text +=         "Detailed description."
   126     default_issue_text +=         "Detailed description."
   125 
   127 
   126     # Get properties, and figure out if we need an explicit comment
   128     # Get properties, and figure out if we need an explicit comment
   127     properties = _get_properties(opts['property'])
   129     properties = _get_properties(opts['property'])
   129     message = opts['message']
   131     message = opts['message']
   130 
   132 
   131     # Create the text
   133     # Create the text
   132     if message:
   134     if message:
   133         if not id:
   135         if not id:
   134             state_str = 'State: %s\n' % state['default']
   136             state_str = 'State: %s\n' % default_state
   135         else:
   137         else:
   136             state_str = ''
   138             state_str = ''
   137         issue = "From: %s\nDate: %s\nSubject: %s\n%s" % \
   139         issue = "From: %s\nDate: %s\nSubject: %s\n%s" % \
   138                 (user, util.datestr(format=date_format), message, state_str)
   140                 (user, util.datestr(format=date_format), message, state_str)
   139     elif not no_comment:
   141     elif not no_comment:
   415         attachment.add_header('Content-Disposition', 'attachment', filename=filename)
   417         attachment.add_header('Content-Disposition', 'attachment', filename=filename)
   416         outer.attach(attachment)
   418         outer.attach(attachment)
   417     return outer
   419     return outer
   418 
   420 
   419 def _status_msg(msg):
   421 def _status_msg(msg):
   420     if msg['State'] == 'resolved':
   422     s = msg['State']
   421         return 'resolved=' + msg['resolution']
   423     if s in annotation:
   422     else:
   424         return '%s=%s' % (s, msg[annotation[s]])
   423         return msg['State']
   425     else:
       
   426         return s
   424 
   427 
   425 def _read_colors(ui):
   428 def _read_colors(ui):
   426     colors = {}
   429     colors = {}
   427     # defaults
   430     # defaults
   428     colors['new.color']             = 'red'
   431     colors['new.color']             = 'red'