Add missing docstrings
[snf-image-creator] / image_creator / dialog_wizard.py
index e1719cc..5605cc7 100644 (file)
@@ -45,14 +45,22 @@ PAGE_WIDTH = 70
 
 
 class WizardExit(Exception):
+    """Exception used to exit the wizard"""
     pass
 
 
 class WizardInvalidData(Exception):
+    """Exception triggered when the user provided data are invalid"""
     pass
 
 
 class Wizard:
+    """Represents a dialog-based wizard
+
+    The wizard is a collection of pages that have a "Next" and a "Back" button
+    on them. The pages are used to collect user data.
+    """
+
     def __init__(self, session):
         self.session = session
         self.pages = []
@@ -60,9 +68,11 @@ class Wizard:
         self.d = session['dialog']
 
     def add_page(self, page):
+        """Add a new page to the wizard"""
         self.pages.append(page)
 
     def run(self):
+        """Run the wizard"""
         idx = 0
         while True:
             try:
@@ -95,6 +105,7 @@ class Wizard:
 
 
 class WizardPage(object):
+    """Represents a page in a wizard"""
     NEXT = 1
     PREV = -1
 
@@ -106,11 +117,15 @@ class WizardPage(object):
         setattr(self, "display", display)
 
     def run(self, session, index, total):
+        """Display this wizard page
+
+        This function is used by the wizard program when accessing a page.
+        """
         raise NotImplementedError
 
 
 class WizardRadioListPage(WizardPage):
-
+    """Represent a Radio List in a wizard"""
     def __init__(self, name, printable, message, choices, **kargs):
         super(WizardRadioListPage, self).__init__(**kargs)
         self.name = name
@@ -145,12 +160,13 @@ class WizardRadioListPage(WizardPage):
 
 
 class WizardInputPage(WizardPage):
-
+    """Represents an input field in a wizard"""
     def __init__(self, name, printable, message, **kargs):
         super(WizardInputPage, self).__init__(**kargs)
         self.name = name
         self.printable = printable
         self.message = message
+        self.info = "%s: <none>" % self.printable
         self.title = kargs['title'] if 'title' in kargs else ''
         self.init = kargs['init'] if 'init' in kargs else ''
 
@@ -173,7 +189,8 @@ class WizardInputPage(WizardPage):
         return self.NEXT
 
 
-def wizard(session):
+def start_wizard(session):
+    """Run the image creation wizard"""
     init_token = Kamaki.get_token()
     if init_token is None:
         init_token = ""
@@ -196,6 +213,7 @@ def wizard(session):
         title="Registration Type", default="Private")
 
     def validate_account(token):
+        """Check if a token is valid"""
         d = session['dialog']
 
         if len(token) == 0:
@@ -231,6 +249,7 @@ def wizard(session):
 
 
 def create_image(session):
+    """Create an image using the information collected by the wizard"""
     d = session['dialog']
     image = session['image']
     wizard = session['wizard']