3 """Produce a "sorted" list of maildir paths based on subdirs."""
5 from pathlib import Path
20 def find_dirs(topdir, ignored):
21 """Walk the subdirs following the KDE layout."""
22 for d in sorted(topdir.iterdir()):
23 if d.name in MAILDIR_DIRS:
28 if not d.is_symlink():
29 if (d / 'cur').is_dir():
31 subdir = topdir / f'.{d.name}.directory'
32 if subdir not in ignored and subdir.is_dir():
33 yield from find_dirs(subdir, ignored)
37 maildir = Path('~/.mail/').expanduser()
38 ignored = {maildir / x for x in IGNORED_DIRS}
40 results = find_dirs(maildir, ignored)
41 print(' '.join(f'"{x}"' for x in results))
45 if __name__ == '__main__':
46 sys.exit(main(sys.argv[1:]))