]>
git.wh0rd.org - home.git/blob - .config/mutt/list-mailboxes.py
3 """Produce a "sorted" list of maildir paths based on subdirs."""
5 from __future__
import print_function
8 from pathlib
import Path
23 def find_dirs(topdir
, ignored
):
24 """Walk the subdirs following the KDE layout."""
25 for d
in sorted(topdir
.iterdir()):
26 if d
.name
in MAILDIR_DIRS
:
31 if not d
.is_symlink():
32 if (d
/ 'cur').is_dir():
34 subdir
= topdir
/ f
'.{d.name}.directory'
35 if subdir
not in ignored
and subdir
.is_dir():
36 yield from find_dirs(subdir
, ignored
)
40 maildir
= Path('~/.mail/').expanduser()
41 ignored
= {maildir
/ x
for x
in IGNORED_DIRS
}
43 results
= find_dirs(maildir
, ignored
)
44 print(' '.join(f
'"{x}"' for x
in results
))
48 if __name__
== '__main__':
49 sys
.exit(main(sys
.argv
[1:]))