Use class attributes as much as possible for application output

refs #803
This commit is contained in:
Laurent Bachelier 2014-09-03 01:22:18 +02:00
commit c07e23cafc
35 changed files with 228 additions and 260 deletions

View file

@ -23,7 +23,6 @@ from email import message_from_string, message_from_file
from email.Header import decode_header
from email.mime.text import MIMEText
from smtplib import SMTP
import sys
import os
import re
import unicodedata
@ -157,7 +156,7 @@ class BoobTracker(ReplApplication):
elif len(path) > 0:
query.project = path[0]
else:
print >>sys.stderr, 'Please enter a project name'
print >>self.stderr, 'Please enter a project name'
return 1
query.author = self.options.author
@ -184,12 +183,12 @@ class BoobTracker(ReplApplication):
Get an issue and display it.
"""
if not line:
print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('get', short=True)
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('get', short=True)
return 2
issue = self.get_object(line, 'get_issue')
if not issue:
print >>sys.stderr, 'Issue not found: %s' % line
print >>self.stderr, 'Issue not found: %s' % line
return 3
self.format(issue)
@ -227,7 +226,7 @@ class BoobTracker(ReplApplication):
try:
hours = float(hours)
except ValueError:
print >>sys.stderr, 'Error: HOURS parameter may be a float'
print >>self.stderr, 'Error: HOURS parameter may be a float'
return 1
id, backend_name = self.parse_id(id, unique_backend=True)
@ -383,16 +382,16 @@ class BoobTracker(ReplApplication):
backend = self.weboob.get_backend(issue.backend)
content = self.issue2text(issue, backend)
while True:
if sys.stdin.isatty():
if self.stdin.isatty():
content = self.acquire_input(content, {'vim': "-c 'set ft=mail'"})
m = message_from_string(content.encode('utf-8'))
else:
m = message_from_file(sys.stdin)
m = message_from_file(self.stdin)
try:
email_to = self.text2issue(issue, m)
except ValueError as e:
if not sys.stdin.isatty():
if not self.stdin.isatty():
raise
raw_input("%s -- Press Enter to continue..." % unicode(e).encode("utf-8"))
continue
@ -407,7 +406,7 @@ class BoobTracker(ReplApplication):
self.send_notification(email_to, issue)
return 0
except IssueError as e:
if not sys.stdin.isatty():
if not self.stdin.isatty():
raise
raw_input("%s -- Press Enter to continue..." % unicode(e).encode("utf-8"))
@ -482,7 +481,7 @@ Weboob Team
_id, key, value = self.parse_command_args(line, 3, 1)
issue = self.get_object(_id, 'get_issue')
if not issue:
print >>sys.stderr, 'Issue not found: %s' % _id
print >>self.stderr, 'Issue not found: %s' % _id
return 3
return self.edit_issue(issue, edit=True)
@ -500,4 +499,4 @@ Weboob Team
Attach a file to an issue (Not implemented yet).
"""
print >>sys.stderr, 'Not implemented yet.'
print >>self.stderr, 'Not implemented yet.'