1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-07 06:42:56 +03:00

Add docstrings to pacify pylint

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2024-03-04 11:51:31 +01:00
parent 8cbbc5f4e6
commit de047b09fe

View File

@@ -468,6 +468,7 @@ class IntegrityChecker:
] ]
def setup_logger(self, log_file, level=logging.INFO): def setup_logger(self, log_file, level=logging.INFO):
"""Log to log_file if provided, or to stderr if None."""
self.logger = logging.getLogger() self.logger = logging.getLogger()
self.logger.setLevel(level) self.logger.setLevel(level)
if log_file: if log_file:
@@ -479,6 +480,10 @@ class IntegrityChecker:
@staticmethod @staticmethod
def collect_files(): def collect_files():
"""Return the list of files to check.
These are the regular files commited into Git.
"""
bytes_output = subprocess.check_output(['git', 'ls-files', '-z']) bytes_output = subprocess.check_output(['git', 'ls-files', '-z'])
bytes_filepaths = bytes_output.split(b'\0')[:-1] bytes_filepaths = bytes_output.split(b'\0')[:-1]
ascii_filepaths = map(lambda fp: fp.decode('ascii'), bytes_filepaths) ascii_filepaths = map(lambda fp: fp.decode('ascii'), bytes_filepaths)
@@ -495,12 +500,17 @@ class IntegrityChecker:
for fp in ascii_filepaths] for fp in ascii_filepaths]
def check_files(self): def check_files(self):
"""Check all files for all issues."""
for issue_to_check in self.issues_to_check: for issue_to_check in self.issues_to_check:
for filepath in self.collect_files(): for filepath in self.collect_files():
if issue_to_check.should_check_file(filepath): if issue_to_check.should_check_file(filepath):
issue_to_check.check_file_for_issue(filepath) issue_to_check.check_file_for_issue(filepath)
def output_issues(self): def output_issues(self):
"""Log the issues found and their locations.
Return 1 if there were issues, 0 otherwise.
"""
integrity_return_code = 0 integrity_return_code = 0
for issue_to_check in self.issues_to_check: for issue_to_check in self.issues_to_check:
if issue_to_check.files_with_issues: if issue_to_check.files_with_issues: