coccigrep provides an abstraction for running spatch in the scope of searching for information in C source code.
There is two interesting classes:
To build a request:
Exception raised when configuration parameter are not correct.
For example, it is returned if spatch command can not be found.
Generic class for coccigrep exception
Core class of the module: setup and run.
This class is the core of the module. It is responsible of initialisation and running of the request.
Add operation to the list of supported operations
|Parameters:||new_ops (list of str) – list of filenames (ending by .cocci)|
Display output for complete request
the result of the search as a str
Get list of available operations
|Returns:||list of operations in a list of str|
Run the search against the files given in argument
This function is doing the main job. It will run spatch with the correct parameters by using subprocess or it will use multiprocessing if a concurrency level greater than 1 has been asked.
|Parameters:||files (list of str) – list of filenames|
|Raise :||CocciRunException or CocciConfigException|
Set concurrency level (number of spatch command to run in parallel)
|Parameters:||ncpus (int) – number of process to launch in parallel|
Set path or command name for spatch
|Parameters:||cmd (str) – Name of parth of the spatch command|
Activate verbose mode
Configuration handling class
This class parses configuration and can be used to access to configuration item via get operations. CocciGrepConfig is derived from SafeConfigParser
Store a match and take care of its display
Display output for a single match
Class used for running spatch command in the case of multiprocessing
Exception raised when running parameters are not correct.
For example, it is returned if a required argument is missing.