mirror of
https://github.com/clearlinux/autospec.git
synced 2026-08-26 18:35:57 +00:00
Fix linter (flake8) errors.
Also: * flake8 configuration is moved from the command-line in the makefile to setup.cfg
This commit is contained in:
committed by
William Douglas
parent
1e97424119
commit
6740ba1683
@@ -1,5 +1,5 @@
|
||||
check: autospec/*.py
|
||||
@flake8 --max-line-length=199 --ignore=E722 $^
|
||||
@flake8 $^
|
||||
|
||||
test_pkg_integrity:
|
||||
PYTHONPATH=${CURDIR}/autospec python3 tests/test_pkg_integrity.py
|
||||
|
||||
@@ -62,8 +62,8 @@ def add_sources(download_path, archives):
|
||||
# directories which usually reside in directories such as
|
||||
# /run or /tmp.
|
||||
#
|
||||
if os.path.exists(os.path.normpath(build.download_path +
|
||||
"/{0}.tmpfiles".format(tarball.name))):
|
||||
if os.path.exists(os.path.normpath(
|
||||
build.download_path + "/{0}.tmpfiles".format(tarball.name))):
|
||||
buildpattern.sources["tmpfile"].append(
|
||||
"{}.tmpfiles".format(tarball.name))
|
||||
if tarball.gcov_file:
|
||||
|
||||
@@ -169,7 +169,7 @@ def is_version(num_str):
|
||||
"""
|
||||
Return True if num_str looks like a version number
|
||||
"""
|
||||
if re.search('^\d+(\.\d+)*$', num_str):
|
||||
if re.search(r'^\d+(\.\d+)*$', num_str):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@@ -150,7 +150,7 @@ def process_NEWS(newsfile):
|
||||
return commitmessage, cves
|
||||
|
||||
# now search for CVEs
|
||||
pat = re.compile("(CVE\-[0-9]+\-[0-9]+)")
|
||||
pat = re.compile(r"(CVE\-[0-9]+\-[0-9]+)")
|
||||
for news in newslines[start:stop]:
|
||||
match = pat.search(news)
|
||||
if match:
|
||||
|
||||
+1
-2
@@ -728,8 +728,7 @@ def parse_config_files(path, bump, filemanager, version):
|
||||
|
||||
patches += read_conf_file(os.path.join(path, "series"))
|
||||
pfiles = [("%s/%s" % (path, x.split(" ")[0])) for x in patches]
|
||||
cmd = "egrep \"(\+\+\+|\-\-\-).*((Makefile.am)|(configure.ac|configure.in))\" %s" % \
|
||||
" ".join(pfiles)
|
||||
cmd = "egrep \"(\+\+\+|\-\-\-).*((Makefile.am)|(configure.ac|configure.in))\" %s" % " ".join(pfiles) # noqa: W605
|
||||
if patches and call(cmd,
|
||||
check=False,
|
||||
stdout=subprocess.DEVNULL,
|
||||
|
||||
+3
-3
@@ -1249,12 +1249,12 @@ def parse_log(log, pkgname=''):
|
||||
# == 55 tests, 48 stderr failures, 6 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==
|
||||
# == 125 tests, 12 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==
|
||||
match = re.search(r"\=\= ([0-9]+) tests?\, ([0-9]+) stderr failures?\, ([0-9]+) stdout failures?\, "
|
||||
"([0-9]+) stderrB failures?\, ([0-9]+) stdoutB failures?\, ([0-9]+) post failures? \=\=", line)
|
||||
r"([0-9]+) stderrB failures?\, ([0-9]+) stdoutB failures?\, ([0-9]+) post failures? \=\=", line)
|
||||
if match and incheck:
|
||||
total_tests += convert_int(match.group(1))
|
||||
total_fail += (convert_int(match.group(2)) + convert_int(match.group(3)) + convert_int(match.group(4)) + convert_int(match.group(5)) + convert_int(match.group(6)))
|
||||
total_pass += (convert_int(match.group(1)) - (convert_int(match.group(2)) + convert_int(match.group(3)) + convert_int(match.group(4)) + convert_int(match.group(5)) +
|
||||
convert_int(match.group(6))))
|
||||
total_pass += \
|
||||
(convert_int(match.group(1)) - (convert_int(match.group(2)) + convert_int(match.group(3)) + convert_int(match.group(4)) + convert_int(match.group(5)) + convert_int(match.group(6))))
|
||||
continue
|
||||
|
||||
# zsh
|
||||
|
||||
+37
-37
@@ -134,7 +134,7 @@ class FileManager(object):
|
||||
res = set()
|
||||
removed = False
|
||||
|
||||
directive_re = re.compile("(%\w+(\([^\)]*\))?\s+)(.*)")
|
||||
directive_re = re.compile(r"(%\w+(\([^\)]*\))?\s+)(.*)")
|
||||
for f in files:
|
||||
# skip the files with directives at the beginning, including %doc
|
||||
# and %dir directives.
|
||||
@@ -218,17 +218,17 @@ class FileManager(object):
|
||||
# Patterns for matching files, format is a tuple as follows:
|
||||
# (<raw pattern>, <package>, <optional replacement>, <optional prefix>)
|
||||
# order matters!
|
||||
(r"^/usr/share/package-licenses/.+/.+", "license"),
|
||||
(r"^/usr/share/package-licenses/.{1,}/.{1,}", "license"),
|
||||
(r"^/usr/share/man/man2", "dev"),
|
||||
(r"^/usr/share/man/man3", "dev"),
|
||||
(r"^/usr/share/man/", "man"),
|
||||
(r"^/usr/share/omf", "main", "/usr/share/omf/*"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.so\.", "lib"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.so\.", "lib"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9\.\_\-\+]*\.so\.", "lib32"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9._+-]*\.so\.", "lib"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9._+-]*\.so\.", "lib"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9._+-]*\.so\.", "lib32"),
|
||||
(r"^/usr/lib64/lib(asm|dw|elf)-[0-9.]+\.so", "lib"),
|
||||
(r"^/usr/lib32/lib(asm|dw|elf)-[0-9.]+\.so", "lib32"),
|
||||
(r"^/usr/lib64/haswell/[a-zA-Z0-9\.\_\-\+]*\.so\.", "lib"),
|
||||
(r"^/usr/lib64/haswell/[a-zA-Z0-9._+-]*\.so\.", "lib"),
|
||||
(r"^/usr/lib64/gobject-introspection/", "lib"),
|
||||
(r"^/usr/libexec/", "libexec"),
|
||||
(r"^/usr/bin/", "bin"),
|
||||
@@ -238,17 +238,17 @@ class FileManager(object):
|
||||
(r"^/usr/lib/python3.*/", "python3", "/usr/lib/python3*/*"),
|
||||
(r"^/usr/lib/python2.*/", "legacypython", "/usr/lib/python2*/*"),
|
||||
(r"^/usr/lib64/python.*/", "python", "/usr/lib64/python*/*"),
|
||||
(r"^/usr/share/gir-[0-9\.]+/[a-zA-Z0-9\.\_\-\+]*\.gir", "data", "/usr/share/gir-1.0/*.gir"),
|
||||
(r"^/usr/share/gir-[0-9\.]+/[a-zA-Z0-9._+-]*\.gir", "data", "/usr/share/gir-1.0/*.gir"),
|
||||
(r"^/usr/share/cmake/", "data", "/usr/share/cmake/*"),
|
||||
(r"^/usr/share/cmake-3.1/", "data", "/usr/share/cmake-3.1/*"),
|
||||
(r"^/usr/share/cmake-3.7/", "data", "/usr/share/cmake-3.7/*"),
|
||||
(r"^/usr/share/cmake-3.8/", "data", "/usr/share/cmake-3.8/*"),
|
||||
(r"^/usr/share/cmake-3.6/", "data", "/usr/share/cmake-3.6/*"),
|
||||
(r"^/usr/share/girepository-1\.0/.*\.typelib\$", "data", "/usr/share/girepository-1.0/*.typelib"),
|
||||
(r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.hxx", "dev", "/usr/include/*.hxx"),
|
||||
(r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.hpp", "dev", "/usr/include/*.hpp"),
|
||||
(r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.h\+\+", "dev", "/usr/include/*.h\+\+"),
|
||||
(r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.h", "dev", "/usr/include/*.h"),
|
||||
(r"^/usr/include/[a-zA-Z0-9._+-]*\.hxx", "dev", "/usr/include/*.hxx"),
|
||||
(r"^/usr/include/[a-zA-Z0-9._+-]*\.hpp", "dev", "/usr/include/*.hpp"),
|
||||
(r"^/usr/include/[a-zA-Z0-9._+-]*\.h\+\+", "dev", "/usr/include/*.h++"),
|
||||
(r"^/usr/include/[a-zA-Z0-9._+-]*\.h", "dev", "/usr/include/*.h"),
|
||||
(r"^/usr/include/", "dev"),
|
||||
(r"^/usr/lib64/girepository-1.0/", "data"),
|
||||
(r"^/usr/share/cmake/", "dev"),
|
||||
@@ -261,29 +261,29 @@ class FileManager(object):
|
||||
(r"^/usr/lib/qt5/", "lib"),
|
||||
(r"^/usr/lib64/qt5/", "lib"),
|
||||
(r"^/usr/lib32/qt5/", "lib32"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.so$", so_dest),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.so$", so_dest),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9\.\_\-\+]*\.so$", so_dest + '32'),
|
||||
(r"^/usr/lib64/haswell/[a-zA-Z0-9\.\_\-\+]*\.so$", so_dest),
|
||||
(r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev", "/usr/lib/*.a"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev", "/usr/lib64/*.a"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev32", "/usr/lib32/*.a"),
|
||||
(r"^/usr/lib/haswell/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev", "/usr/lib/haswell/*.a"),
|
||||
(r"^/usr/lib64/haswell/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev", "/usr/lib64/haswell/*.a"),
|
||||
(r"^/usr/lib32/haswell/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev32", "/usr/lib32/haswell/*.a"),
|
||||
(r"^/usr/lib/pkgconfig/[a-zA-Z0-9\.\_\-\+]*\.pc$", "dev"),
|
||||
(r"^/usr/lib64/pkgconfig/[a-zA-Z0-9\.\_\-\+]*\.pc$", "dev"),
|
||||
(r"^/usr/lib32/pkgconfig/[a-zA-Z0-9\.\_\-\+]*\.pc$", "dev32"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.la$", "dev"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.la$", "dev"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9\.\_\-\+]*\.la$", "dev32"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.prl$", "dev"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.prl$", "dev"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9\.\_\-\+]*\.prl$", "dev32"),
|
||||
(r"^/usr/share/aclocal/[a-zA-Z0-9\.\_\-\+]*\.ac$", "dev", "/usr/share/aclocal/*.ac"),
|
||||
(r"^/usr/share/aclocal/[a-zA-Z0-9\.\_\-\+]*\.m4$", "dev", "/usr/share/aclocal/*.m4"),
|
||||
(r"^/usr/share/aclocal-1.[0-9]+/[a-zA-Z0-9\.\_\-\+]*\.ac$", "dev", "/usr/share/aclocal-1.*/*.ac"),
|
||||
(r"^/usr/share/aclocal-1.[0-9]+/[a-zA-Z0-9\.\_\-\+]*\.m4$", "dev", "/usr/share/aclocal-1.*/*.m4"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9._+-]*\.so$", so_dest),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9._+-]*\.so$", so_dest),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9._+-]*\.so$", so_dest + '32'),
|
||||
(r"^/usr/lib64/haswell/[a-zA-Z0-9._+-]*\.so$", so_dest),
|
||||
(r"^/usr/lib/[a-zA-Z0-9._+-]*\.a$", "dev", "/usr/lib/*.a"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9._+-]*\.a$", "dev", "/usr/lib64/*.a"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9._+-]*\.a$", "dev32", "/usr/lib32/*.a"),
|
||||
(r"^/usr/lib/haswell/[a-zA-Z0-9._+-]*\.a$", "dev", "/usr/lib/haswell/*.a"),
|
||||
(r"^/usr/lib64/haswell/[a-zA-Z0-9._+-]*\.a$", "dev", "/usr/lib64/haswell/*.a"),
|
||||
(r"^/usr/lib32/haswell/[a-zA-Z0-9._+-]*\.a$", "dev32", "/usr/lib32/haswell/*.a"),
|
||||
(r"^/usr/lib/pkgconfig/[a-zA-Z0-9._+-]*\.pc$", "dev"),
|
||||
(r"^/usr/lib64/pkgconfig/[a-zA-Z0-9._+-]*\.pc$", "dev"),
|
||||
(r"^/usr/lib32/pkgconfig/[a-zA-Z0-9._+-]*\.pc$", "dev32"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9._+-]*\.la$", "dev"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9._+-]*\.la$", "dev"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9._+-]*\.la$", "dev32"),
|
||||
(r"^/usr/lib/[a-zA-Z0-9._+-]*\.prl$", "dev"),
|
||||
(r"^/usr/lib64/[a-zA-Z0-9._+-]*\.prl$", "dev"),
|
||||
(r"^/usr/lib32/[a-zA-Z0-9._+-]*\.prl$", "dev32"),
|
||||
(r"^/usr/share/aclocal/[a-zA-Z0-9._+-]*\.ac$", "dev", "/usr/share/aclocal/*.ac"),
|
||||
(r"^/usr/share/aclocal/[a-zA-Z0-9._+-]*\.m4$", "dev", "/usr/share/aclocal/*.m4"),
|
||||
(r"^/usr/share/aclocal-1.[0-9]+/[a-zA-Z0-9._+-]*\.ac$", "dev", "/usr/share/aclocal-1.*/*.ac"),
|
||||
(r"^/usr/share/aclocal-1.[0-9]+/[a-zA-Z0-9._+-]*\.m4$", "dev", "/usr/share/aclocal-1.*/*.m4"),
|
||||
(r"^/usr/share/doc/" + re.escape(tarball.name) + "/", "doc", "%doc /usr/share/doc/" + re.escape(tarball.name) + "/*"),
|
||||
(r"^/usr/share/doc/", "doc"),
|
||||
(r"^/usr/share/gtk-doc/html", "doc"),
|
||||
@@ -303,9 +303,9 @@ class FileManager(object):
|
||||
(r"^/usr/share/", "data"),
|
||||
# finally move any dynamically loadable plugins (not
|
||||
# perl/python/ruby/etc.. extensions) into lib package
|
||||
(r"^/usr/lib/.*/[a-zA-Z0-9\.\_\-\+]*\.so", "lib"),
|
||||
(r"^/usr/lib64/.*/[a-zA-Z0-9\.\_\-\+]*\.so", "lib"),
|
||||
(r"^/usr/lib32/.*/[a-zA-Z0-9\.\_\-\+]*\.so", "lib32"),
|
||||
(r"^/usr/lib/.*/[a-zA-Z0-9._+-]*\.so", "lib"),
|
||||
(r"^/usr/lib64/.*/[a-zA-Z0-9._+-]*\.so", "lib"),
|
||||
(r"^/usr/lib32/.*/[a-zA-Z0-9._+-]*\.so", "lib32"),
|
||||
# locale data gets picked up via file_is_locale
|
||||
(r"^/usr/share/locale/", "ignore")]
|
||||
|
||||
|
||||
@@ -383,9 +383,9 @@ class PyPiVerifier(MD5Verifier):
|
||||
|
||||
def parse_name(self):
|
||||
pkg_name = os.path.basename(self.package_path)
|
||||
name, _ = re.split('-\d+\.', pkg_name, maxsplit=1)
|
||||
name, _ = re.split(r'-\d+\.', pkg_name, maxsplit=1)
|
||||
release_no = pkg_name.replace(name + '-', '')
|
||||
extensions = "({})".format("|".join(['\.tar\.gz$', '\.zip$', '\.tgz$', '\.tar\.bz2$']))
|
||||
extensions = "({})".format("|".join([r'\.tar\.gz$', r'\.zip$', r'\.tgz$', r'\.tar\.bz2$']))
|
||||
ext = re.search(extensions, release_no)
|
||||
if ext is not None:
|
||||
release_no = release_no.replace(ext.group(), '')
|
||||
@@ -541,7 +541,7 @@ class GEMShaVerifier(Verifier):
|
||||
if os.path.exists(self.package_path) is False:
|
||||
self.print_result(False, 'GEM was not found {}'.format(self.package_path))
|
||||
return
|
||||
name, _ = re.split('-\d+\.', gemname)
|
||||
name, _ = re.split(r'-\d+\.', gemname)
|
||||
number = gemname.replace(name + '-', '')
|
||||
geminfo = self.get_rubygems_info(name)
|
||||
gemsha = self.get_gemnumber_sha(geminfo, number)
|
||||
|
||||
@@ -160,10 +160,8 @@ class Specfile(object):
|
||||
Append additional source files - systemd unit files, gcov, and
|
||||
additional source tarballs are the currently supported file types.
|
||||
"""
|
||||
for count, source in enumerate(sorted(self.sources["unit"] +
|
||||
self.sources["archive"] +
|
||||
self.sources["tmpfile"] +
|
||||
self.sources["gcov"])):
|
||||
for count, source in enumerate(
|
||||
sorted(self.sources["unit"] + self.sources["archive"] + self.sources["tmpfile"] + self.sources["gcov"])):
|
||||
self.source_index[source] = count + 1
|
||||
if self.urlban:
|
||||
source = re.sub(self.urlban, "localhost", source)
|
||||
@@ -1472,7 +1470,7 @@ class Specfile(object):
|
||||
quoted = ''
|
||||
# Capture any directive prefix separately from actual filename
|
||||
# (1 )(3 )
|
||||
directive_re = re.compile("(%\w+(\([^\)]*\))?\s+)(.*)")
|
||||
directive_re = re.compile(r"(%\w+(\([^\)]*\))?\s+)(.*)")
|
||||
parts = directive_re.match(filename)
|
||||
if parts:
|
||||
# Add prefix to the output
|
||||
|
||||
+5
-5
@@ -273,9 +273,9 @@ def download_tarball(target_dir):
|
||||
config_f = configparser.ConfigParser(interpolation=None)
|
||||
config_f.read('options.conf')
|
||||
if "package" in config_f.sections():
|
||||
if (config_f["package"].get("name") == name or
|
||||
config_f["package"].get("url") == url or
|
||||
config_f["package"].get("archives") == " ".join(archives)):
|
||||
if (config_f["package"].get("name") == name
|
||||
or config_f["package"].get("url") == url
|
||||
or config_f["package"].get("archives") == " ".join(archives)):
|
||||
target = os.getcwd()
|
||||
if "giturl" in config_f["package"]:
|
||||
giturl = config_f["package"].get("giturl")
|
||||
@@ -427,8 +427,8 @@ def name_and_version(name_arg, version_arg, filemanager):
|
||||
# Only take the repo name as the package name if it's more descriptive
|
||||
name = repo
|
||||
elif name != repo:
|
||||
name = re.sub("release-", '', name)
|
||||
name = re.sub("\d*$", '', name)
|
||||
name = re.sub(r"release-", '', name)
|
||||
name = re.sub(r"\d*$", '', name)
|
||||
rawname = name
|
||||
version = m.group(3).replace(name, '')
|
||||
if "archive" not in pattern:
|
||||
|
||||
+5
-5
@@ -81,11 +81,11 @@ def scan_for_tests(src_dir):
|
||||
"perlcheck": perl_check,
|
||||
"setup.py": setup_check,
|
||||
"cmake": "cd clr-build; " + cmake_check,
|
||||
"rakefile": "pushd %{buildroot}%{gem_dir}/gems/" +
|
||||
tarball.tarball_prefix +
|
||||
"\nrake --trace test TESTOPTS=\"-v\"\npopd",
|
||||
"rspec": "pushd %{buildroot}%{gem_dir}/gems/" +
|
||||
tarball.tarball_prefix + "\nrspec -I.:lib spec/\npopd"
|
||||
"rakefile": "pushd %{buildroot}%{gem_dir}/gems/"
|
||||
+ tarball.tarball_prefix
|
||||
+ "\nrake --trace test TESTOPTS=\"-v\"\npopd",
|
||||
"rspec": "pushd %{buildroot}%{gem_dir}/gems/"
|
||||
+ tarball.tarball_prefix + "\nrspec -I.:lib spec/\npopd"
|
||||
}
|
||||
if config.config_opts['32bit']:
|
||||
testsuites["makecheck"] += "\ncd ../build32;\n" + make_check + " || :"
|
||||
|
||||
Reference in New Issue
Block a user