Skip to content

Commit

Permalink
Use the provided Config's output stream if setOutputStream is never c…
Browse files Browse the repository at this point in the history
…alled.
  • Loading branch information
exogen committed Mar 6, 2010
1 parent d9a22cd commit 8f30747
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion noseachievements/plugin.py
Expand Up @@ -37,6 +37,7 @@ def __init__(self, achievements=default_manager, data=None):
achievements = AchievementManager(achievements)
self.achievements = achievements
self.data = AchievementData(data or {})
self.output_stream = None

def options(self, parser, env):
if Plugin is not object:
Expand All @@ -55,6 +56,9 @@ def options(self, parser, env):
"groups. [ACHIEVEMENTS]")

def configure(self, options, conf):
# Save a reference to the `Config` to access its `stream` in case
# setOutputStream isn't called.
self.config = conf
if Plugin is not object:
super(AchievementsPlugin, self).configure(options, conf)

Expand Down Expand Up @@ -138,7 +142,7 @@ def finalize(self, result):
self.data.save(data_file)
data_file.close()

output_stream = self.output_stream
output_stream = self.output_stream or self.config.stream
if str is not unicode:
output_stream = codecs.getwriter('utf-8')(output_stream)
for achievement in self.data['achievements.new']:
Expand Down

0 comments on commit 8f30747

Please sign in to comment.