mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
gh-66515: mailbox.MH now supports folders withou the ".mh_sequences" file (GH-804)
(for example Claws Mail IMAP-cache folders).
This commit is contained in:
parent
b5dc0f83ad
commit
e87cadc1ce
4 changed files with 26 additions and 3 deletions
|
@ -1198,7 +1198,11 @@ class MH(Mailbox):
|
|||
def get_sequences(self):
|
||||
"""Return a name-to-key-list dictionary to define each sequence."""
|
||||
results = {}
|
||||
with open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII') as f:
|
||||
try:
|
||||
f = open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII')
|
||||
except FileNotFoundError:
|
||||
return results
|
||||
with f:
|
||||
all_keys = set(self.keys())
|
||||
for line in f:
|
||||
try:
|
||||
|
@ -1221,9 +1225,8 @@ class MH(Mailbox):
|
|||
|
||||
def set_sequences(self, sequences):
|
||||
"""Set sequences using the given name-to-key-list dictionary."""
|
||||
f = open(os.path.join(self._path, '.mh_sequences'), 'r+', encoding='ASCII')
|
||||
f = open(os.path.join(self._path, '.mh_sequences'), 'w', encoding='ASCII')
|
||||
try:
|
||||
os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))
|
||||
for name, keys in sequences.items():
|
||||
if len(keys) == 0:
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue