[narval/debcheck] use a glob instead of a recursive os.walk to find *.changes
We know where those files are, there's no need to do a recursive search.
This also avoids issues with os.walk with non-ascii file names.
***
--- a/_narval/checkers/apycot/debcheck.py Mon Jul 07 18:48:43 2014 +0200
+++ b/_narval/checkers/apycot/debcheck.py Wed Jul 09 11:36:06 2014 +0200
@@ -2,15 +2,9 @@
import logging
import os
import subprocess
+from glob import glob
from checkers.apycot import BaseChecker
-def find_with_extension(path, extension):
- path = os.path.expanduser(path)
- for folder, subfolders, files in os.walk(path):
- for filename in files:
- if filename.endswith(extension):
- yield os.path.join(folder, filename)
-
class DebianLintianChecker(BaseChecker):
"""Runs the lintian program after building a debian package. Lintian
checks for bugs and debian policy violations."""
@@ -40,7 +34,7 @@
changes_files = self.options.get('changes-files')
if not changes_files:
build_folder = os.path.join(test.project_path(), os.pardir)
- changes_files = find_with_extension(build_folder, '.changes')
+ changes_files = glob(os.path.join(build_folder, '*', '*.changes'))
if not changes_files:
status = apycotlib.NODATA
for f in changes_files:
@@ -125,7 +119,7 @@
changes_files = self.options.get('changes-files')
if not changes_files:
build_folder = os.path.join(test.project_path(), '..')
- changes_files = find_with_extension(build_folder, '.changes')
+ changes_files = glob(os.path.join(build_folder, '*', '*.changes'))
if not changes_files:
status = apycotlib.NODATA
for f in changes_files:
--- a/_narval/checkers/apycot/lgp.py Mon Jul 07 18:48:43 2014 +0200
+++ b/_narval/checkers/apycot/lgp.py Wed Jul 09 11:36:06 2014 +0200
@@ -1,14 +1,11 @@
import os
import logging
-
-#from narvalbot.prototype import input, output
-#from narvalbot.elements import FilePath
+from glob import glob
import apycotlib as apycot
from checkers.apycot import BaseChecker, AbstractFilteredFileChecker
from logilab.devtools.lgp import *
-from checkers.apycot.debcheck import find_with_extension
class FilePath(object):
def __init__(self, path, host=None, **kwargs):
@@ -87,7 +84,7 @@
def display_logs(self, build_folder):
self.writer.info('begin scanning for log files ')
- for filename in find_with_extension(build_folder, '.log'):
+ for filename in glob(os.path.join(build_folder, '*', '*.log')):
if os.path.isfile(filename):
log_file = open(filename, 'r')
self.writer.info('printing {0}: {1}'.format(filename,