/Doc/library/mhlib.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 207 lines · 93 code · 114 blank · 0 comment · 0 complexity · a4cc53bcbaac84999383701241da1b31 MD5 · raw file

  1. :mod:`mhlib` --- Access to MH mailboxes
  2. =======================================
  3. .. module:: mhlib
  4. :synopsis: Manipulate MH mailboxes from Python.
  5. :deprecated:
  6. .. deprecated:: 2.6
  7. The :mod:`mhlib` module has been removed in Python 3.0. Use the
  8. :mod:`mailbox` instead.
  9. .. sectionauthor:: Skip Montanaro <skip@pobox.com>
  10. The :mod:`mhlib` module provides a Python interface to MH folders and their
  11. contents.
  12. The module contains three basic classes, :class:`MH`, which represents a
  13. particular collection of folders, :class:`Folder`, which represents a single
  14. folder, and :class:`Message`, which represents a single message.
  15. .. class:: MH([path[, profile]])
  16. :class:`MH` represents a collection of MH folders.
  17. .. class:: Folder(mh, name)
  18. The :class:`Folder` class represents a single folder and its messages.
  19. .. class:: Message(folder, number[, name])
  20. :class:`Message` objects represent individual messages in a folder. The Message
  21. class is derived from :class:`mimetools.Message`.
  22. .. _mh-objects:
  23. MH Objects
  24. ----------
  25. :class:`MH` instances have the following methods:
  26. .. method:: MH.error(format[, ...])
  27. Print an error message -- can be overridden.
  28. .. method:: MH.getprofile(key)
  29. Return a profile entry (``None`` if not set).
  30. .. method:: MH.getpath()
  31. Return the mailbox pathname.
  32. .. method:: MH.getcontext()
  33. Return the current folder name.
  34. .. method:: MH.setcontext(name)
  35. Set the current folder name.
  36. .. method:: MH.listfolders()
  37. Return a list of top-level folders.
  38. .. method:: MH.listallfolders()
  39. Return a list of all folders.
  40. .. method:: MH.listsubfolders(name)
  41. Return a list of direct subfolders of the given folder.
  42. .. method:: MH.listallsubfolders(name)
  43. Return a list of all subfolders of the given folder.
  44. .. method:: MH.makefolder(name)
  45. Create a new folder.
  46. .. method:: MH.deletefolder(name)
  47. Delete a folder -- must have no subfolders.
  48. .. method:: MH.openfolder(name)
  49. Return a new open folder object.
  50. .. _mh-folder-objects:
  51. Folder Objects
  52. --------------
  53. :class:`Folder` instances represent open folders and have the following methods:
  54. .. method:: Folder.error(format[, ...])
  55. Print an error message -- can be overridden.
  56. .. method:: Folder.getfullname()
  57. Return the folder's full pathname.
  58. .. method:: Folder.getsequencesfilename()
  59. Return the full pathname of the folder's sequences file.
  60. .. method:: Folder.getmessagefilename(n)
  61. Return the full pathname of message *n* of the folder.
  62. .. method:: Folder.listmessages()
  63. Return a list of messages in the folder (as numbers).
  64. .. method:: Folder.getcurrent()
  65. Return the current message number.
  66. .. method:: Folder.setcurrent(n)
  67. Set the current message number to *n*.
  68. .. method:: Folder.parsesequence(seq)
  69. Parse msgs syntax into list of messages.
  70. .. method:: Folder.getlast()
  71. Get last message, or ``0`` if no messages are in the folder.
  72. .. method:: Folder.setlast(n)
  73. Set last message (internal use only).
  74. .. method:: Folder.getsequences()
  75. Return dictionary of sequences in folder. The sequence names are used as keys,
  76. and the values are the lists of message numbers in the sequences.
  77. .. method:: Folder.putsequences(dict)
  78. Return dictionary of sequences in folder name: list.
  79. .. method:: Folder.removemessages(list)
  80. Remove messages in list from folder.
  81. .. method:: Folder.refilemessages(list, tofolder)
  82. Move messages in list to other folder.
  83. .. method:: Folder.movemessage(n, tofolder, ton)
  84. Move one message to a given destination in another folder.
  85. .. method:: Folder.copymessage(n, tofolder, ton)
  86. Copy one message to a given destination in another folder.
  87. .. _mh-message-objects:
  88. Message Objects
  89. ---------------
  90. The :class:`Message` class adds one method to those of
  91. :class:`mimetools.Message`:
  92. .. method:: Message.openmessage(n)
  93. Return a new open message object (costs a file descriptor).