diff --git a/docs/api/reporter.rst b/docs/api/reporter.rst new file mode 100644 index 000000000..03260f9cd --- /dev/null +++ b/docs/api/reporter.rst @@ -0,0 +1,5 @@ +:mod:`letsencrypt.reporter` +--------------------------- + +.. automodule:: letsencrypt.reporter + :members: diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 59e99648d..70a0d82ee 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -1,7 +1,7 @@ """Let's Encrypt CLI.""" # TODO: Sanity check all input. Be sure to avoid shell code etc... -import atexit import argparse +import atexit import logging import os import sys diff --git a/letsencrypt/reporter.py b/letsencrypt/reporter.py index 26269e3f8..99586d7cf 100644 --- a/letsencrypt/reporter.py +++ b/letsencrypt/reporter.py @@ -12,16 +12,16 @@ from letsencrypt import interfaces class Reporter(object): """Collects and displays information to the user. - :ivar `Queue.PriorityQueue` messages: Messages to be displayed to the user. + :ivar `Queue.PriorityQueue` messages: Messages to be displayed to + the user. """ - zope.interface.implements(interfaces.IReporter) HIGH_PRIORITY, MEDIUM_PRIORITY, LOW_PRIORITY = xrange(3) _RESET = '\033[0m' _BOLD = '\033[1m' - _msg_type = collections.namedtuple('Msg', 'priority, text, on_crash') + _msg_type = collections.namedtuple('ReporterMsg', 'priority text on_crash') def __init__(self): self.messages = Queue.PriorityQueue() @@ -31,21 +31,21 @@ class Reporter(object): :param str msg: Message to be displayed to the user. - :param int priority: One of HIGH_PRIORITY, MEDIUM_PRIORITY, or - LOW_PRIORITY. + :param int priority: One of `HIGH_PRIORITY`, `MEDIUM_PRIORITY`, + or `LOW_PRIORITY`. - :param bool on_crash: Whether or not the message should be printed if - the program exits abnormally. + :param bool on_crash: Whether or not the message should be + printed if the program exits abnormally. """ - assert priority >= self.HIGH_PRIORITY and priority <= self.LOW_PRIORITY + assert self.HIGH_PRIORITY <= priority <= self.LOW_PRIORITY self.messages.put(self._msg_type(priority, msg, on_crash)) def print_messages(self): """Prints messages to the user and clears the message queue. - If there is an unhandled exception, only messages for which on_crash is - True are printed. + If there is an unhandled exception, only messages for which + ``on_crash`` is ``True`` are printed. """ bold_on = False @@ -56,7 +56,7 @@ class Reporter(object): sys.stdout.write(self._BOLD) print 'IMPORTANT NOTES:' wrapper = textwrap.TextWrapper(initial_indent=' - ', - subsequent_indent=' '*3) + subsequent_indent=(' ' * 3)) while not self.messages.empty(): msg = self.messages.get() if no_exception or msg.on_crash: diff --git a/letsencrypt/tests/reporter_test.py b/letsencrypt/tests/reporter_test.py index df9790256..e6a8c9005 100644 --- a/letsencrypt/tests/reporter_test.py +++ b/letsencrypt/tests/reporter_test.py @@ -1,10 +1,12 @@ -"""Tests for letsencrypt/reporter.py""" +"""Tests for letsencrypt.reporter.""" import StringIO import sys import unittest class ReporterTest(unittest.TestCase): + """Tests for letsencrypt.reporter.Reporter.""" + def setUp(self): from letsencrypt import reporter self.reporter = reporter.Reporter() @@ -70,4 +72,4 @@ class ReporterTest(unittest.TestCase): if __name__ == "__main__": - unittest.main() # pragma: no cover + unittest.main() # pragma: no cover