Commit 1417084b 1417084b72f9a2eb6547b65982e314e07fd9b012 by Wojciech Polak

Minor PEP 8 changes in Python API.

1 parent cea1ebcb
......@@ -33,10 +33,9 @@ is licensed using the GNU GPL.
See http://www.gnu.org/software/mailutils/ for more information about
GNU Mailutils.
"""
__all__ = [
__all__ = (
"error",
"address",
"attribute",
......@@ -59,4 +58,4 @@ __all__ = [
"stream",
"url",
"util",
]
)
......
......@@ -83,28 +83,28 @@ class Address:
def get_domain (self, n):
"""Return domain part of the Nth email address."""
status, domain = address.get_domain (self.addr, n)
status, domain = address.get_domain (self.addr, n)
if status:
raise AddressError (status)
return domain
def get_personal (self, n):
"""Return personal part of the Nth email address."""
status, personal = address.get_personal (self.addr, n)
status, personal = address.get_personal (self.addr, n)
if status:
raise AddressError (status)
return personal
def get_comments (self, n):
"""Return comment part of the Nth email address."""
status, comments = address.get_comments (self.addr, n)
status, comments = address.get_comments (self.addr, n)
if status:
raise AddressError (status)
return comments
def get_route (self, n):
"""Return the route part of the Nth email address."""
status, route = address.get_route (self.addr, n)
status, route = address.get_route (self.addr, n)
if status:
raise AddressError (status)
return route
......
......@@ -21,7 +21,7 @@ from mailutils.error import AuthError
MU_AF_QUOTA = 0x1
def register_module (name = None):
def register_module (name=None):
if name == None:
status = auth.register_module ()
elif isinstance (name, types.TupleType) \
......@@ -51,7 +51,7 @@ def set_pam_service (pam_service):
class Authority:
__owner = False
def __init__ (self, authority = None):
def __init__ (self, authority=None):
if isinstance (authority, auth.AuthorityType):
self.authority = authority
else:
......@@ -85,7 +85,7 @@ class Authority:
class Ticket:
__owner = False
def __init__ (self, ticket = None):
def __init__ (self, ticket=None):
if isinstance (ticket, auth.TicketType):
self.ticket = ticket
else:
......@@ -108,7 +108,7 @@ class Ticket:
class Wicket:
__owner = False
def __init__ (self, wicket = None):
def __init__ (self, wicket=None):
if isinstance (wicket, auth.WicketType):
self.wicket = wicket
else:
......
......@@ -37,7 +37,7 @@ class Debug:
def __del__ (self):
del self.dbg
def set_level (self, level = MU_DEBUG_PROT):
def set_level (self, level=MU_DEBUG_PROT):
status = debug.set_level (self.dbg, level)
if status:
raise DebugError (status)
......
......@@ -29,8 +29,8 @@ MU_FILTER_WRITE = MU_STREAM_WRITE
MU_FILTER_RDWR = MU_STREAM_RDWR
class FilterStream (Stream):
def __init__ (self, transport, name, type = MU_FILTER_DECODE,
direction = MU_FILTER_READ):
def __init__ (self, transport, name, type=MU_FILTER_DECODE,
direction=MU_FILTER_READ):
Stream.__init__ (self)
status = filter.create (self.stm, transport.stm, name,
type, direction)
......
......@@ -77,7 +77,7 @@ class Folder:
raise FolderError (status)
return url.Url (u)
def list (self, dirname, pattern, max_level = 0):
def list (self, dirname, pattern, max_level=0):
status, lst = folder.list (self.folder, dirname, pattern, max_level)
if status:
raise FolderError (status)
......
......@@ -82,7 +82,7 @@ class Header:
raise HeaderError (status)
return lines
def get_value (self, name, default = None):
def get_value (self, name, default=None):
status, value = header.get_value (self.hdr, name)
if status == MU_ERR_NOENT:
if default != None:
......@@ -93,7 +93,7 @@ class Header:
raise HeaderError (status)
return value
def get_value_n (self, name, n = 1, default = None):
def get_value_n (self, name, n=1, default=None):
status, value = header.get_value_n (self.hdr, name, n)
if status == MU_ERR_NOENT:
if default != None:
......@@ -104,7 +104,7 @@ class Header:
raise HeaderError (status)
return value
def set_value (self, name, value, replace = True):
def set_value (self, name, value, replace=True):
status = header.set_value (self.hdr, name, value, replace)
if status:
raise HeaderError (status)
......
......@@ -24,7 +24,7 @@ from mailutils import debug
from mailutils.error import MailboxError
class MailboxBase:
def open (self, mode = 0):
def open (self, mode=0):
"""Open the connection.
'mode' may be a string, consisting of the characters described
......@@ -65,7 +65,7 @@ class MailboxBase:
if status:
raise MailboxError (status)
def flush (self, expunge = False):
def flush (self, expunge=False):
"""Flush the mailbox."""
status = mailbox.flush (self.mbox, expunge)
if status:
......@@ -216,7 +216,7 @@ class Mailbox (MailboxBase):
del self.mbox
class MailboxDefault (MailboxBase):
def __init__ (self, name = None):
def __init__ (self, name=None):
"""MailboxDefault creates a Mailbox object for the supplied
mailbox 'name'. Before creating, the name is expanded using
the rules below:
......
......@@ -37,7 +37,7 @@ class Mailer:
else:
raise AttributeError, name
def open (self, flags = 0):
def open (self, flags=0):
status = mailer.open (self.mlr, flags)
if status:
raise MailerError (status)
......
......@@ -25,7 +25,7 @@ from mailutils.error import MessageError
class Message:
__owner = False
def __init__ (self, msg = None):
def __init__ (self, msg=None):
if msg == None:
self.msg = message.MessageType ()
self.__owner = True
......@@ -141,7 +141,7 @@ class Message:
raise MessageError (status)
return name, lang
def save_attachment (self, filename = ''):
def save_attachment (self, filename=''):
status = message.save_attachment (self.msg, filename)
if status:
raise MessageError (status)
......
......@@ -23,7 +23,7 @@ MU_MIME_MULTIPART_MIXED = 0x1
MU_MIME_MULTIPART_ALT = 0x2
class Mime:
def __init__ (self, msg, flags = 0):
def __init__ (self, msg, flags=0):
self.mime = mime.MimeType ()
status = mime.create (self.mime, msg.msg, flags)
if status:
......
......@@ -18,7 +18,7 @@
import types
from mailutils.c_api import registrar
def register_format (name = None):
def register_format (name=None):
"""Register desired mailutils 'name' format.
A list or tuple of strings can be given.
......
......@@ -43,7 +43,7 @@ MU_STDERR_FD = 2
class Stream:
__refcount = 0
def __init__ (self, stm = None):
def __init__ (self, stm=None):
if isinstance (stm, stream.StreamType):
self.stm = stm
else:
......@@ -104,14 +104,14 @@ class Stream:
return rbuf
class TcpStream (Stream):
def __init__ (self, host, port, flags = MU_STREAM_READ):
def __init__ (self, host, port, flags=MU_STREAM_READ):
Stream.__init__ (self)
status = stream.tcp_stream_create (self.stm, host, port, flags)
if status:
raise StreamError (status)
class FileStream (Stream):
def __init__ (self, filename, flags = MU_STREAM_READ):
def __init__ (self, filename, flags=MU_STREAM_READ):
Stream.__init__ (self)
status = stream.file_stream_create (self.stm, filename, flags)
if status:
......@@ -125,7 +125,7 @@ class StdioStream (Stream):
raise StreamError (status)
class ProgStream (Stream):
def __init__ (self, progname, flags = MU_STREAM_READ):
def __init__ (self, progname, flags=MU_STREAM_READ):
Stream.__init__ (self)
status = stream.prog_stream_create (self.stm, progname, flags)
if status:
......
......@@ -17,7 +17,7 @@
from mailutils.c_api import util
def get_user_email (name = None):
def get_user_email (name=None):
if name == None:
return util.get_user_email ()
else:
......@@ -33,5 +33,5 @@ def get_user_email_domain ():
def set_user_email_domain (domain):
util.set_user_email_domain (domain)
def tempname (tmpdir = None):
def tempname (tmpdir=None):
return util.tempname (tmpdir)
......