Parcourir la source

docstrings

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-configuration@866 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen il y a 15 ans
Parent
commit
2143745c89

+ 0 - 1
src/lib/config/python/isc/config/config_test.in

@@ -17,4 +17,3 @@ ${PYTHON_EXEC} -O ${CONFIG_PATH}/config_data_test.py $*
 ${PYTHON_EXEC} -O ${CONFIG_PATH}/module_spec_test.py $*
 ${PYTHON_EXEC} -O ${CONFIG_PATH}/module_spec_test.py $*
 
 
 ${PYTHON_EXEC} -O ${CONFIG_PATH}/cfgmgr_test.py $*
 ${PYTHON_EXEC} -O ${CONFIG_PATH}/cfgmgr_test.py $*
-

+ 12 - 0
src/lib/config/python/isc/config/module_spec.py

@@ -25,9 +25,15 @@ import isc.cc.data
 # import that so we can check those types
 # import that so we can check those types
 
 
 class ModuleSpecError(Exception):
 class ModuleSpecError(Exception):
+    """This exception is raised it the ModuleSpec fails to initialize
+       or if there is a failure or parse error reading the specification
+       file"""
     pass
     pass
 
 
 def module_spec_from_file(spec_file, check = True):
 def module_spec_from_file(spec_file, check = True):
+    """Returns a ModuleSpec object defined by the file at spec_file.
+       If check is True, the contents are verified. If there is an error
+       in those contents, a ModuleSpecError is raised."""
     module_spec = None
     module_spec = None
     if hasattr(spec_file, 'read'):
     if hasattr(spec_file, 'read'):
         module_spec = ast.literal_eval(spec_file.read(-1))
         module_spec = ast.literal_eval(spec_file.read(-1))
@@ -44,6 +50,10 @@ def module_spec_from_file(spec_file, check = True):
 
 
 class ModuleSpec:
 class ModuleSpec:
     def __init__(self, module_spec, check = True):
     def __init__(self, module_spec, check = True):
+        """Initializes a ModuleSpec object from the specification in
+           the given module_spec (which must be a dict). If check is
+           True, the contents are verified. Raises a ModuleSpec error
+           if there is something wrong with the contents of the dict""".
         if type(module_spec) != dict:
         if type(module_spec) != dict:
             raise ModuleSpecError("module_spec is of type " + str(type(module_spec)) + ", not dict")
             raise ModuleSpecError("module_spec is of type " + str(type(module_spec)) + ", not dict")
         if check:
         if check:
@@ -65,6 +75,8 @@ class ModuleSpec:
 
 
 
 
     def get_module_name(self):
     def get_module_name(self):
+        """Returns a string containing the name of the module as
+           specified by the specification given at __init__"""
         return self._module_spec['module_name']
         return self._module_spec['module_name']
 
 
     def get_full_spec(self):
     def get_full_spec(self):