debian_inspector.debcon module
- class debian_inspector.debcon.AnyWhiteSpaceSeparatedField(values)
Bases:
FieldMixin
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#white-space-lists This is a list of values where each item is itself a space-separated list.
- dumps(**kwargs)
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.Debian822(data=None)
Bases:
MutableMapping
A mapping-like class that corresponds to a single deb822 paragraph like a whole .dsc file.
- dump(file_like=None, **kwargs)
- dumps(**kwargs)
Return a text that resembles the original Debian822 format. This is not meant to be a high fidelity rendering and not meant to be used as-is in control files.
- classmethod from_file(location, remove_pgp_signature=True)
- classmethod from_string(text)
- to_dict(normalize_names=False)
- class debian_inspector.debcon.DescriptionField(synopsis=None, text=None)
Bases:
FieldMixin
https://www.debian.org/doc/debian-policy/ch-controlfields#description 5.6.13. Description
- dumps(**kwargs)
Return a string representation of self.
- classmethod from_value(value)
- class debian_inspector.debcon.FieldMixin
Bases:
object
Base mixin for attrs-based fields.
- classmethod attrib(**kwargs)
Return an attrib class
- dumps()
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.File(name=None, size=None, md5=None, sha1=None, sha256=None, sha512=None)
Bases:
object
- class debian_inspector.debcon.FileField(name=None, size=None, checksum=None)
Bases:
FieldMixin
- dumps(**kwargs)
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.FilesField(values)
Bases:
FieldMixin
This is a list of FileField
- dumps(**kwargs)
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.FormattedTextField(text)
Bases:
FieldMixin
https://www.debian.org/doc/debian-policy/ch-controlfields#description Like Description, but there is no special meaning for the first line.
- dumps(**kwargs)
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.LineAndSpaceSeparatedField(values)
Bases:
FieldMixin
This is a list of values where each item is itself a space-separated list.
- dumps(**kwargs)
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.LineSeparatedField(values)
Bases:
FieldMixin
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#line-based-lists
- dumps(**kwargs)
Return a string in Debian format for this field.
- classmethod from_value(value)
- class debian_inspector.debcon.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)
- class debian_inspector.debcon.SingleLineField(value)
Bases:
FieldMixin
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#single-line
- dumps()
Return a string in Debian format for this field.
- classmethod from_value(value)
- debian_inspector.debcon.as_formatted_lines(lines)
Return a text formatted for use in a Debian control file with proper continuation for multilines.
- debian_inspector.debcon.as_formatted_text(text)
Return a text formatted for use in a Debian control file with proper continuation for multilines.
- debian_inspector.debcon.collect_file(value)
Yield tuples of (name, size, digest) given a Debian “Files” value string which contains digest, size and name.
- debian_inspector.debcon.collect_files(data)
Return a mapping of {name: File} from a Debian data mapping.
Note: the Files and Checksums-* fields have the same structure and contain redundant data.
- debian_inspector.debcon.comma_separated(value)
- debian_inspector.debcon.comma_space_separated(value)
- debian_inspector.debcon.from_formatted_lines(lines)
Return text from a list of lines strings using the Debian Description rules for handling line prefixes and continuations.
- debian_inspector.debcon.from_formatted_text(text)
Return cleaned text from a Debian formatted description text using rules for handling line prefixes and continuations.
- debian_inspector.debcon.get_paragraph_data(text, remove_pgp_signature=False)
Return paragraph data from the Debian control text. The paragraph data is an ordered mapping of {name: value} fields. If there is data that is not parsable or not attached to a field name, this will be added to a field named “unknown”.
If there are duplicates field names, the string values of duplicates field names are merged together with a new line in the first occurence of that field.
Optionally remove a wrapping PGP signature if remove_pgp_signature is True.
- debian_inspector.debcon.get_paragraph_data_from_file(location, remove_pgp_signature=False)
Return paragraph data from the Debian control file at location that contains a single paragraph (e.g. a dsc file).
Optionally remove a wrapping PGP signature if remove_pgp_signature is True.
- debian_inspector.debcon.get_paragraphs_data(text)
Yield paragraph data mappings from the Debian control text string that contains multiple paragraphs (e.g. Package, status, copyright file, etc.).
- debian_inspector.debcon.get_paragraphs_data_from_file(location)
Yield paragraph data mappings from the Debian control file at location that contains multiple paragraphs (e.g. Package, status, copyright file, etc.).
- debian_inspector.debcon.line_separated(value)
Return a list of values from a value string using line as list delimiters.
- debian_inspector.debcon.load_control_file(control_file)
Load a control file and return the parsed control fields.
- Parameters:
control_file – The filename of the control file to load (a string).
- Returns:
A dictionary created by
parse_control_fields()
.
- debian_inspector.debcon.normalize_control_field_name(name)
Return a case-normalized field name string.
Normalization of control file field names is not really needed when reading as we lowercase everything and replace dash to underscore internally, but it can help to compare the parsing results to the original file while testing.
According to the Debian Policy Manual field names are not case-sensitive, however a conventional capitalization is most common and not using it may break hings.
http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-controlsyntax
- debian_inspector.debcon.parse_control_fields(input_fields, deps_fields=frozenset({'Breaks', 'Build-Conflicts', 'Build-Conflicts-Arch', 'Build-Conflicts-Indep', 'Build-Depends', 'Build-Depends-Arch', 'Build-Depends-Indep', 'Built-Using', 'Conflicts', 'Depends', 'Enhances', 'Pre-Depends', 'Provides', 'Recommends', 'Replaces', 'Suggests'}))
Return an ordered mapping from parsing an`input_fields` mapping of Debian control file fields. This applies a few conversions such as:
The values of the fields that contain dependencies are parsed into Python data structures.
The value of some fields such as Installed-Size from a string to a native type (here an integer).
- debian_inspector.debcon.read_text_file(location)
Return the content of the file at location as text or None.
- debian_inspector.debcon.space_separated(value)
Return a list of values from a value string using one or more whitespace as list items delimiter. Empty values are NOT returned.
- debian_inspector.debcon.split_in_paragraphs(text)
Yield paragraphs from a text string that contains one or more paragraph separated by empty lines. Each paragraph is a string.