提交 af3cf998 编写于 作者: G gongzt

命令行工具的开发和pylint代码代码检查的通用配置

上级 df066c06
'''
Entry method for custom commands
'''
import os
import json
try:
import argparse
import requests
from requests.exceptions import ConnectionError as ConnErr
from requests.exceptions import HTTPError
import prettytable
from prettytable import PrettyTable
from packageship.libs.log import Log
from packageship.libs.exception import Error
from packageship.libs.configutils.readconfig import ReadConfig
LOGGER = Log(__name__)
except ImportError as import_error:
print('Error importing related dependencies, \
please check if related dependencies are installed')
else:
from packageship.application.apps.package.function.Constants import ResponseCode
from packageship.application.apps.package.function.Constants import ListNode
DB_NAME = 0
def main():
'''
command entry function
'''
try:
packship_cmd = PkgshipCommand()
packship_cmd.parser_args()
except Error as error:
LOGGER.logger.error(error)
print('command error')
class BaseCommand():
'''
Basic attributes used for command invocation
'''
def __init__(self):
self._read_config = ReadConfig()
self.write_host = None
self.read_host = None
self.__http = 'http://'
self.headers = {"Content-Type": "application/json",
"Accept-Language": "zh-CN,zh;q=0.9"}
self.load_read_host()
self.load_write_host()
def load_write_host(self):
'''
Address to load write permission
'''
wirte_port = self._read_config.get_system('write_port')
write_ip = self._read_config.get_system('write_ip_addr')
_write_host = self.__http + write_ip + ":" + wirte_port
setattr(self, 'write_host', _write_host)
def load_read_host(self):
'''
Address to load write permission
'''
read_port = self._read_config.get_system('query_port')
read_ip = self._read_config.get_system('query_ip_addr')
_read_host = self.__http + read_ip + ":" + read_port
setattr(self, 'read_host', _read_host)
class PkgshipCommand(BaseCommand):
'''
PKG package command line
'''
parser = argparse.ArgumentParser(
description='package related dependency management')
subparsers = parser.add_subparsers(
help='package related dependency management')
def __init__(self):
super(PkgshipCommand, self).__init__()
self.statistics = dict()
self.table = PkgshipCommand.create_table(
['package name', 'src name', 'version', 'database'])
# Calculate the total width of the current terminal
self.columns = int(os.popen('stty size', 'r').read().split()[1])
self.params = []
@staticmethod
def register_command(command):
'''
Register command
'''
command.register()
def register(self):
'''
Command line parameter injection
'''
for command_params in self.params:
self.parse.add_argument( # pylint: disable=E1101
command_params[0],
type=eval(command_params[1]), # pylint: disable=W0123
help=command_params[2],
default=command_params[3])
@classmethod
def parser_args(cls):
'''
Command parsing
'''
cls.register_command(RemoveCommand())
cls.register_command(InitDatabaseCommand())
cls.register_command(UpdateDatabaseCommand())
cls.register_command(AllPackageCommand())
cls.register_command(UpdatePackageCommand())
cls.register_command(BuildDepCommand())
cls.register_command(InstallDepCommand())
cls.register_command(SelfBuildCommand())
cls.register_command(BeDependCommand())
cls.register_command(SingleCommand())
try:
args = cls.parser.parse_args()
args.func(args)
except Error:
print('command error')
def parse_package(self, response_data):
'''
Parse the corresponding data of the package
'''
if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data')
if isinstance(package_all, list):
for package_item in package_all:
row_data = [package_item.get('sourceName'), package_item.get(
'dbname'), package_item.get('version'), package_item.get('license')]
self.table.add_row(row_data)
else:
print(response_data.get('msg'))
def parse_depend_package(self, response_data):
'''
Parse the corresponding data of the package
'''
bin_package_count = 0
src_package_count = 0
if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data')
if isinstance(package_all, dict):
for bin_package, package_depend in package_all.items():
# distinguish whether the current data is the data of the root node
if isinstance(package_depend, list) and \
package_depend[ListNode.SOURCE_NAME] != 'source':
row_data = [bin_package,
package_depend[ListNode.SOURCE_NAME],
package_depend[ListNode.VERSION],
package_depend[ListNode.DBNAME]]
# Whether the database exists
if package_depend[ListNode.DBNAME] not in self.statistics:
self.statistics[package_depend[ListNode.DBNAME]] = {
'binary': [],
'source': []
}
# Determine whether the current binary package exists
if bin_package not in \
self.statistics[package_depend[ListNode.DBNAME]]['binary']:
self.statistics[package_depend[ListNode.DBNAME]
]['binary'].append(bin_package)
bin_package_count += 1
# Determine whether the source package exists
if package_depend[ListNode.SOURCE_NAME] not in \
self.statistics[package_depend[ListNode.DBNAME]]['source']:
self.statistics[package_depend[ListNode.DBNAME]]['source'].append(
package_depend[ListNode.SOURCE_NAME])
src_package_count += 1
if hasattr(self, 'table') and self.table:
self.table.add_row(row_data)
else:
LOGGER.logger.error(response_data.get('msg'))
print(response_data.get('msg'))
statistics_table = self.statistics_table(
bin_package_count, src_package_count)
return statistics_table
def print_(self, content=None, character='=', dividing_line=False):
'''
Output formatted characters
'''
# Get the current width of the console
if dividing_line:
print(character * self.columns)
if content:
print(content)
if dividing_line:
print(character * self.columns)
@staticmethod
def create_table(title):
'''
Create printed forms
'''
table = PrettyTable(title)
# table.set_style(prettytable.PLAIN_COLUMNS)
table.align = 'l'
table.horizontal_char = '='
table.junction_char = '='
table.vrules = prettytable.NONE
table.hrules = prettytable.FRAME
return table
def statistics_table(self, bin_package_count, src_package_count):
'''
Generate data for total statistical tables
'''
statistics_table = self.create_table(['', 'binary', 'source'])
statistics_table.add_row(
['self depend sum', bin_package_count, src_package_count])
# cyclically count the number of source packages and binary packages in each database
for database, statistics_item in self.statistics.items():
statistics_table.add_row([database, len(statistics_item.get(
'binary')), len(statistics_item.get('source'))])
return statistics_table
@staticmethod
def http_error(response):
'''
Log error messages for http
'''
try:
print(response.raise_for_status())
except HTTPError as http_error:
LOGGER.logger.error(http_error)
print('Request failed')
print(http_error)
class RemoveCommand(PkgshipCommand):
'''
Delete database command
'''
def __init__(self):
super(RemoveCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'rm', help='delete database operation')
self.params = [('db', 'str', 'name of the database operated', '')]
def register(self):
'''
Command line parameter injection
'''
super(RemoveCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
if params.db is None:
print('No database specified for deletion')
else:
_url = self.write_host + '/repodatas?dbName={}'.format(params.db)
try:
response = requests.delete(_url)
except ConnErr as conn_err:
LOGGER.logger.error(conn_err)
print(str(conn_err))
else:
# Determine whether to delete the mysql database or sqlite database
if response.status_code == 200:
data = json.loads(response.text)
if data.get('code') == ResponseCode.SUCCESS:
print('delete success')
else:
LOGGER.logger.error(data.get('msg'))
print(data.get('msg'))
else:
self.http_error(response)
class InitDatabaseCommand(PkgshipCommand):
'''
Initialize database command
'''
def __init__(self):
super(InitDatabaseCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'init', help='initialization of the database')
self.params = [
('-filepath', 'str', 'name of the database operated', '')]
def register(self):
'''
Command line parameter injection
'''
super(InitDatabaseCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
file_path = params.filepath
try:
response = requests.post(self.write_host +
'/initsystem', data=json.dumps({'configfile': file_path}),
headers=self.headers)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
response_data = json.loads(response.text)
if response_data.get('code') == ResponseCode.SUCCESS:
print('Database initialization success ')
else:
LOGGER.logger.error(response_data.get('msg'))
print(response_data.get('msg'))
else:
self.http_error(response)
class UpdateDatabaseCommand(PkgshipCommand):
'''
update database command
'''
def __init__(self):
super(UpdateDatabaseCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'updatedb', help='database update operation')
self.params = [('db', 'str', 'name of the database operated', '')]
def register(self):
'''
Command line parameter injection
'''
super(UpdateDatabaseCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
pass # pylint: disable= W0107
class AllPackageCommand(PkgshipCommand):
'''
get all package commands
'''
def __init__(self):
super(AllPackageCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'list', help='get all package data')
self.table = self.create_table(
['packagenames', 'database', 'version', 'license'])
self.params = [('-db', 'str', 'name of the database operated', '')]
def register(self):
'''
Command line parameter injection
'''
super(AllPackageCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
_url = self.read_host + \
'/packages?dbName={dbName}'.format(dbName=params.db)
try:
response = requests.get(_url)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
self.parse_package(json.loads(response.text))
if self.table:
print(self.table)
else:
self.http_error(response)
class UpdatePackageCommand(PkgshipCommand):
'''
update package data
'''
def __init__(self):
super(UpdatePackageCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'updatepkg', help='update package data')
self.params = [
('packagename', 'str', 'Source package name', ''),
('db', 'str', 'name of the database operated', ''),
('-m', 'str', 'Maintainers name', ''),
('-l', 'int', 'database priority', 1)
]
def register(self):
'''
Command line parameter injection
'''
super(UpdatePackageCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
_url = self.write_host + '/packages/findByPackName'
try:
response = requests.put(
_url, data=json.dumps({'sourceName': params.packagename,
'dbName': params.db,
'maintainer': params.m,
'maintainLevel': params.l}),
headers=self.headers)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
data = json.loads(response.text)
if data.get('code') == ResponseCode.SUCCESS:
print('update completed')
else:
LOGGER.logger.error(data.get('msg'))
print(data.get('msg'))
else:
self.http_error(response)
class BuildDepCommand(PkgshipCommand):
'''
query the compilation dependencies of the specified package
'''
def __init__(self):
super(BuildDepCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'builddep', help='query the compilation dependencies of the specified package')
self.collection = True
self.params = [
('packagename', 'str', 'source package name', ''),
]
self.collection_params = [
('-dbs', 'Operational database collection')
]
def register(self):
'''
Command line parameter injection
'''
super(BuildDepCommand, self).register()
# collection parameters
for cmd_params in self.collection_params:
self.parse.add_argument(
cmd_params[0], nargs='*', default=None, help=cmd_params[1])
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
_url = self.read_host + '/packages/findBuildDepend'
try:
response = requests.post(
_url, data=json.dumps({'sourceName': params.packagename,
'db_list': params.dbs}),
headers=self.headers)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
statistics_table = self.parse_depend_package(
json.loads(response.text))
if getattr(self.table, 'rowcount'):
self.print_('query {} buildDepend result display:'.format(
params.packagename))
print(self.table)
self.print_('statistics')
print(statistics_table)
else:
self.http_error(response)
class InstallDepCommand(PkgshipCommand):
'''
query the installation dependencies of the specified package
'''
def __init__(self):
super(InstallDepCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'installdep', help='query the installation dependencies of the specified package')
self.collection = True
self.params = [
('packagename', 'str', 'source package name', ''),
]
self.collection_params = [
('-dbs', 'Operational database collection')
]
def register(self):
'''
Command line parameter injection
'''
super(InstallDepCommand, self).register()
# collection parameters
for cmd_params in self.collection_params:
self.parse.add_argument(
cmd_params[0], nargs='*', default=None, help=cmd_params[1])
self.parse.set_defaults(func=self.do_command)
def parse_package(self, response_data):
'''
Parse the corresponding data of the package
'''
if getattr(self, 'statistics'):
setattr(self, 'statistics', dict())
bin_package_count = 0
src_package_count = 0
if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data')
if isinstance(package_all, dict):
for bin_package, package_depend in package_all.items():
# distinguish whether the current data is the data of the root node
if isinstance(package_depend, list) and package_depend[-1][0][0] != 'root':
row_data = [bin_package,
package_depend[ListNode.SOURCE_NAME],
package_depend[ListNode.VERSION],
package_depend[ListNode.DBNAME]]
# Whether the database exists
if package_depend[ListNode.DBNAME] not in self.statistics:
self.statistics[package_depend[ListNode.DBNAME]] = {
'binary': [],
'source': []
}
# Determine whether the current binary package exists
if bin_package not in \
self.statistics[package_depend[ListNode.DBNAME]]['binary']:
self.statistics[package_depend[ListNode.DBNAME]
]['binary'].append(bin_package)
bin_package_count += 1
# Determine whether the source package exists
if package_depend[ListNode.SOURCE_NAME] not in \
self.statistics[package_depend[ListNode.DBNAME]]['source']:
self.statistics[package_depend[ListNode.DBNAME]]['source'].append(
package_depend[ListNode.SOURCE_NAME])
src_package_count += 1
self.table.add_row(row_data)
else:
LOGGER.logger.error(response_data.get('msg'))
print(response_data.get('msg'))
# Display of aggregated data
statistics_table = self.statistics_table(
bin_package_count, src_package_count)
return statistics_table
def do_command(self, params):
'''
Action to execute command
'''
_url = self.read_host + '/packages/findInstallDepend'
try:
response = requests.post(_url, data=json.dumps(
{
'binaryName': params.packagename,
'db_list': params.dbs
}, ensure_ascii=True), headers=self.headers)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
statistics_table = self.parse_package(
json.loads(response.text))
if getattr(self.table, 'rowcount'):
self.print_('query{} InstallDepend result display:'.format(
params.packagename))
print(self.table)
self.print_('statistics')
print(statistics_table)
else:
self.http_error(response)
class SelfBuildCommand(PkgshipCommand):
'''
self-compiled dependency query
'''
def __init__(self):
super(SelfBuildCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'selfbuild', help='query the self-compiled dependencies of the specified package')
self.collection = True
self.bin_package_table = self.create_table(
['package name', 'src name', 'version', 'database'])
self.src_package_table = self.create_table([
'src name', 'version', 'database'])
self.params = [
('packagename', 'str', 'source package name', ''),
('-t', 'str', 'Source of data query', 'binary'),
('-w', 'str', 'whether to include other subpackages of binary', 0),
('-s', 'str', 'whether it is self-compiled', 0)
]
self.collection_params = [
('-dbs', 'Operational database collection')
]
def register(self):
'''
Command line parameter injection
'''
super(SelfBuildCommand, self).register()
# collection parameters
for cmd_params in self.collection_params:
self.parse.add_argument(
cmd_params[0], nargs='*', default=None, help=cmd_params[1])
self.parse.set_defaults(func=self.do_command)
def _parse_bin_package(self, bin_packages):
'''
Parsing binary result data
'''
bin_package_count = 0
if bin_packages:
for bin_package, package_depend in bin_packages.items():
# distinguish whether the current data is the data of the root node
if isinstance(package_depend, list) and package_depend[-1][0][0] != 'root':
row_data = [bin_package, package_depend[ListNode.SOURCE_NAME],
package_depend[ListNode.VERSION], package_depend[ListNode.DBNAME]]
# Whether the database exists
if package_depend[ListNode.DBNAME] not in self.statistics:
self.statistics[package_depend[ListNode.DBNAME]] = {
'binary': [],
'source': []
}
# Determine whether the current binary package exists
if bin_package not in \
self.statistics[package_depend[ListNode.DBNAME]]['binary']:
self.statistics[package_depend[ListNode.DBNAME]
]['binary'].append(bin_package)
bin_package_count += 1
self.bin_package_table.add_row(row_data)
return bin_package_count
def _parse_src_package(self, src_apckages):
'''
Source package data analysis
'''
src_package_count = 0
if src_apckages:
for src_package, package_depend in src_apckages.items():
# distinguish whether the current data is the data of the root node
if isinstance(package_depend, list):
row_data = [src_package, package_depend[ListNode.VERSION],
package_depend[DB_NAME]]
# Whether the database exists
if package_depend[DB_NAME] not in self.statistics:
self.statistics[package_depend[DB_NAME]] = {
'binary': [],
'source': []
}
# Determine whether the current binary package exists
if src_package not in self.statistics[package_depend[DB_NAME]]['source']:
self.statistics[package_depend[DB_NAME]
]['source'].append(src_package)
src_package_count += 1
self.src_package_table.add_row(row_data)
return src_package_count
def parse_package(self, response_data):
'''
Parse the corresponding data of the package
'''
if getattr(self, 'statistics'):
setattr(self, 'statistics', dict())
bin_package_count = 0
src_package_count = 0
if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data')
if isinstance(package_all, dict):
# Parsing binary result data
bin_package_count = self._parse_bin_package(
package_all.get('binary_dicts'))
# Source package data analysis
src_package_count = self._parse_src_package(
package_all.get('source_dicts'))
else:
LOGGER.logger.error(response_data.get('msg'))
print(response_data.get('msg'))
# Display of aggregated data
statistics_table = self.statistics_table(
bin_package_count, src_package_count)
# return (bin_package_table, src_package_table, statistics_table)
return statistics_table
def do_command(self, params):
'''
Action to execute command
'''
_url = self.read_host + '/packages/findSelfDepend'
try:
response = requests.post(_url,
data=json.dumps({
'packagename': params.packagename,
'db_list': params.dbs,
'packtype': params.t,
'selfbuild': str(params.s),
'withsubpack': str(params.w)}),
headers=self.headers)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
statistics_table = self.parse_package(
json.loads(response.text))
if getattr(self.bin_package_table, 'rowcount') \
and getattr(self.src_package_table, 'rowcount'):
self.print_('query {} selfDepend result display :'.format(
params.packagename))
print(self.bin_package_table)
self.print_(character='=')
print(self.src_package_table)
self.print_('statistics')
print(statistics_table)
else:
self.http_error(response)
class BeDependCommand(PkgshipCommand):
'''
dependent query
'''
def __init__(self):
super(BeDependCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'bedepend', help='dependency query for the specified package')
self.params = [
('packagename', 'str', 'source package name', ''),
('db', 'str', 'name of the database operated', ''),
('-w', 'str', 'whether to include other subpackages of binary', 0),
]
def register(self):
'''
Command line parameter injection
'''
super(BeDependCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def do_command(self, params):
'''
Action to execute command
'''
_url = self.read_host + '/packages/findBeDepend'
try:
response = requests.post(_url, data=json.dumps(
{
'packagename': params.packagename,
'dbname': params.db,
'withsubpack': str(params.w)
}
), headers=self.headers)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
statistics_table = self.parse_depend_package(
json.loads(response.text))
if getattr(self.table, 'rowcount'):
self.print_('query {} beDepend result display :'.format(
params.packagename))
print(self.table)
self.print_('statistics')
print(statistics_table)
else:
self.http_error(response)
class SingleCommand(PkgshipCommand):
'''
query single package information
'''
def __init__(self):
super(SingleCommand, self).__init__()
self.parse = PkgshipCommand.subparsers.add_parser(
'single', help='query the information of a single package')
self.params = [
('packagename', 'str', 'source package name', ''),
('-db', 'str', 'name of the database operated', '')
]
def register(self):
'''
Command line parameter injection
'''
super(SingleCommand, self).register()
self.parse.set_defaults(func=self.do_command)
def parse_package(self, response_data):
'''
Parse the corresponding data of the package
'''
show_field_name = ('sourceName', 'dbname', 'version',
'license', 'maintainer', 'maintainlevel')
print_contents = []
if response_data.get('code') == ResponseCode.SUCCESS:
package_all = response_data.get('data')
if isinstance(package_all, list):
for package_item in package_all:
for key, value in package_item.items():
if value is None:
value = ''
if key in show_field_name:
line_content = '%-15s:%s' % (key, value)
print_contents.append(line_content)
print_contents.append('='*self.columns)
else:
print(response_data.get('msg'))
if print_contents:
for content in print_contents:
self.print_(content=content)
def do_command(self, params):
'''
Action to execute command
'''
_url = self.read_host + \
'/packages/findByPackName?dbName={db_name}&sourceName={packagename}' \
.format(db_name=params.db, packagename=params.packagename)
try:
response = requests.get(_url)
except ConnectionError as conn_error:
LOGGER.logger.error(conn_error)
print(str(conn_error))
else:
if response.status_code == 200:
self.parse_package(json.loads(response.text))
else:
self.http_error(response)
if __name__ == '__main__':
main()
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=1
# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
limit-inference-results=100
# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# Specify a configuration file.
#rcfile=
# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
confidence=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape,
attribute-defined-outside-init
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member
[REPORTS]
# Python expression which should return a score less than or equal to 10. You
# have access to the variables 'error', 'warning', 'refactor', and 'convention'
# which contain the number of messages in each category, as well as 'statement'
# which is the total number of statements analyzed. This score is used by the
# global evaluation report (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
#msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
output-format=text
# Tells whether to display a full report or only the messages.
reports=no
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=sys.exit
[BASIC]
# Naming style matching correct argument names.
argument-naming-style=snake_case
# Regular expression matching correct argument names. Overrides argument-
# naming-style.
#argument-rgx=
# Naming style matching correct attribute names.
attr-naming-style=snake_case
# Regular expression matching correct attribute names. Overrides attr-naming-
# style.
#attr-rgx=
# Bad variable names which should always be refused, separated by a comma.
bad-names=foo,
bar,
baz,
toto,
tutu,
tata
# Naming style matching correct class attribute names.
class-attribute-naming-style=any
# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style.
#class-attribute-rgx=
# Naming style matching correct class names.
class-naming-style=PascalCase
# Regular expression matching correct class names. Overrides class-naming-
# style.
#class-rgx=
# Naming style matching correct constant names.
const-naming-style=UPPER_CASE
# Regular expression matching correct constant names. Overrides const-naming-
# style.
#const-rgx=
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming style matching correct function names.
function-naming-style=snake_case
# Regular expression matching correct function names. Overrides function-
# naming-style.
#function-rgx=
# Good variable names which should always be accepted, separated by a comma.
good-names=i,
j,
k,
ex,
Run,
_
# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
# Naming style matching correct inline iteration names.
inlinevar-naming-style=any
# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style.
#inlinevar-rgx=
# Naming style matching correct method names.
method-naming-style=snake_case
# Regular expression matching correct method names. Overrides method-naming-
# style.
#method-rgx=
# Naming style matching correct module names.
module-naming-style=snake_case
# Regular expression matching correct module names. Overrides module-naming-
# style.
#module-rgx=
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty
# Naming style matching correct variable names.
variable-naming-style=snake_case
# Regular expression matching correct variable names. Overrides variable-
# naming-style.
#variable-rgx=
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module.
max-module-lines=1000
# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[LOGGING]
# Format style used to check logging format string. `old` means using %
# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings.
logging-format-style=old
# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
[SIMILARITIES]
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=no
# Minimum lines number of a similarity.
min-similarity-lines=4
[SPELLING]
# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4
# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains the private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to the private dictionary (see the
# --spelling-private-dict-file option) instead of raising a message.
spelling-store-unknown-words=no
[STRING]
# This flag controls whether the implicit-str-concat-in-sequence should
# generate a warning on implicit string concatenation in sequences defined over
# several lines.
check-str-concat-over-line-jumps=no
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
# List of decorators that change the signature of a decorated function.
signature-mutators=
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid defining new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
_cb
# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
__new__,
setUp,
__post_init__
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
_rows
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls
[DESIGN]
# Maximum number of arguments for function / method.
max-args=6
# Maximum number of attributes for a class (see R0902).
max-attributes=15
# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
# Maximum number of branch for function / method body.
max-branches=12
# Maximum number of locals for function / method body.
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body.
max-returns=6
# Maximum number of statements in function / method body.
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
[IMPORTS]
# List of modules that can be imported at any level, not just the top level
# one.
allow-any-import-level=
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Deprecated modules which should not be used, separated by a comma.
deprecated-modules=optparse,tkinter.tix
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled).
ext-import-graph=
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled).
import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled).
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
# Couples of modules and preferred modules, separated by a comma.
preferred-modules=
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册