MCPcopy Index your code
hub / github.com/python/cpython / set_flags

Method set_flags

Lib/mailbox.py:1747–1767  ·  view source on GitHub ↗

Set the given flags and unset all others.

(self, flags)

Source from the content-addressed store, hash-verified

1745 return self.get('Status', '') + self.get('X-Status', '')
1746
1747 def set_flags(self, flags):
1748 """Set the given flags and unset all others."""
1749 flags = set(flags)
1750 status_flags, xstatus_flags = '', ''
1751 for flag in ('R', 'O'):
1752 if flag in flags:
1753 status_flags += flag
1754 flags.remove(flag)
1755 for flag in ('D', 'F', 'A'):
1756 if flag in flags:
1757 xstatus_flags += flag
1758 flags.remove(flag)
1759 xstatus_flags += ''.join(sorted(flags))
1760 try:
1761 self.replace_header('Status', status_flags)
1762 except KeyError:
1763 self.add_header('Status', status_flags)
1764 try:
1765 self.replace_header('X-Status', xstatus_flags)
1766 except KeyError:
1767 self.add_header('X-Status', xstatus_flags)
1768
1769 def add_flag(self, flag):
1770 """Set the given flag(s) without changing others."""

Callers 2

add_flagMethod · 0.95
remove_flagMethod · 0.95

Calls 5

setFunction · 0.85
replace_headerMethod · 0.80
removeMethod · 0.45
joinMethod · 0.45
add_headerMethod · 0.45

Tested by

no test coverage detected