Package licensechecker :: Module fileinfo :: Class FileChecker
[hide private]
[frames] | no frames]

Class FileChecker

source code

Class holding FileInfo instances related to a set of programming languages and file extensions.

Instance Methods [hide private]
 
__init__(self, filename='/home/mhoebeke/Devel/lichk/src/licensechecker/data/fileinfo.txt')
Builds a new instance of FileChecker from a text file containing descriptions of programming languages and file extensions.
source code
[string,]
getExtensions(self, filetype=None)
Returns the list of extensions for a given programming language, or all known file extensions.
source code
string
getTypeName(self, extension)
Returns the type name (programming language) for a given file extension.
source code
FileInfo
getFileInfo(self, filename)
Returns an instance of FileInfo given a filename.
source code
Method Details [hide private]

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

source code 

Builds a new instance of FileChecker from a text file containing descriptions of programming languages and file extensions.

The textfile must be formatted as follows:

  • blank lines or lines starting with # are ignored,
  • other lines are split in whitespace separated fields:
    • the first field contains an indentifier (case sensitive) for the programming language,
    • the remaining fields each contain a file extension related to the programming language.

Example:

 # Enumeration of file extensions for C++
 C++ .cc .C .cxx .cpp .h .hxx 
Parameters:
  • filename - a string with the filename containing the association between programming languages and file extensions. If no argument is given, the instance is built from the contents of the fileinfo.txt file located in the module's data subdirectory.

getExtensions(self, filetype=None)

source code 

Returns the list of extensions for a given programming language, or all known file extensions.

Parameters:
  • filetype - the programming language for which the file extensions will be returned (or None if all extensions are to be returned).
Returns: [string,]
a list with all the resulting file extensions.

getTypeName(self, extension)

source code 

Returns the type name (programming language) for a given file extension.

Parameters:
  • extension - a string containing the file extension (without the leading dot). An exception is raised if the extension is unknown.
Returns: string
the type (programming language) corresponding to the extension.

getFileInfo(self, filename)

source code 

Returns an instance of FileInfo given a filename.

Parameters:
  • filename - a string containing a filename.
Returns: FileInfo
an instance of FileInfo looked up from the extension of the given filename. An exception occurs if no mathing FileInfo is found.