coccigrep provides an abstraction for running spatch in the scope of searching for information in C source code.
There is two interesting classes:
- coccigrep.CocciGrep: main class that run the intensive task
- coccigrep.CocciGrepConfig: used to parse and get configuration value
To build a request:
- Create a coccigrep.CocciGrep instance
- Call coccigrep.CocciGrep.setup() function to setup the search
- Call coccigrep.CocciGrep.run() function to execute the search
- Call coccigrep.CocciGrep.display() function to display the output of the search
Exception raised when configuration parameter are not correct.
For example, it is returned if spatch command can not be found.
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
Parameters: |
|
---|---|
Returns: | 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 |
---|
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
Parameters: |
|
---|