utils: checkstyle.py: Use single-quoted strings when possible

checkstyle.py uses single-quoted strings in most locations already.
There are a few locations where this wouldn't be convenient (when the
string itself contains a single quote, which would then require
escaping), but there are also a few other locations where double quotes
are used when single quotes would work fine. Change those to standardize
on single-quoted strings.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2021-08-27 18:41:10 +03:00
parent d1cdaeb6f0
commit 605b58efb1

View file

@ -239,7 +239,7 @@ class StagedChanges(Commit):
def _parse(self): def _parse(self):
ret = subprocess.run(['git', 'diff', '--staged', '--name-status'], ret = subprocess.run(['git', 'diff', '--staged', '--name-status'],
stdout=subprocess.PIPE).stdout.decode('utf-8') stdout=subprocess.PIPE).stdout.decode('utf-8')
self._title = "Staged changes" self._title = 'Staged changes'
self._files = [CommitFile(f) for f in ret.splitlines()] self._files = [CommitFile(f) for f in ret.splitlines()]
def get_diff(self, top_level, filename): def get_diff(self, top_level, filename):
@ -476,7 +476,7 @@ class Pep8Checker(StyleChecker):
ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'], ret = subprocess.run(['pycodestyle', '--ignore=E501', '-'],
input=data, stdout=subprocess.PIPE) input=data, stdout=subprocess.PIPE)
except FileNotFoundError: except FileNotFoundError:
issues.append(StyleIssue(0, None, "Please install pycodestyle to validate python additions")) issues.append(StyleIssue(0, None, 'Please install pycodestyle to validate python additions'))
return issues return issues
results = ret.stdout.decode('utf-8').splitlines() results = ret.stdout.decode('utf-8').splitlines()
@ -509,7 +509,7 @@ class ShellChecker(StyleChecker):
ret = subprocess.run(['shellcheck', '-Cnever', '-'], ret = subprocess.run(['shellcheck', '-Cnever', '-'],
input=data, stdout=subprocess.PIPE) input=data, stdout=subprocess.PIPE)
except FileNotFoundError: except FileNotFoundError:
issues.append(StyleIssue(0, None, "Please install shellcheck to validate shell script additions")) issues.append(StyleIssue(0, None, 'Please install shellcheck to validate shell script additions'))
return issues return issues
results = ret.stdout.decode('utf-8').splitlines() results = ret.stdout.decode('utf-8').splitlines()
@ -774,10 +774,10 @@ def check_style(top_level, commit):
issues += check_file(top_level, commit, f) issues += check_file(top_level, commit, f)
if issues == 0: if issues == 0:
print("No issue detected") print('No issue detected')
else: else:
print('---') print('---')
print("%u potential %s detected, please review" % print('%u potential %s detected, please review' %
(issues, 'issue' if issues == 1 else 'issues')) (issues, 'issue' if issues == 1 else 'issues'))
return issues return issues
@ -833,7 +833,7 @@ def main(argv):
for command, mandatory in dependencies.items(): for command, mandatory in dependencies.items():
found = shutil.which(command) found = shutil.which(command)
if mandatory and not found: if mandatory and not found:
print("Executable %s not found" % command) print('Executable %s not found' % command)
return 1 return 1
dependencies[command] = found dependencies[command] = found