Linux server1.dn-server.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
LiteSpeed
Server IP : 195.201.204.189 & Your IP : 216.73.217.130
Domains :
Cant Read [ /etc/named.conf ]
User : beriska1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
python37 /
lib /
python3.7 /
site-packages /
Delete
Unzip
Name
Size
Permission
Date
Action
Babel-2.9.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
Beaker-1.11.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
Jinja2-3.0.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
Mako-1.1.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
OpenSSL
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
Paste-1.7.5.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
PyJWT-2.1.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
Pygments-2.4.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
Tempita-0.5.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
WebOb-1.2.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
WebTest-1.3.4-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
__pycache__
[ DIR ]
drwxr-xr-x
2026-05-01 04:25
_distutils_hack
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
_pytest
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
aiosignal
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
aiosignal-1.2.0a0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
alembic
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
alembic-0.8.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
appdirs-1.4.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
args-0.1.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
asn1crypto
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
asn1crypto-0.22.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
astroid
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
astroid-2.2.5-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
async_timeout
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
async_timeout-4.0.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
attr
[ DIR ]
drwxr-xr-x
2026-05-01 04:19
attrs-21.2.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:19
babel
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
beaker
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
beautifulsoup4-4.5.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
betamax
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
betamax-0.8.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
bs4
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
certifi
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
certifi-2018.4.16-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
chardet
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
chardet-3.0.4-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
charset_normalizer
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
charset_normalizer-2.0.12-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
clint
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
clint-0.5.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
colorama
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
colorama-0.3.7-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
constantly
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
constantly-15.1.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
contextlib2-0.5.4-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:25
cryptography_vectors
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
cryptography_vectors-2.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
cssselect
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
cssselect-0.9.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
ddt-1.1.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
distlib
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
docopt-0.6.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
docutils
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
dodgy
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
dodgy-0.1.9-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
dtopt
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
dtopt-0.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
filelock
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
filelock-0.0.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
funcsigs
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
funcsigs-1.0.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
future
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
future-0.17.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
html5lib
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
html5lib-1.0.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
idna
[ DIR ]
drwxr-xr-x
2026-05-01 04:19
idna-2.5-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:19
idna_ssl-1.0.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:23
importlib_metadata
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
importlib_metadata-0.0.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
incremental
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
incremental-17.5.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
isort
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
isort-4.2.5-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
jinja2
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
jsonschema
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
jsonschema-3.2.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
jwt
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
libfuturize
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
libpasteurize
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
logilab
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
logilab_common-0.63.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
mako
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
mccabe-0.6.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
mock
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
mock-3.0.5-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
nose
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
nose-1.3.7-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
packaging
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
packaging-16.8-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
past
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
paste
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pbr
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pbr-1.8.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pep8_naming-0.4.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pip
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
pip-20.2.4.dist-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
pkg_resources
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
pkginfo
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pkginfo-1.3.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
platformdirs
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
platformdirs-0.0.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
ply
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
ply-3.8-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
prettytable-0.7.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
prometheus_client
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
prometheus_client-0.8.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
prospector
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
prospector-1.1.7-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
py
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
py-1.4.34-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pyOpenSSL-17.3.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pyasn1
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
pyasn1-0.1.9-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
pyasn1_modules
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
pyasn1_modules-0.0.8-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
pycodestyle-2.0.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pycparser
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pycparser-2.14-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pydocstyle
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pydocstyle-2.1.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pyfakefs
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
pyfakefs-3.5.8-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
pyflakes
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pyflakes-1.5.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pygments
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint-2.3.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_celery
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_celery-0.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_common
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_common-0.2.5-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_django
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_django-2.0.10-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_flask
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_plugin_utils
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pylint_plugin_utils-0.5-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pyparsing
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
pyparsing-3.0.9.dist-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:20
pyserial-3.4-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pytest-3.0.7-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
python_editor-0.4-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pytz
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
pytz-2017.2-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
raven
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
raven-6.3.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
redis
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
redis-3.5.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
requests
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
requests-2.26.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
requests_toolbelt
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
requests_toolbelt-0.7.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
requirements_detector
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
requirements_detector-0.6-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
schema-0.7.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
sentry_sdk
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
sentry_sdk-1.3.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
serial
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
service_identity
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
service_identity-18.1.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
setoptconf
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
setoptconf-0.2.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
setuptools
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
setuptools-58.3.0.dist-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
setuptools_git
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
setuptools_git-1.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
setuptools_scm
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
setuptools_scm-3.2.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
six-1.15.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
snowballstemmer
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
svgwrite
[ DIR ]
drwxr-xr-x
2026-05-01 04:23
svgwrite-1.3.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:23
tap
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
tap.py-1.9-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
tempita
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
testfixtures
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
testfixtures-4.13.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
twine
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
twine-1.8.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
typing_extensions-3.7.4.3-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
unittest_xml_reporting-3.0.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
urllib3
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
urllib3-1.26.6-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
virtualenv
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
virtualenv-20.13.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
webencodings
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
webencodings-0.5.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
webob
[ DIR ]
drwxr-xr-x
2026-05-01 04:21
webtest
[ DIR ]
drwxr-xr-x
2026-05-01 04:22
wheel
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
wheel-0.31.1-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
xmlrunner
[ DIR ]
drwxr-xr-x
2026-05-01 04:24
zipp-0.0.0-py3.7.egg-info
[ DIR ]
drwxr-xr-x
2026-04-30 23:38
Paste-1.7.5.1-py3.7-nspkg.pth
534
B
-rw-r--r--
2019-12-10 21:53
PySocks-1.5.7-py3.7.egg-info
322
B
-rw-r--r--
2023-11-14 17:33
appdirs.py
24.1
KB
-rw-r--r--
2019-12-09 22:00
args.py
9.1
KB
-rw-r--r--
2012-05-08 10:11
contextlib2.py
14.48
KB
-rw-r--r--
2016-07-31 08:12
ddt.py
8.06
KB
-rw-r--r--
2016-10-07 22:43
distlib-0.3.4-py3.7.egg-info
1.13
KB
-rw-r--r--
2023-11-14 15:41
distutils-precedence.pth
152
B
-rw-r--r--
2023-11-14 01:05
docopt.py
19.48
KB
-rw-r--r--
2014-06-16 15:44
docutils-0.14-py3.7.egg-info
2.31
KB
-rw-r--r--
2019-12-03 22:03
editor.py
2.5
KB
-rwxr-xr-x
2019-12-10 21:23
idna_ssl.py
666
B
-rw-r--r--
2018-03-06 18:40
logilab_common-0.63.2-py3.7-nspkg.pth
544
B
-rw-r--r--
2022-06-28 02:04
mccabe.py
10.44
KB
-rw-r--r--
2017-01-27 01:40
pep8ext_naming.py
10.9
KB
-rw-r--r--
2016-06-26 16:36
prettytable.py
52.93
KB
-rw-r--r--
2013-04-07 04:14
pycodestyle.py
81.7
KB
-rw-r--r--
2019-12-09 20:42
pylint_flask-0.6-py3.7.egg-info
844
B
-rw-r--r--
2019-12-09 20:45
pytest.py
621
B
-rw-r--r--
2019-12-03 22:06
schema.py
28.51
KB
-rw-r--r--
2019-09-09 22:09
six.py
33.36
KB
-rw-r--r--
2020-05-21 19:55
snowballstemmer-1.2.1-py3.7.egg-info
2.19
KB
-rw-r--r--
2019-12-09 20:36
socks.py
29.25
KB
-rw-r--r--
2016-05-22 02:24
sockshandler.py
2.84
KB
-rw-r--r--
2016-05-22 02:24
typing-3.5.3.0-py3.7.egg-info
1.45
KB
-rw-r--r--
2019-12-03 21:38
typing.py
69.02
KB
-rw-r--r--
2017-01-01 06:27
typing_extensions.py
81.76
KB
-rw-r--r--
2020-07-08 02:59
zipp.py
8.23
KB
-rw-r--r--
2021-12-31 03:31
Save
Rename
""" Meager code path measurement tool. Ned Batchelder http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html MIT License. """ from __future__ import with_statement import optparse import sys import tokenize from collections import defaultdict try: import ast from ast import iter_child_nodes except ImportError: # Python 2.5 from flake8.util import ast, iter_child_nodes __version__ = '0.6.1' class ASTVisitor(object): """Performs a depth-first walk of the AST.""" def __init__(self): self.node = None self._cache = {} def default(self, node, *args): for child in iter_child_nodes(node): self.dispatch(child, *args) def dispatch(self, node, *args): self.node = node klass = node.__class__ meth = self._cache.get(klass) if meth is None: className = klass.__name__ meth = getattr(self.visitor, 'visit' + className, self.default) self._cache[klass] = meth return meth(node, *args) def preorder(self, tree, visitor, *args): """Do preorder walk of tree using visitor""" self.visitor = visitor visitor.visit = self.dispatch self.dispatch(tree, *args) # XXX *args make sense? class PathNode(object): def __init__(self, name, look="circle"): self.name = name self.look = look def to_dot(self): print('node [shape=%s,label="%s"] %d;' % ( self.look, self.name, self.dot_id())) def dot_id(self): return id(self) class PathGraph(object): def __init__(self, name, entity, lineno, column=0): self.name = name self.entity = entity self.lineno = lineno self.column = column self.nodes = defaultdict(list) def connect(self, n1, n2): self.nodes[n1].append(n2) # Ensure that the destination node is always counted. self.nodes[n2] = [] def to_dot(self): print('subgraph {') for node in self.nodes: node.to_dot() for node, nexts in self.nodes.items(): for next in nexts: print('%s -- %s;' % (node.dot_id(), next.dot_id())) print('}') def complexity(self): """ Return the McCabe complexity for the graph. V-E+2 """ num_edges = sum([len(n) for n in self.nodes.values()]) num_nodes = len(self.nodes) return num_edges - num_nodes + 2 class PathGraphingAstVisitor(ASTVisitor): """ A visitor for a parsed Abstract Syntax Tree which finds executable statements. """ def __init__(self): super(PathGraphingAstVisitor, self).__init__() self.classname = "" self.graphs = {} self.reset() def reset(self): self.graph = None self.tail = None def dispatch_list(self, node_list): for node in node_list: self.dispatch(node) def visitFunctionDef(self, node): if self.classname: entity = '%s%s' % (self.classname, node.name) else: entity = node.name name = '%d:%d: %r' % (node.lineno, node.col_offset, entity) if self.graph is not None: # closure pathnode = self.appendPathNode(name) self.tail = pathnode self.dispatch_list(node.body) bottom = PathNode("", look='point') self.graph.connect(self.tail, bottom) self.graph.connect(pathnode, bottom) self.tail = bottom else: self.graph = PathGraph(name, entity, node.lineno, node.col_offset) pathnode = PathNode(name) self.tail = pathnode self.dispatch_list(node.body) self.graphs["%s%s" % (self.classname, node.name)] = self.graph self.reset() visitAsyncFunctionDef = visitFunctionDef def visitClassDef(self, node): old_classname = self.classname self.classname += node.name + "." self.dispatch_list(node.body) self.classname = old_classname def appendPathNode(self, name): if not self.tail: return pathnode = PathNode(name) self.graph.connect(self.tail, pathnode) self.tail = pathnode return pathnode def visitSimpleStatement(self, node): if node.lineno is None: lineno = 0 else: lineno = node.lineno name = "Stmt %d" % lineno self.appendPathNode(name) def default(self, node, *args): if isinstance(node, ast.stmt): self.visitSimpleStatement(node) else: super(PathGraphingAstVisitor, self).default(node, *args) def visitLoop(self, node): name = "Loop %d" % node.lineno self._subgraph(node, name) visitAsyncFor = visitFor = visitWhile = visitLoop def visitIf(self, node): name = "If %d" % node.lineno self._subgraph(node, name) def _subgraph(self, node, name, extra_blocks=()): """create the subgraphs representing any `if` and `for` statements""" if self.graph is None: # global loop self.graph = PathGraph(name, name, node.lineno, node.col_offset) pathnode = PathNode(name) self._subgraph_parse(node, pathnode, extra_blocks) self.graphs["%s%s" % (self.classname, name)] = self.graph self.reset() else: pathnode = self.appendPathNode(name) self._subgraph_parse(node, pathnode, extra_blocks) def _subgraph_parse(self, node, pathnode, extra_blocks): """parse the body and any `else` block of `if` and `for` statements""" loose_ends = [] self.tail = pathnode self.dispatch_list(node.body) loose_ends.append(self.tail) for extra in extra_blocks: self.tail = pathnode self.dispatch_list(extra.body) loose_ends.append(self.tail) if node.orelse: self.tail = pathnode self.dispatch_list(node.orelse) loose_ends.append(self.tail) else: loose_ends.append(pathnode) if pathnode: bottom = PathNode("", look='point') for le in loose_ends: self.graph.connect(le, bottom) self.tail = bottom def visitTryExcept(self, node): name = "TryExcept %d" % node.lineno self._subgraph(node, name, extra_blocks=node.handlers) visitTry = visitTryExcept def visitWith(self, node): name = "With %d" % node.lineno self.appendPathNode(name) self.dispatch_list(node.body) visitAsyncWith = visitWith class McCabeChecker(object): """McCabe cyclomatic complexity checker.""" name = 'mccabe' version = __version__ _code = 'C901' _error_tmpl = "C901 %r is too complex (%d)" max_complexity = -1 def __init__(self, tree, filename): self.tree = tree @classmethod def add_options(cls, parser): flag = '--max-complexity' kwargs = { 'default': -1, 'action': 'store', 'type': 'int', 'help': 'McCabe complexity threshold', 'parse_from_config': 'True', } config_opts = getattr(parser, 'config_options', None) if isinstance(config_opts, list): # Flake8 2.x kwargs.pop('parse_from_config') parser.add_option(flag, **kwargs) parser.config_options.append('max-complexity') else: parser.add_option(flag, **kwargs) @classmethod def parse_options(cls, options): cls.max_complexity = int(options.max_complexity) def run(self): if self.max_complexity < 0: return visitor = PathGraphingAstVisitor() visitor.preorder(self.tree, visitor) for graph in visitor.graphs.values(): if graph.complexity() > self.max_complexity: text = self._error_tmpl % (graph.entity, graph.complexity()) yield graph.lineno, graph.column, text, type(self) def get_code_complexity(code, threshold=7, filename='stdin'): try: tree = compile(code, filename, "exec", ast.PyCF_ONLY_AST) except SyntaxError: e = sys.exc_info()[1] sys.stderr.write("Unable to parse %s: %s\n" % (filename, e)) return 0 complx = [] McCabeChecker.max_complexity = threshold for lineno, offset, text, check in McCabeChecker(tree, filename).run(): complx.append('%s:%d:1: %s' % (filename, lineno, text)) if len(complx) == 0: return 0 print('\n'.join(complx)) return len(complx) def get_module_complexity(module_path, threshold=7): """Returns the complexity of a module""" with open(module_path, "rU") as mod: code = mod.read() return get_code_complexity(code, threshold, filename=module_path) def _read(filename): if (2, 5) < sys.version_info < (3, 0): with open(filename, 'rU') as f: return f.read() elif (3, 0) <= sys.version_info < (4, 0): """Read the source code.""" try: with open(filename, 'rb') as f: (encoding, _) = tokenize.detect_encoding(f.readline) except (LookupError, SyntaxError, UnicodeError): # Fall back if file encoding is improperly declared with open(filename, encoding='latin-1') as f: return f.read() with open(filename, 'r', encoding=encoding) as f: return f.read() def main(argv=None): if argv is None: argv = sys.argv[1:] opar = optparse.OptionParser() opar.add_option("-d", "--dot", dest="dot", help="output a graphviz dot file", action="store_true") opar.add_option("-m", "--min", dest="threshold", help="minimum complexity for output", type="int", default=1) options, args = opar.parse_args(argv) code = _read(args[0]) tree = compile(code, args[0], "exec", ast.PyCF_ONLY_AST) visitor = PathGraphingAstVisitor() visitor.preorder(tree, visitor) if options.dot: print('graph {') for graph in visitor.graphs.values(): if (not options.threshold or graph.complexity() >= options.threshold): graph.to_dot() print('}') else: for graph in visitor.graphs.values(): if graph.complexity() >= options.threshold: print(graph.name, graph.complexity()) if __name__ == '__main__': main(sys.argv[1:])