text stringlengths 0 828 |
|---|
""""""Check if the file should be excluded. |
:param filename: file name |
:param excludes: list of regex to match |
:return: True if the file should be excluded |
"""""" |
# check if you need to exclude this file |
return any([exclude and re.match(exclude, filename) is not None |
for exclude in excludes])" |
1662,"def check_pep8(filename, **kwargs): |
""""""Perform static analysis on the given file. |
:param filename: path of file to check. |
:type filename: str |
:param ignore: codes to ignore, e.g. ``('E111', 'E123')`` |
:type ignore: `list` |
:param select: codes to explicitly select. |
:type select: `list` |
:param pyflakes: run the pyflakes checks too (default ``True``) |
:type pyflakes: bool |
:return: errors |
:rtype: `list` |
.. seealso:: :py:class:`pycodestyle.Checker` |
"""""" |
options = { |
""ignore"": kwargs.get(""ignore""), |
""select"": kwargs.get(""select""), |
} |
if not _registered_pyflakes_check and kwargs.get(""pyflakes"", True): |
_register_pyflakes_check() |
checker = pep8.Checker(filename, reporter=_Report, **options) |
checker.check_all() |
errors = [] |
for error in sorted(checker.report.errors, key=lambda x: x[0]): |
errors.append(""{0}:{1}: {3}"".format(*error)) |
return errors" |
1663,"def check_pydocstyle(filename, **kwargs): |
""""""Perform static analysis on the given file docstrings. |
:param filename: path of file to check. |
:type filename: str |
:param ignore: codes to ignore, e.g. ('D400',) |
:type ignore: `list` |
:param match: regex the filename has to match to be checked |
:type match: str |
:param match_dir: regex everydir in path should match to be checked |
:type match_dir: str |
:return: errors |
:rtype: `list` |
.. seealso:: |
`PyCQA/pydocstyle <https://github.com/GreenSteam/pydocstyle/>`_ |
"""""" |
ignore = kwargs.get(""ignore"") |
match = kwargs.get(""match"", None) |
match_dir = kwargs.get(""match_dir"", None) |
errors = [] |
if match and not re.match(match, os.path.basename(filename)): |
return errors |
if match_dir: |
# FIXME here the full path is checked, be sure, if match_dir doesn't |
# match the path (usually temporary) before the actual application path |
# it may not run the checks when it should have. |
path = os.path.split(os.path.abspath(filename))[0] |
while path != ""/"": |
path, dirname = os.path.split(path) |
if not re.match(match_dir, dirname): |
return errors |
checker = pydocstyle.PEP257Checker() |
with open(filename) as fp: |
try: |
for error in checker.check_source(fp.read(), filename): |
if ignore is None or error.code not in ignore: |
# Removing the colon ':' after the error code |
message = re.sub(""(D[0-9]{3}): ?(.*)"", |
r""\1 \2"", |
error.message) |
errors.append(""{0}: {1}"".format(error.line, message)) |
except tokenize.TokenError as e: |
errors.append(""{1}:{2} {0}"".format(e.args[0], *e.args[1])) |
except pydocstyle.AllError as e: |
errors.append(str(e)) |
return errors" |
1664,"def check_license(filename, **kwargs): |
""""""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. |
:param filename: path of file to check. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.