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: |
|
---|
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.
Retrieves string from the configuration.
Retrieves string from the configuration transforming the result.
Retrieves boolean value from the configuration.
Retrieves floating-point value from the configuration.
Retrieves integer value from the configuration.
Retrieves strings from the configuration and splits it into the list of strings.
Local root folder for storing messages. Will not be set for remote repositories.
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.
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.
Parameters: |
|
---|
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.
WARNING: This function is a bit tricky, and modifying it in the wrong way, may easily lead to data-loss.
Arguments: - content: message content, headers and body as a single string - linebreak: string that carries line ending - headername: name of the header to add - headervalue: value of the header to add
Note
The following documentation will not get displayed correctly after being processed by Sphinx. View the source of this method to read it.
This has to deal with strange corner cases where the header is missing or empty. Here are illustrations for all the cases, showing where the header gets inserted and what the end result is. In each illustration, ‘+’ means the added contents. Note that these examples assume LF for linebreak, not CRLF, so ‘
‘ then you would have to substitute ‘ ‘ for
‘
‘ in the below examples.
- Case 1: No ‘
‘, leading ‘ ‘
+X-Flying-Pig-Header: i am here
This is the body
next line
- Case 2: ‘
‘ at position 0
+X-Flying-Pig-Header: i am here
This is the body
next line
- Case 3: No ‘
‘, no leading ‘ ‘
+X-Flying-Pig-Header: i am here
This is the body
next line
- Case 4: ‘
‘ at non-zero position
Subject: Something wrong with OI
From: some@person.at +
X-Flying-Pig-Header: i am here
This is the body
next line
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. |
---|
Combine the message’s flags and keywords using the mapping for the destination folder.
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.
maxage is allowed to be either an integer or a date of the form YYYY-mm-dd. This returns a time_struct.
Searches for the first occurence of the given header and returns its value. Header name is case-insensitive.
Arguments: - contents: message itself - name: name of the header to be searched
Returns: header value or None if no such header was found
Searches for the given header and returns a list of values for that header.
Arguments: - contents: message itself - name: name of the header to be searched
Returns: list of header values or emptylist if no such header was found
Gets the current message list.
You must call cachemessagelist() before calling this function!
Gets a list of UIDs.
You may have to call cachemessagelist() before calling this function!
Returns value for empty messagelist element with given UID.
This function must initialize all fields of messagelist item and must be called every time when one creates new messagelist entry to ensure that all fields that must be present are present.
Runs quick check for folder changes and returns changed status: True – changed, False – not changed.
Parameters: | 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.
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: |
|
---|