class documentation

class HeaderSet(MutableSet):

View In Hierarchy

Similar to the ETags class this implements a set-like structure. Unlike ETags this is case insensitive and used for vary, allow, and content-language headers.

If not constructed using the parse_set_header function the instantiation works like this:

>>> hs = HeaderSet(['foo', 'bar', 'baz'])
>>> hs
HeaderSet(['foo', 'bar', 'baz'])
Method __bool__ Undocumented
Method __contains__ Undocumented
Method __delitem__ Undocumented
Method __getitem__ Undocumented
Method __init__ Undocumented
Method __iter__ Undocumented
Method __len__ Undocumented
Method __repr__ Undocumented
Method __setitem__ Undocumented
Method __str__ Undocumented
Method add Add a new header to the set.
Method as​_set Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost.
Method clear Clear the set.
Method discard Like remove but ignores errors.
Method find Return the index of the header in the set or return -1 if not found.
Method index Return the index of the header in the set or raise an IndexError.
Method remove Remove a header from the set. This raises an KeyError if the header is not in the set.
Method to​_header Convert the header set into an HTTP header string.
Method update Add all the headers from the iterable to the set.
Instance Variable on​_update Undocumented
Instance Variable ​_headers Undocumented
Instance Variable ​_set Undocumented
def __bool__(self):

Undocumented

def __contains__(self, header):

Undocumented

def __delitem__(self, idx):

Undocumented

def __getitem__(self, idx):

Undocumented

def __init__(self, headers=None, on_update=None):

Undocumented

def __iter__(self):

Undocumented

def __len__(self):

Undocumented

def __repr__(self):

Undocumented

def __setitem__(self, idx, value):

Undocumented

def __str__(self):

Undocumented

def add(self, header):
Add a new header to the set.
def as_set(self, preserve_casing=False):
Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost.
Parameters
preserve​_casingif set to True the items in the set returned will have the original case like in the HeaderSet, otherwise they will be lowercase.
def clear(self):
Clear the set.
def discard(self, header):
Like remove but ignores errors.
Parameters
headerthe header to be discarded.
def find(self, header):
Return the index of the header in the set or return -1 if not found.
Parameters
headerthe header to be looked up.
def index(self, header):
Return the index of the header in the set or raise an IndexError.
Parameters
headerthe header to be looked up.
def remove(self, header):

Remove a header from the set. This raises an KeyError if the header is not in the set.

Changed in version 0.5: In older versions a IndexError was raised instead of a KeyError if the object was missing.
Parameters
headerthe header to be removed.
def to_header(self):
Convert the header set into an HTTP header string.
def update(self, iterable):
Add all the headers from the iterable to the set.
Parameters
iterableupdates the set with the items from the iterable.
on_update =

Undocumented

_headers =

Undocumented

_set =

Undocumented