#!/usr/bin/python3

from lintian_brush.fixer import (
    package_is_native,
    report_result,
    fixed_lintian_tag,
    opinionated,
    )
import os
import sys

if not package_is_native():
    # Nothing to do
    sys.exit(0)

if not opinionated():
    sys.exit(0)

try:
    os.unlink('debian/upstream/metadata')
except FileNotFoundError:
    sys.exit(0)
else:
    fixed_lintian_tag('source', 'upstream-metadata-in-native-source', ())

if os.listdir('debian/upstream') == []:
    os.rmdir('debian/upstream')

report_result(
    'Remove debian/upstream/metadata in native source package.',
    certainty='certain')
def filter_by_tag(orig, changed, fields, tag):
    if all(field in orig for field in fields):
        return

    issue = LintianIssue('source', tag, info='')

    if (not all(field in orig for field in fields) and not issue.should_fix()):
        for field in fields:
            if field in changed:
                del changed[field]

    if all(field in orig or field in changed for field in fields):
        issue.report_fixed()


if package_is_native():
    # Native package
    sys.exit(0)

current_version = current_package_version()

missing_file_issue = LintianIssue('source',
                                  'upstream-metadata-file-is-missing',
                                  info=())

if (not os.path.exists('debian/upstream/metadata')
        and not missing_file_issue.should_fix()):
    sys.exit(0)

with YamlUpdater('debian/upstream/metadata') as editor:
    if isinstance(editor.code, str):
Beispiel #3
0
from lintian_brush import (
    certainty_to_confidence, )
from lintian_brush.fixer import (
    current_package_version,
    net_access_allowed,
    report_result,
    package_is_native,
    LintianIssue,
)
from lintian_brush.watch import (
    candidates_from_setup_py,
    candidates_from_upstream_metadata,
)

if os.path.exists('debian/watch') or package_is_native():
    # Nothing to do here..
    sys.exit(0)

issue = LintianIssue('source', 'debian-watch-file-is-missing', info='')

if not issue.should_fix():
    sys.exit(0)

candidates = []

good_upstream_versions = {current_package_version().upstream_version}

if os.path.exists('setup.py'):
    candidates.extend(
        candidates_from_setup_py('setup.py',