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

@ -19,7 +19,6 @@
import os
import sys
import tempfile
import codecs
@ -53,10 +52,10 @@ class WebContentEdit(ReplApplication):
contents += [content for backend, content in self.do('get_content', _id, backends=backend_names) if content]
if len(contents) == 0:
print >>sys.stderr, 'No contents found'
print >>self.stderr, 'No contents found'
return 3
if sys.stdin.isatty():
if self.stdin.isatty():
paths = {}
for content in contents:
tmpdir = os.path.join(tempfile.gettempdir(), "weboob")
@ -91,7 +90,7 @@ class WebContentEdit(ReplApplication):
contents.remove(content)
if len(contents) == 0:
print >>sys.stderr, 'No changes. Abort.'
print >>self.stderr, 'No changes. Abort.'
return 1
print 'Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents))
@ -118,7 +117,7 @@ class WebContentEdit(ReplApplication):
# stdin is not a tty
if len(contents) != 1:
print >>sys.stderr, "Multiple ids not supported with pipe"
print >>self.stderr, "Multiple ids not supported with pipe"
return 2
message, minor = '', False
@ -148,7 +147,7 @@ class WebContentEdit(ReplApplication):
Display log of a page
"""
if not line:
print >>sys.stderr, 'Error: please give a page ID'
print >>self.stderr, 'Error: please give a page ID'
return 2
_id, backend_name = self.parse_id(line)
@ -167,7 +166,7 @@ class WebContentEdit(ReplApplication):
Get page contents
"""
if not line:
print >>sys.stderr, 'Error: please give a page ID'
print >>self.stderr, 'Error: please give a page ID'
return 2
_part_line = line.strip().split(' ')
@ -180,7 +179,7 @@ class WebContentEdit(ReplApplication):
_part_line.remove('-r')
if not _part_line:
print >>sys.stderr, 'Error: please give a page ID'
print >>self.stderr, 'Error: please give a page ID'
return 2
_id, backend_name = self.parse_id(" ".join(_part_line))