MCPcopy Index your code
hub / github.com/RustPython/RustPython / set_flags

Method set_flags

Lib/mailbox.py:1740–1760  ·  view source on GitHub ↗

Set the given flags and unset all others.

(self, flags)

Source from the content-addressed store, hash-verified

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

Callers 2

add_flagMethod · 0.95
remove_flagMethod · 0.95

Calls 6

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

Tested by

no test coverage detected