kwalitee package¶
Subpackages¶
Submodules¶
kwalitee.config module¶
kwalitee base configuration.
To change it, put a config.py into your instance.
- kwalitee.config.CONTEXT¶
Context for Github.
See also
- kwalitee.config.COMPONENTS¶
List of supported components.
See also
- kwalitee.config.ACCESS_TOKEN¶
Github access token. Used to post statuses and comments. It MUST be set.
- kwalitee.config.AUTO_CREATE¶
Allow anyone to add its repository by setting up the webhook on Github.
Default: False
- kwalitee.config.CHECK_COMMIT_MESSAGES¶
Enable the commit message checks.
Default: True
- kwalitee.config.CHECK_WIP¶
Enable the work-in-progress pull requests checks. Disabled by default.
Default: False
- kwalitee.config.CHECK_LICENSE¶
Enable the license checks.
Default: True
- kwalitee.config.CHECK_PEP8¶
Enable the PEP8 checks.
Default: True
- kwalitee.config.CHECK_PEP257¶
Enable the PEP257 checks.
Default: True
- kwalitee.config.CHECK_PYFLAKES¶
Enable the PyFlakes checks. PEP8 checks are required.
Default: True
- kwalitee.config.IGNORE¶
Error codes to ignore.
Default: ['E123', 'E226', 'E24', 'E501', 'E265']
- kwalitee.config.SELECT¶
Error codes to specially enable.
Default: []
- kwalitee.config.WORKER_TIMEOUT¶
Background worker job time window.
Any job taking longer than that will be killed.
RQ default timeout is 180 seconds
- kwalitee.config.MIN_REVIEWERS¶
Minimum number of reviewers for py:func:message check <.kwalitee.check_message>.
Default: 3
- kwalitee.config.LABEL_WIP¶
Label to apply for a work-in-progress pull request.
Default: "in_work"
- kwalitee.config.LABEL_REVIEW¶
Label to apply for a pull request that needs more reviewers.
Default: "in_review"
- kwalitee.config.LABEL_READY¶
Label to apply for a pull request that passes all the checks.
Default: "in_integration"
- kwalitee.config.ALT_SIGNATURES = ('Reported-by',)¶
Alternative signatures recognized but not counted as reviewers.
- kwalitee.config.COMMIT_MSG_TEMPLATE = '{component}: description (max 50 chars, using nouns)\n\n* Detailed description formatted as a bullet list (using present tense).\n\nSigned-off-by: {author}\n{extra}'¶
Template used to generate the commit message from the git hook.
- kwalitee.config.GITHUB = 'https://github.com/'¶
Github base URL.
- kwalitee.config.GITHUB_REPO = 'https://github.com/{account}/{repository}/'¶
Github repository URL template.
- kwalitee.config.HOOK_TEMPLATE = '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\nfrom kwalitee import create_app\nfrom kwalitee.hooks import {hook}\n\nif __name__ == "__main__":\n with create_app().app_context():\n sys.exit({hook}(sys.argv))\n'¶
Template used to generate the git hooks, customize at will.
- kwalitee.config.PEP257_MATCH = '(?!test_).*\\.py'¶
Files checked for PEP257 conformance.
- kwalitee.config.PEP257_MATCH_DIR = '[^\\.].*'¶
Directories checkes for PEP257 conformance.
- kwalitee.config.SIGNATURES = ('Signed-off-by', 'Co-authored-by', 'Tested-by', 'Reviewed-by', 'Acked-by')¶
Authors and reviewers signatures.
- kwalitee.config.TRUSTED_DEVELOPERS = []¶
Super developers who’s code never fail.
kwalitee.factory module¶
kwalitee factory for Flask application.
- class kwalitee.factory.ShaConverter(map)[source]¶
Bases: werkzeug.routing.BaseConverter
Werkzeug routing converter for sha-1 (truncated or full).
- regex = u'(?!/)(?:[a-fA-F0-9]{40}|[a-fA-F0-9]{7})'¶
- weight = 150¶
kwalitee.hooks module¶
Git hooks.
kwalitee.kwalitee module¶
Kwalitee checks for PEP8, PEP257, PyFlakes and License.
- kwalitee.kwalitee.SUPPORTED_FILES = (u'.py', u'.html', u'.tpl', u'.js', u'.jsx', u'.css', u'.less')¶
Supported file types.
- kwalitee.kwalitee.check_file(filename, **kwargs)[source]¶
Perform static analysis on the given file.
See also
Parameters: filename (str) – path of file to check. Returns: errors sorted by line number Return type: list
- kwalitee.kwalitee.check_license(filename, **kwargs)[source]¶
Perform a license check on the given file.
The license format should be commented using # and live at the top of the file. Also, the year should be the current one.
Parameters: Returns: errors
Return type: list
- kwalitee.kwalitee.check_message(message, **kwargs)[source]¶
Check the message format.
Rules:
- the first line must start by a component name
- and a short description (52 chars),
- then bullet points are expected
- and finally signatures.
Parameters: - components (list) – compontents, e.g. ('auth', 'utils', 'misc')
- signatures (list) – signatures, e.g. ('Signed-off-by', 'Reviewed-by')
- alt_signatures (list) – alternative signatures, e.g. ('Tested-by',)
- trusted (list) – optional list of reviewers, e.g. ('john.doe@foo.org',)
- max_length (int) – optional maximum line length (by default: 72)
- max_first_line (int) – optional maximum first line length (by default: 50)
- allow_empty (bool) – optional way to allow empty message (by default: False)
Returns: errors sorted by line number
Return type: list
- kwalitee.kwalitee.check_pep257(filename, **kwargs)[source]¶
Perform static analysis on the given file docstrings.
Parameters: Returns: errors
Return type: list
See also
- kwalitee.kwalitee.check_pep8(filename, **kwargs)[source]¶
Perform static analysis on the given file.
Parameters: Returns: errors
Return type: list
See also
kwalitee.models module¶
Database models to persist the data over time.
- class kwalitee.models.Account(name, email=None, token=None)[source]¶
Bases: flask_sqlalchemy.Model
Github account.
- created_at¶
Date of creation.
- email¶
Email.
- id¶
Identifier
- name¶
Username.
- token¶
API Token.
- updated_at¶
Date of last modification.
- class kwalitee.models.BranchStatus(commit, name, url, content=None)[source]¶
Bases: flask_sqlalchemy.Model
Status of a pull request.
- commit¶
- commit_id¶
- content¶
Get the content of the status.
- created_at¶
- classmethod find_or_create(commit, name, url, content=None)[source]¶
Find or create a commit status.
- id¶
- name¶
- updated_at¶
- url¶
- class kwalitee.models.CommitStatus(repository, sha, url, content=None)[source]¶
Bases: flask_sqlalchemy.Model
Status of a push.
- content¶
Get the content of the status.
- created_at¶
- id¶
- repository¶
- repository_id¶
- sha¶
- updated_at¶
- url¶
kwalitee.tasks module¶
Tasks to run on the worker.
- kwalitee.tasks.get_headers(repository, config)[source]¶
Get the HTTP headers for the GitHub api.
This is required to post comments on GitHub on your behalf. Please update your configuration accordingly.
ACCESS_TOKEN = "deadbeef..."
It can also be overwritten per user.
$ kwalitee account add username --token=deadbeef...
Returns: HTTP headers Return type: dict
kwalitee.views module¶
Views like in MTV.
- kwalitee.views.account(account)[source]¶
Display the repositories linked with one account.
Parameters: account – name of the account
- kwalitee.views.branch(account, repository, branch)[source]¶
Display the statuses of a branch.
Parameters: - account – name of the owner
- repository – name of the repository
- branch – name of the branch
- kwalitee.views.branch_status(account, repository, branch, sha)[source]¶
Display the status of a pull request.
Parameters: - account – name of the owner
- repository – name of the repository
- branch – name of the branch
- sha – commit identifier of the commit related with the branch
- kwalitee.views.commit(account, repository, sha)[source]¶
Display the status of a commit.
Parameters: - account – name of the owner
- repository – name of the repository
- sha – identifier of the commit
- kwalitee.views.payload()[source]¶
Handle the GitHub events.
See also
Event Types <https://developer.github.com/v3/activity/events/types/>
kwalitee.worker module¶
Initialize Redis and setups the RQ worker.
kwalitee.wsgi module¶
WSGI application with debug middleware if in debug mode.