Kwpyspec

The kwpyspec command creates a Python build specification based on the arguments you pass to it.

Prerequisites

Before you can create a build specification, you need to install the Server package. See Installing Klocwork.

In order to see any python-related issues, you need to import the provided python taxonomy ('py.base.tconf'). For more information, see Configuring industry-specific coding standards and checkers.

For more information, see Creating a Python build specification.

Usage

kwpyspec <options>

where <options> are any arguments required for your build.

You can also specify the 'kwpyspec.out' option file generated by kwpyspecimport:

kwpyspec @kwpyspec.opt

where 'kwpyspec.opt' is a file containing the arguments in separate lines. Below is an example of a 'kwpyspec.opt' file:

--py-version
python3
--ignore
CVS
--ignore-patterns
^\.#
C:\Desktop\python_project

Options

Name (and short name) Description
--help (-h) display help
--version display kwpyspec version
--output (-o) <file> specify your output build specification file. The default is 'kwpyspec.out'
--py-version <string> specify your python version. The default is python3.
--ignore <string> comma-separated list of files or directories you want to ignore. They must be base names, not paths.
--ignore-patterns <string>

comma-separated list of regex patterns you want to ignore. The regex matches against base names, not paths.

--ignore-paths <string>

comma-separated list of files or directories you want to ignore.

--plugins <string> comma-separated list of plugins (python modules names).
--extensions <string> comma-separated list of package or module names from where C extensions may be loaded
--django-settings-path <string> specify the module location of the settings for the pylint_django plugin
--python-path <string> set the python path to use while running the analysis
--list-plugins displays the list of supported plugins

Example

Let's look at how to use kwpyspec --ignore, --ignore-patterns, and --ignore-paths options for a project called "Django-poll-app", with the following project structure:

Django-poll-app      
  polls    
    migrations  
      init.py
    admin.py  
  accounts    
    views.py  
    forms.py  
  pollme    
    urls.py  

Example of --ignore option in which polls and accounts folders will be ignored:

Django-poll-app > kwpyspec -o kwpyspec.out --py-version python3 --ignore polls,accounts --plugins django accounts pollme polls polls\migrations

Example of --ignore-patterns option in which polls and pollme folders will be ignored:

Django-poll-app > kwpyspec -o kwpyspec.out --py-version python3 --ignore-patterns poll* --plugins django accounts pollme polls polls\migrations

Example of --ignore-paths option for Windows:

Django-poll-app > kwpyspec -o kwpyspec.out --py-version python3 --ignore-paths .*\polls,.*\accounts\views.py --plugins django accounts pollme polls polls\migrations

Example of --ignore-paths option for Linux:

Django-poll-app > kwpyspec -o kwpyspec.out --py-version python3 --ignore-paths .*/polls,.*/accounts/views.py --plugins django accounts pollme polls polls/migrations
If all directories have an __init__.py file, you do not need to pass the directories accounts pollme polls polls\migrations in the kwpyspec command.