Commit 83da94fe authored by Jelmer Vernooij's avatar Jelmer Vernooij

Add fixer for debian-control-has-empty-field.

parent 587010df
from lintian_brush.control import update_control
import sys
removed = []
def rm_empty_field(control):
for k, v in control.items():
if not v.strip():
del control[k]
update_control(source_package_cb=rm_empty_field, binary_package_cb=rm_empty_field)
print "debian/control: Remove empty control field%s %s." % (
"s" if len(removed) > 1 else "",
", ".join(removed),
......@@ -4,6 +4,7 @@ from breezy.trace import note
import os
import subprocess
import sys
class NoChanges(Exception):
......@@ -23,7 +24,7 @@ class Fixer(object):
def available_lintian_fixers():
fixer_scripts = {}
fixers_dir = os.path.join(os.path.dirname(__file__), 'fixers', 'lintian')
fixers_dir = os.path.join(os.path.dirname(__file__), '..', 'fixers', 'lintian')
for n in os.listdir(fixers_dir):
if n.endswith("~") or n.startswith("."):
......@@ -46,7 +47,7 @@ def run_lintian_fixer(local_tree, fixer, update_changelog=True):
if list(local_tree.iter_changes(local_tree.basis_tree())):
raise AssertionError("Local tree %s has changes" % local_tree.basedir)
note('Running fixer %s on %s', fixer.tag, local_tree.branch.user_url)
p = subprocess.Popen(fixer.script_path, cwd=local_tree.basedir, stdout=subprocess.PIPE)
p = subprocess.Popen(fixer.script_path, cwd=local_tree.basedir, stdout=subprocess.PIPE, stderr=sys.stderr)
(description, err) = p.communicate("")
if p.returncode != 0:
raise ScriptFailed("Script %s failed with error code %d" % (
File mode changed from 100644 to 100755
from io import BytesIO
from debian.deb822 import Deb822
import sys
def update_control(path='debian/control', **kwargs):
outf = BytesIO()
with open(path, 'rb') as f:
update_control_file(f, outf, **kwargs)
with open(path, 'wb') as f:
def update_control_file(inf, outf, source_package_cb=None, binary_package_cb=None):
control = Deb822(inf, encoding='utf-8')
if source_package_cb:
while control:
control.dump(fd=outf, encoding='utf-8')
control = Deb822(inf, encoding='utf-8')
if control:
if binary_package_cb:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment