[svn] commit: r2899 - in /branches/trac322/src/lib/python/isc/bind10: rename.py tests/rename.py

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Sep 9 18:18:34 UTC 2010


Author: vorner
Date: Thu Sep  9 18:18:33 2010
New Revision: 2899

Log:
Documentation

Modified:
    branches/trac322/src/lib/python/isc/bind10/rename.py
    branches/trac322/src/lib/python/isc/bind10/tests/rename.py

Modified: branches/trac322/src/lib/python/isc/bind10/rename.py
==============================================================================
--- branches/trac322/src/lib/python/isc/bind10/rename.py (original)
+++ branches/trac322/src/lib/python/isc/bind10/rename.py Thu Sep  9 18:18:33 2010
@@ -1,7 +1,12 @@
+"""Module with renaming function."""
 import setproctitle
 import sys
 import os.path
 
+"""
+Rename the current process to given name (so it can be found in ps).
+If name is None, use zero'th command line argument.
+"""
 def rename(name = None):
     if name is None:
         name = os.path.basename(sys.argv[0])

Modified: branches/trac322/src/lib/python/isc/bind10/tests/rename.py
==============================================================================
--- branches/trac322/src/lib/python/isc/bind10/tests/rename.py (original)
+++ branches/trac322/src/lib/python/isc/bind10/tests/rename.py Thu Sep  9 18:18:33 2010
@@ -1,3 +1,4 @@
+"""Tests for isc.bind10.rename."""
 import unittest
 import os
 import os.path
@@ -5,27 +6,34 @@
 import isc.bind10.rename
 import re
 
+"""Testcase for isc.bind10.rename."""
 class TestRename(unittest.TestCase):
     def __get_self_name(self):
         return setproctitle.getproctitle()
 
-    # This tests if the renaming works
     def test_rename(self):
+        """Test if the renaming function works."""
         isc.bind10.rename.rename("rename-test")
         self.assertEqual("rename-test", self.__get_self_name())
         isc.bind10.rename.rename()
         self.assertEqual("rename.py", self.__get_self_name())
 
-    # Scan one script if it contains call to the renaming function
     def __scan(self, directory, script, fun, repl):
+        # Scan one script if it contains call to the renaming function
         filename = os.path.join(directory, script)
         data = ''.join(open(filename).readlines())
         prettyname = 'src' + filename[filename.rfind('../') + 2:]
         self.assert_(fun.search(data),
             "Didn't find a call to isc.bind10.rename.rename in " + prettyname)
 
-    # This finds all python scripts and tries to find if they call the function
     def test_calls(self):
+        """
+        Test if every script renames itself.
+
+        Scan all Makefile.am and look for scripts.
+        Then scan them by looking at the source text
+        (without actually running them)
+        """
         # I miss perl here little bit...
         lines = re.compile('^\\w+_SCRIPTS\\s*=\\s*((.|\\\\\\n)*)$',
             re.MULTILINE)
@@ -33,6 +41,7 @@
         fun = re.compile('^\s*isc\.bind10\.rename\.rename\s*\(.*\)\s*(|#.*)$',
             re.MULTILINE)
         repl = re.compile('(../)*')
+
         # Find all Makefile.am and extract names of scripts
         for (d, _, fs) in os.walk('../../../../../', followlinks = True):
             if 'Makefile.am' in fs:




More information about the bind10-changes mailing list