debian_inspector.copyright module

class debian_inspector.copyright.BaseParagraph(line_numbers_by_field=NOTHING)

Bases: FieldMixin

Base paragraph with line numbers tracking.

dumps(**kwargs)

Return a string in Debian format for this field.

classmethod from_dict(data)
classmethod from_fields(fields, all_extra=False)

Return a paragraph built from a list of Deb822Field. If all_extra is True, treat all data as “extra_data”.

get_field_line_numbers(field_name)

Return a tuple of (start_line, end_line) for the field_name field.

get_field_names()

Return a list of field names defined on this paragraph.

get_first_last_line_numbers()

Return a tuple of (first line, last line) number of this paragraph.

has_extra_data()
is_empty()

Return True if all fields are empty

to_dict(with_extra_data=True, with_lines=False)
class debian_inspector.copyright.CatchAllParagraph(line_numbers_by_field=NOTHING, extra_data=NOTHING)

Bases: BaseParagraph

A catch-all paragraph: everything is fed to the extra_data. Every field is treated as formatted text.

classmethod from_fields(fields)

Return a paragraph built from a list of Deb822Field. If all_extra is True, treat all data as “extra_data”.

is_all_unknown()

Return True if this is an “unknown” field. We use the “unknown” field name for things that do not have a name.

is_valid(strict=False)
class debian_inspector.copyright.CopyrightField(statements=NOTHING)

Bases: FieldMixin

This represents a single “Copyright:” field which is a plain formatted text but is conventionally a list of copyrights statements one per line

dumps(**kwargs)

Return a string in Debian format for this field.

classmethod from_value(value)
class debian_inspector.copyright.CopyrightFilesParagraph(line_numbers_by_field=NOTHING, files=None, copyright=None, license=None, comment=None, extra_data=NOTHING)

Bases: BaseParagraph

A “files” paragraph with files, copyright, license and comment fields.

https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#files-paragraph

dumps(**kwargs)

Return a string in Debian format for this field.

is_empty()

Return True if this is empty.

is_valid(strict=False)
class debian_inspector.copyright.CopyrightHeaderParagraph(line_numbers_by_field=NOTHING, format=None, upstream_name=None, upstream_contact=None, source=None, disclaimer=None, copyright=None, license=None, comment=None, files_excluded=None, extra_data=NOTHING)

Bases: BaseParagraph

The header paragraph.

https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#header-paragraph

is_valid(strict=False)
class debian_inspector.copyright.CopyrightLicenseParagraph(line_numbers_by_field=NOTHING, license=None, comment=None, extra_data=NOTHING)

Bases: BaseParagraph

A standalone license paragraph with license and comment fields, but no files.

https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#stand-alone-license-paragraph

dumps(**kwargs)

Return a string in Debian format for this field.

is_empty()

Return True if this is empty (e.g. was crated only because of a ‘License:’ empty field.

is_valid(strict=False)
class debian_inspector.copyright.CopyrightStatementField(holder, year_range=None)

Bases: FieldMixin

Conventionally (but not in the spec) each line in a copyright is a space- separated tuple of (year range, holder). If it cannot be parsed, the holder contains all text. This field represents one line, e.g. one statememt.

dumps(**kwargs)

Return a string in Debian format for this field.

classmethod from_value(value)
class debian_inspector.copyright.DebianCopyright(paragraphs=NOTHING)

Bases: object

A machine-readable debian copyright file. See https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

dumps(**kwargs)
fold_contiguous_empty_license_followed_by_unknown()

Update self.paragraphs, such that a CatchAllParagraph paragraph with “unknown” as license text is merged into a preceding empty (e.g. without any text) CopyrightLicenseParagraph paragraph.

classmethod from_fields_groups(fields_groups)

Return a DebianCopyright from a fields_groups list of list of Deb822Field.

classmethod from_file(location)
classmethod from_text(text)
get_header()

Return the header paragraph or None.

is_valid(strict=False)

Return True if this is a valid Debian Copyright file. If strict is True, validate strictly against the spec.

merge_contiguous_unknown_paragraphs()

Update self.paragraphs, merging contiguous unknown-only CatchAllParagraph paragraphs in one.

to_dict(with_lines=False)
class debian_inspector.copyright.LicenseField(name=None, text=None)

Bases: FieldMixin

dumps(**kwargs)

Return a string in Debian format for this field.

classmethod from_value(value)
has_doc_reference()

Return True if this license contains a reference to a Debian shared license file in the /usr/share/common-licenses directory.

class debian_inspector.copyright.MaintainerField(name, email_address=None)

Bases: FieldMixin

https://www.debian.org/doc/debian-policy/ch-controlfields#s-f-maintainer 5.6.2. Maintainer

dumps(**kwargs)

Return a string in Debian format for this field.

classmethod from_value(value)

Return True if a text is for a machine-readable copyright format.

debian_inspector.copyright.is_year_range(text)

Return True if text is a year range.