debian._util module

class debian._util.LinkedList(values: Iterable[T] | None = None)

Bases: Generic[T]

Specialized linked list implementation to support the deb822 parser needs

We deliberately trade “encapsulation” for features needed by this library to facilitate their implementation. Notably, we allow nodes to leak and assume well-behaved calls to remove_node - because that makes it easier to implement components like Deb822InvalidParagraphElement.

_size
append(value: T) LinkedListNode[T]
clear() None
extend(values: Iterable[T]) None
head_node: LinkedListNode[T] | None
insert_after(value: T, existing_node: LinkedListNode[T]) LinkedListNode[T]
insert_at_head(value: T) LinkedListNode[T]
insert_before(value: T, existing_node: LinkedListNode[T]) LinkedListNode[T]
insert_node_after(new_node: LinkedListNode[T], existing_node: LinkedListNode[T]) LinkedListNode[T]
insert_node_before(new_node: LinkedListNode[T], existing_node: LinkedListNode[T]) LinkedListNode[T]
iter_nodes() Iterator[LinkedListNode[T]]
pop() None
remove_node(node: LinkedListNode[T]) None
property tail: T | None
tail_node: LinkedListNode[T] | None
class debian._util.LinkedListNode(value: T)

Bases: Generic[T]

_previous_node: ReferenceType[LinkedListNode[T]] | None
insert_after(new_node: LinkedListNode[T]) None
insert_before(new_node: LinkedListNode[T]) None
iter_next(*, skip_current: bool | None = False) Iterator[LinkedListNode[T]]
iter_previous(*, skip_current: bool | None = False) Iterator[LinkedListNode[T]]
next_node: LinkedListNode[T] | None
property previous_node: LinkedListNode[T] | None
remove() T
value
class debian._util.OrderedSet(iterable: Iterable[str] | None = None)

Bases: object

A set-like object that preserves order when iterating over it

We use this to keep track of keys in Deb822Dict, because it’s much faster to look up if a key is in a set than in a list.

_reorder(item: str, reinserter: Callable[[str], LinkedListNode[str]]) None
add(item: str) None
append(item: str) None
extend(iterable: Iterable[str]) None
order_after(item: str, reference_item: str) None

Re-order the given item so appears directly before the reference item in the sequence

order_before(item: str, reference_item: str) None

Re-order the given item so appears directly after the reference item in the sequence

order_first(item: str) None

Re-order the given item so it is “first” in the set

order_last(item: str) None

Re-order the given item so it is “last” in the set

remove(item: str) None
class debian._util._CaseInsensitiveString(str_)

Bases: str

Case insensitive string.

lower() str

Return a copy of the string converted to lowercase.

str_lower
debian._util._strI

alias of _CaseInsensitiveString

debian._util.default_field_sort_key(x: str) Any
debian._util.resolve_ref(ref: ReferenceType[T] | None) T | None