Package licensechecker :: Module commentinfo :: Class CommentChecker
[hide private]
[frames] | no frames]

Class CommentChecker

source code

Class containing comment information about all known programming languages.


Note: this class may be given a more meaningful name if it turns out that the actual check for the license conformity is performed elsewhere.

Instance Methods [hide private]
 
__init__(self, filename='/home/mhoebeke/Devel/lichk/src/licensechecker/data/commentinf...)
Builds a new instance of CommentChecker from a text file containing comment information.
source code
CommentInfo
getCommentInfo(self, typename)
Return comment info about a given programming language.
source code
{string:CommentInfo,}
getAllCommentInfo(self)
Return comment info about all known programming languages.
source code
[string,]
getAllTypeNames(self)
Return the names of all known programming languages.
source code
Class Variables [hide private]
  __logger = logging.getLogger('lichk')
Method Details [hide private]

__init__(self, filename='/home/mhoebeke/Devel/lichk/src/licensechecker/data/commentinf...)
(Constructor)

source code 

Builds a new instance of CommentChecker from a text file containing comment information.

The text file must be formatted as follows:

  • blank lines or lines starting with # are ignored,
  • other lines must have 2, 3 or 4 whitespace separated fields :
    • the first field is a string with the name of the programming language (case sensitive),
    • for lines with 2 fields, the second field is the delimiter for single-line comments,
    • for lines with 3 fields, the second (resp. third field) is the opening (resp. closing) delimiter for comment blocks,
    • for lines with 4 fields, the three first fields are the same as in a 3-field line, the 4th field is the delimiter for single-line comments.

Examples:

 # The following line declares Shell-type comments (single-line comments)
 shell #
 # The following line declares Java-type comments (both block and single-line)
 Java /* */ //
Parameters:
  • filename - (optional) the name of the file with the comment information. The default value looks for a file named commentinfo.txt in this module's data subdirectory.

Note: there may be multiple lines related to a single programming language in the same file. Each line adds new delimiters those already encountered. Example:

 # First pair of delimiters for Pascal comment blocks.
 Pascal (* *)
 # Second pair of delimiters for Pascal comment blocks.
 Pascal { }

getCommentInfo(self, typename)

source code 

Return comment info about a given programming language.

Parameters:
  • typename - the name of the programming language (string)
Returns: CommentInfo
an instance of CommentInfo if the typename is known (or None).

getAllCommentInfo(self)

source code 

Return comment info about all known programming languages.

Returns: {string:CommentInfo,}
all known CommentInfo instances in the form of a dictionary whose keys are the names of the programming languages, and whose values are CommentInfo instances.

getAllTypeNames(self)

source code 

Return the names of all known programming languages.

Returns: [string,]
an array of strings containing the names of all known programming languages.