setup check: common files walker

This commit is contained in:
un-pogaz 2025-01-13 19:39:25 +01:00
parent c1f7c9dd95
commit 74c535f624

View File

@ -30,15 +30,21 @@ def get_ruff_config(is_strict_check):
return [] return []
def checkable_python_files(SRC): def files_walker(root_path, ext):
for dname in ('odf', 'calibre'): for x in os.walk(root_path):
for x in os.walk(os.path.join(SRC, dname)):
for f in x[-1]: for f in x[-1]:
y = os.path.join(x[0], f) y = os.path.join(x[0], f)
if f.endswith('.py') and not f.endswith('_ui.py'): if f.endswith(ext):
yield y yield y
def checkable_python_files(SRC):
for dname in ('odf', 'calibre'):
for f in files_walker(os.path.join(SRC, dname), '.py'):
if not f.endswith('_ui.py'):
yield f
class Check(Command): class Check(Command):
description = 'Check for errors in the calibre source code' description = 'Check for errors in the calibre source code'
@ -57,17 +63,10 @@ class Check(Command):
def get_files(self): def get_files(self):
yield from checkable_python_files(self.SRC) yield from checkable_python_files(self.SRC)
for x in os.walk(self.j(self.d(self.SRC), 'recipes')): yield from files_walker(self.j(self.d(self.SRC), 'recipes'), '.recipe')
for f in x[-1]:
f = self.j(x[0], f) yield from files_walker(self.j(self.SRC, 'pyj'), '.pyj')
if f.endswith('.recipe'):
yield f
for x in os.walk(self.j(self.SRC, 'pyj')):
for f in x[-1]:
f = self.j(x[0], f)
if f.endswith('.pyj'):
yield f
if self.has_changelog_check: if self.has_changelog_check:
yield self.j(self.d(self.SRC), 'Changelog.txt') yield self.j(self.d(self.SRC), 'Changelog.txt')