/head: changeset 6
Updated -- more writing
This commit is contained in:
parent
ab27fdaad7
commit
abcbfd9b2f
29
head/Makefile
Normal file
29
head/Makefile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Copyright (C) 2002 John Goerzen
|
||||||
|
# <jgoerzen@complete.org>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
doc:
|
||||||
|
PYTHONPATH=`pwd` pydoc2.2 dictdlib > dictdlib.txt
|
||||||
|
PYTHONPATH=`pwd` pydoc2.2 -w dictdlib
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f `find . -name "*~"`
|
||||||
|
-rm -f `find . -name "*.pyc"`
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
cvs2cl
|
||||||
|
cvs commit ChangeLog
|
||||||
|
rm ChangeLog.bak
|
@ -17,7 +17,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from imapsync import imaplib, imaputil, imapserver
|
from imapsync import imaplib, imaputil, imapserver, repository, folder
|
||||||
import re
|
import re
|
||||||
import getpass
|
import getpass
|
||||||
|
|
||||||
@ -28,3 +28,5 @@ passwd = getpass.getpass('Password: ')
|
|||||||
server = imapserver.IMAPServer(user, passwd, host, ssl = 1)
|
server = imapserver.IMAPServer(user, passwd, host, ssl = 1)
|
||||||
imapobj = server.makeconnection()
|
imapobj = server.makeconnection()
|
||||||
delim, root = imaputil.imapsplit(imapobj.list('""', '""')[1][0])[1:]
|
delim, root = imaputil.imapsplit(imapobj.list('""', '""')[1][0])[1:]
|
||||||
|
|
||||||
|
repos = repository.IMAP.IMAPRepository(server)
|
||||||
|
0
head/offlineimap/__init__.py
Normal file
0
head/offlineimap/__init__.py
Normal file
34
head/offlineimap/folder/Base.py
Normal file
34
head/offlineimap/folder/Base.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Base folder support
|
||||||
|
# Copyright (C) 2002 John Goerzen
|
||||||
|
# <jgoerzen@complete.org>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
class BaseFolder:
|
||||||
|
def getname(self):
|
||||||
|
"""Returns name"""
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def getroot(self):
|
||||||
|
"""Returns the root of the folder, in a folder-specific fashion."""
|
||||||
|
return self.root
|
||||||
|
|
||||||
|
def getsep(self):
|
||||||
|
"""Returns the separator for this folder type."""
|
||||||
|
return self.sep
|
||||||
|
|
||||||
|
def getfullname(self):
|
||||||
|
return self.getroot() + self.getsep() + self.getname()
|
||||||
|
|
28
head/offlineimap/folder/IMAP.py
Normal file
28
head/offlineimap/folder/IMAP.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# IMAP folder support
|
||||||
|
# Copyright (C) 2002 John Goerzen
|
||||||
|
# <jgoerzen@complete.org>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
from Base import BaseFolder
|
||||||
|
from imapsync import imaputil
|
||||||
|
|
||||||
|
class IMAPFolder(BaseFolder):
|
||||||
|
def __init__(self, imapserver, name):
|
||||||
|
self.name = imaputil.dequote(name)
|
||||||
|
self.root = imapserver.root
|
||||||
|
self.sep = imapserver.delim
|
||||||
|
self.imapserver = imapserver
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
import Base, IMAP
|
@ -16,7 +16,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from imapsync import imaplib
|
from imapsync import imaplib, imaputil
|
||||||
|
|
||||||
class IMAPServer:
|
class IMAPServer:
|
||||||
def __init__(self, username, password, hostname, port = None, ssl = 1):
|
def __init__(self, username, password, hostname, port = None, ssl = 1):
|
||||||
@ -25,12 +25,24 @@ class IMAPServer:
|
|||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.port = port
|
self.port = port
|
||||||
self.usessl = ssl
|
self.usessl = ssl
|
||||||
|
self.delim = None
|
||||||
|
self.root = None
|
||||||
if port == None:
|
if port == None:
|
||||||
if ssl:
|
if ssl:
|
||||||
self.port = 993
|
self.port = 993
|
||||||
else:
|
else:
|
||||||
self.port = 143
|
self.port = 143
|
||||||
|
|
||||||
|
def getdelim(self):
|
||||||
|
"""Returns this server's folder delimiter. Can only be called
|
||||||
|
after one or more calls to makeconnection."""
|
||||||
|
return self.delim
|
||||||
|
|
||||||
|
def getroot(self):
|
||||||
|
"""Returns this server's folder root. Can only be called after one
|
||||||
|
or more calls to makeconnection."""
|
||||||
|
return self.root
|
||||||
|
|
||||||
def makeconnection(self):
|
def makeconnection(self):
|
||||||
"""Opens a connection to the server and returns an appropriate
|
"""Opens a connection to the server and returns an appropriate
|
||||||
object."""
|
object."""
|
||||||
@ -42,6 +54,11 @@ class IMAPServer:
|
|||||||
imapobj = imaplib.IMAP4(self.hostname, self.port)
|
imapobj = imaplib.IMAP4(self.hostname, self.port)
|
||||||
|
|
||||||
imapobj.login(self.username, self.password)
|
imapobj.login(self.username, self.password)
|
||||||
|
|
||||||
|
if self.delim == None:
|
||||||
|
self.delim, self.root = \
|
||||||
|
imaputil.imapsplit(imapobj.list('""', '""')[1][0])[1:]
|
||||||
|
|
||||||
return imapobj
|
return imapobj
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@ def dequote(string):
|
|||||||
string = string.replace('\\\\', '\\')
|
string = string.replace('\\\\', '\\')
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
def flagsplit(string):
|
||||||
|
if string[0] != '(' or string[-1] != ')':
|
||||||
|
raise ValueError, "Passed string '%s' is not a flag list" % string
|
||||||
|
return string[1:-1].split(" ")
|
||||||
|
|
||||||
def imapsplit(string):
|
def imapsplit(string):
|
||||||
"""Takes a string from an IMAP conversation and returns a list containing
|
"""Takes a string from an IMAP conversation and returns a list containing
|
||||||
its components. One example string is:
|
its components. One example string is:
|
||||||
|
@ -17,10 +17,20 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from Base import BaseRepository
|
from Base import BaseRepository
|
||||||
|
from imapsync import folder, imaputil
|
||||||
|
|
||||||
class IMAPRepository(BaseRepository):
|
class IMAPRepository(BaseRepository):
|
||||||
def __init__(self, imapserver):
|
def __init__(self, imapserver):
|
||||||
"""Initialize an IMAPRepository object. Takes an IMAPServer
|
"""Initialize an IMAPRepository object. Takes an IMAPServer
|
||||||
object."""
|
object."""
|
||||||
self.imapserver = imapserver
|
self.imapserver = imapserver
|
||||||
|
self.imapobj = imapserver.makeconnection()
|
||||||
|
|
||||||
|
def getfolders(self):
|
||||||
|
retval = []
|
||||||
|
for string in self.imapobj.list(self.imapserver.root)[1]:
|
||||||
|
flags, delim, name = imaputil.imapsplit(string)
|
||||||
|
if '\\Noselect' in imaputil.flagsplit(flags):
|
||||||
|
continue
|
||||||
|
retval.append(folder.IMAP.IMAPFolder(self.imapserver, name))
|
||||||
|
return retval
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
import IMAP, Base
|
Loading…
Reference in New Issue
Block a user