A derivative of class Base.BaseRepository represents an email repository depending on the type of storage, possible options are:
Which class you need depends on your account configuration. The helper class offlineimap.repository.Repository is an autoloader, that returns the correct class depending on your configuration. So when you want to instanciate a new offlineimap.repository, you will mostly do it through this class.
Abstract class that returns the correct Repository type instance based on ‘account’ and ‘reqtype’, e.g. a class:ImapRepository instance.
Load the correct Repository type and return that. The __init__ of the corresponding Repository class will be executed instead of this stub
Parameters: |
|
---|
Account name as string
Establish a connection to the remote, if necessary. This exists so that IMAP connections can all be established up front, gathering passwords as needed. It was added in order to support the error recovery – we need to connect first outside of the error trap in order to validate the password, and that’s the point of this function.
Forgets the cached list of folders, if any. Useful to run after a sync run.
Is folder creation enabled on this repository?
It is disabled by either setting the whole repository ‘readonly’ or by using the ‘createfolders’ setting.
Returns a list of ALL folders on this server.
Local root folder for storing messages. Will not be set for remote repositories.
Create a new folder
Is the repository readonly?
Sets folders’ atime back to their values after a sync
Controlled by the ‘restoreatime’ config parameter (default False), applies only to local Maildir mailboxes and does nothing on all other repository types.
Should this folder be synced?
The default implementation will do nothing.
Stop keep alive, but don’t bother waiting for the threads to terminate.
Syncs the folders in this repository to those in dest.
It does NOT sync the contents of those folders. nametrans rules in both directions will be honored, but there are NO checks yet that forward and backward nametrans actually match up! Configuring nametrans on BOTH repositories therefore could lead to infinite folder creation cycles.
Initialize an IMAPRepository object.
Initialize an IMAPRepository object.
Gmail IMAP repository.
Falls back to hard-coded gmail host name and port, if none were specified: http://mail.google.com/support/bin/answer.py?answer=78799&topic=12814
Initialize a GmailRepository object.
Initialize a MaildirRepository object. Takes a path name to the directory holding all the Maildir directories.
Para name: | Path & name of folder minus root or reference |
---|---|
Para repository: | |
Repository() in which the folder is. |
Account name as string
Adds the specified flags to the message’s flag set. If a given flag is already present, it will not be duplicated.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Parameters: | flags – A set() of flags |
---|
Adds new header to the provided message.
Arguments: - content: message content, headers and body as a single string - crlf: string that carries line ending - headername: name of the header to add - headervalue: value of the header to add
Adds the specified labels to the message’s labels set. If a given label is already present, it will not be duplicated.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Parameters: | labels – A set() of labels |
---|
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Reads the message list from disk or network and stores it in memory for later use. This list will not be re-read from disk or memory unless this function is called again.
Change the message from existing uid to new_uid
If the backend supports it (IMAP does not).
Parameters: | new_uid – (optional) If given, the old UID will be changed to a new UID. This allows backends efficient renaming of messages if the UID has changed. |
---|
Tests if the cached UIDVALIDITY match the real current one
If required it saves the UIDVALIDITY value. In this case the function is not threadsafe. So don’t attempt to call it from concurrent threads.
Returns: | Boolean indicating the match. Returns True in case it implicitely saved the UIDVALIDITY. |
---|
Copies a message from self to dst if needed, updating the status
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Parameters: |
|
---|---|
Returns: | Nothing on success, or raises an Exception. |
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Removes each flag given from the message’s flag set. If a given flag is already removed, no action will be taken for that flag.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Deletes headers in the given list from the message content.
Arguments: - content: message itself - header_list: list of headers to be deleted or just the header name
We expect our message to have ‘
‘ as line endings.
Removes each label given from the message’s label set. If a given label is already removed, no action will be taken for that label.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Return the previously cached UIDVALIDITY value
Returns: | UIDVALIDITY as (long) number or None, if None had been saved yet. |
---|
Retrieve the current connections UIDVALIDITY value
This function needs to be implemented by each Backend :returns: UIDVALIDITY as a (long) number
For threading folders, returns the instancelimitname for InstanceLimitedThreads.
Return base file name of file to store Status/UID info in
Returns the content of the specified message.
Gets the number of messages.
Returns the flags for the specified message.
Searches for the given header and returns its value. Arguments: - contents: message itself - name: name of the header to be searched
Returns: header value or None if no such header was found
Returns the labels for the specified message.
Gets the current message list. You must call cachemessagelist() before calling this function!
Returns the message modification time of the specified message.
Return the received time for the specified message.
Gets a list of UIDs. You may have to call cachemessagelist() before calling this function!
Returns name
Returns the repository object that this folder is within.
Returns the root of the folder, in a folder-specific fashion.
Returns the separator for this folder type.
The nametrans-transposed name of the folder’s name
Runs quick check for folder changes and returns changed status: True – changed, False – not changed. :param statusfolder: keeps track of the last known folder state.
Save the UIDVALIDITY value of the folder to the cache
This function is not threadsafe, so don’t attempt to call it from concurrent threads.
Writes a new message, with the specified uid.
return it. In case it cannot assign a new uid, it returns the negative uid passed in WITHOUT saving the message.
If the backend CAN assign a new uid, but cannot find out what this UID is (as is the case with some IMAP servers), it returns 0 but DOES save the message.
IMAP backend should be the only one that can assign a new uid.
Note that savemessage() does not check against dryrun settings, so you need to ensure that savemessage is never called in a dryrun mode.
Sets the specified message’s flags to the given set.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Sets the specified message’s labels to the given set.
Note that this function does not check against dryrun settings, so you need to ensure that it is never called in a dryrun mode.
Should be true for any backend that actually saves message bodies. (Almost all of them). False for the LocalStatus backend. Saves us from having to slurp up messages just for localstatus purposes.
Returns true if this folder suggests using threads for actions; false otherwise. Probably only IMAP will return true.
Should this folder be synced or is it e.g. filtered out?
Syncs messages in this folder to the destination dstfolder.
This is the high level entry for syncing messages in one direction. Syncsteps are:
Get all UIDS in statusfolder but not self. These are messages that were deleted in ‘self’. Delete those from dstfolder and statusfolder.
After this pass, the message lists should be identical wrt the uids present (except for potential negative uids that couldn’t be placed anywhere).
Parameters: |
|
---|
Returns True if uid exists
Implements method that waits for thread to be usable. Should be implemented only for folders that suggest threads.