Barry Warsaw has proposed merging lp:~barry/mailman/pep435 into lp:mailman.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~barry/mailman/pep435/+merge/170232
Convert from flufl.enums to PEP 435 enums.
--
https://code.launchpad.net/~barry/mailman/pep435/+merge/170232
Your team Mailman Coders is requested to review the proposed merge of
lp:~barry/mailman/pep435 into lp:mailman.
=== modified file 'setup.py'
--- setup.py 2013-01-05 23:10:43 +0000
+++ setup.py 2013-06-19 02:50:33 +0000
@@ -93,8 +93,8 @@
'console_scripts' : list(scripts),
},
install_requires = [
+ 'enum34',
'flufl.bounce',
- 'flufl.enum',
'flufl.i18n',
'flufl.lock',
'httplib2',
=== modified file 'src/mailman/app/moderator.py'
--- src/mailman/app/moderator.py 2013-01-01 14:05:42 +0000
+++ src/mailman/app/moderator.py 2013-06-19 02:50:33 +0000
@@ -246,7 +246,7 @@
lang=getUtility(ILanguageManager)[data['language']])
elif action is Action.accept:
key, data = requestdb.get_request(id)
- delivery_mode = DeliveryMode(data['delivery_mode'])
+ delivery_mode = DeliveryMode[data['delivery_mode']]
address = data['address']
display_name = data['display_name']
language = getUtility(ILanguageManager)[data['language']]
=== modified file 'src/mailman/app/subscriptions.py'
--- src/mailman/app/subscriptions.py 2013-01-01 14:05:42 +0000
+++ src/mailman/app/subscriptions.py 2013-06-19 02:50:33 +0000
@@ -54,7 +54,7 @@
The members are sorted first by unique list id, then by subscribed email
address, then by role.
"""
- return (member.list_id, member.address.email, int(member.role))
+ return (member.list_id, member.address.email, member.role.value)
=== modified file 'src/mailman/bin/master.py'
--- src/mailman/bin/master.py 2013-01-01 14:05:42 +0000
+++ src/mailman/bin/master.py 2013-06-19 02:50:33 +0000
@@ -34,7 +34,7 @@
import logging
from datetime import timedelta
-from flufl.enum import Enum
+from enum import Enum
from flufl.lock import Lock, NotLockedError, TimeOutError
from lazr.config import as_boolean
=== modified file 'src/mailman/commands/cli_members.py'
--- src/mailman/commands/cli_members.py 2013-01-01 14:05:42 +0000
+++ src/mailman/commands/cli_members.py 2013-06-19 02:50:33 +0000
@@ -130,7 +130,7 @@
DeliveryMode.mime_digests,
DeliveryMode.summary_digests]
elif args.digest is not None:
- digest_types = [DeliveryMode(args.digest + '_digests')]
+ digest_types = [DeliveryMode[args.digest + '_digests']]
else:
# Don't filter on digest type.
pass
@@ -140,7 +140,7 @@
elif args.nomail == 'byadmin':
status_types = [DeliveryStatus.by_moderator]
elif args.nomail.startswith('by'):
- status_types = [DeliveryStatus('by_' + args.nomail[2:])]
+ status_types = [DeliveryStatus['by_' + args.nomail[2:]]]
elif args.nomail == 'enabled':
status_types = [DeliveryStatus.enabled]
elif args.nomail == 'unknown':
=== modified file 'src/mailman/commands/cli_status.py'
--- src/mailman/commands/cli_status.py 2013-01-01 14:05:42 +0000
+++ src/mailman/commands/cli_status.py 2013-06-19 02:50:33 +0000
@@ -64,4 +64,4 @@
message = _('GNU Mailman is in an unexpected state '
'($hostname != $fqdn_name)')
print(message)
- return int(status)
+ return status.value
=== modified file 'src/mailman/database/schema/mm_20120407000000.py'
--- src/mailman/database/schema/mm_20120407000000.py 2013-01-01 14:05:42 +0000
+++ src/mailman/database/schema/mm_20120407000000.py 2013-06-19 02:50:33 +0000
@@ -67,11 +67,11 @@
def archive_policy(archive, archive_private):
"""Convert archive and archive_private to archive_policy."""
if archive == 0:
- return int(ArchivePolicy.never)
+ return ArchivePolicy.never.value
elif archive_private == 1:
- return int(ArchivePolicy.private)
+ return ArchivePolicy.private.value
else:
- return int(ArchivePolicy.public)
+ return ArchivePolicy.public.value
=== modified file 'src/mailman/database/types.py'
--- src/mailman/database/types.py 2013-01-01 14:05:42 +0000
+++ src/mailman/database/types.py 2013-06-19 02:50:33 +0000
@@ -32,7 +32,7 @@
class _EnumVariable(Variable):
- """Storm variable for supporting flufl.enum.Enum types.
+ """Storm variable for supporting enum types.
To use this, make the database column a INTEGER.
"""
@@ -46,18 +46,18 @@
return None
if not from_db:
return value
- return self._enum[value]
+ return self._enum(value)
def parse_get(self, value, to_db):
if value is None:
return None
if not to_db:
return value
- return int(value)
+ return value.value
class Enum(SimpleProperty):
- """Custom Enum type for Storm supporting flufl.enum.Enums."""
+ """Custom type for Storm supporting enums."""
variable_class = _EnumVariable
=== modified file 'src/mailman/interfaces/action.py'
--- src/mailman/interfaces/action.py 2013-05-02 15:15:14 +0000
+++ src/mailman/interfaces/action.py 2013-06-19 02:50:33 +0000
@@ -24,7 +24,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
=== modified file 'src/mailman/interfaces/archiver.py'
--- src/mailman/interfaces/archiver.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/archiver.py 2013-06-19 02:50:33 +0000
@@ -27,7 +27,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
=== modified file 'src/mailman/interfaces/autorespond.py'
--- src/mailman/interfaces/autorespond.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/autorespond.py 2013-06-19 02:50:33 +0000
@@ -30,7 +30,7 @@
from datetime import timedelta
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
ALWAYS_REPLY = timedelta()
=== modified file 'src/mailman/interfaces/bounce.py'
--- src/mailman/interfaces/bounce.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/bounce.py 2013-06-19 02:50:33 +0000
@@ -28,7 +28,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Attribute, Interface
=== modified file 'src/mailman/interfaces/chain.py'
--- src/mailman/interfaces/chain.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/chain.py 2013-06-19 02:50:33 +0000
@@ -35,7 +35,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
=== modified file 'src/mailman/interfaces/command.py'
--- src/mailman/interfaces/command.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/command.py 2013-06-19 02:50:33 +0000
@@ -28,7 +28,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
=== modified file 'src/mailman/interfaces/digests.py'
--- src/mailman/interfaces/digests.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/digests.py 2013-06-19 02:50:33 +0000
@@ -25,7 +25,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
=== modified file 'src/mailman/interfaces/mailinglist.py'
--- src/mailman/interfaces/mailinglist.py 2013-05-30 22:29:28 +0000
+++ src/mailman/interfaces/mailinglist.py 2013-06-19 02:50:33 +0000
@@ -29,7 +29,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
from mailman.interfaces.member import MemberRole
=== modified file 'src/mailman/interfaces/member.py'
--- src/mailman/interfaces/member.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/member.py 2013-06-19 02:50:33 +0000
@@ -36,7 +36,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
from mailman.core.errors import MailmanError
=== modified file 'src/mailman/interfaces/mime.py'
--- src/mailman/interfaces/mime.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/mime.py 2013-06-19 02:50:33 +0000
@@ -27,7 +27,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
=== modified file 'src/mailman/interfaces/nntp.py'
--- src/mailman/interfaces/nntp.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/nntp.py 2013-06-19 02:50:33 +0000
@@ -25,7 +25,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
=== modified file 'src/mailman/interfaces/requests.py'
--- src/mailman/interfaces/requests.py 2013-01-01 14:05:42 +0000
+++ src/mailman/interfaces/requests.py 2013-06-19 02:50:33 +0000
@@ -30,7 +30,7 @@
]
-from flufl.enum import Enum
+from enum import Enum
from zope.interface import Interface, Attribute
=== modified file 'src/mailman/model/docs/autorespond.rst'
--- src/mailman/model/docs/autorespond.rst 2011-09-24 01:42:39 +0000
+++ src/mailman/model/docs/autorespond.rst 2013-06-19 02:50:33 +0000
@@ -90,7 +90,7 @@
>>> response.address
<Address: [email protected] [not verified] at ...>
>>> response.response_type
- <EnumValue: Response.hold [int=1]>
+ <Response.hold: 1>
>>> response.date_sent
datetime.date(2005, 8, 1)
=== modified file 'src/mailman/model/docs/membership.rst'
--- src/mailman/model/docs/membership.rst 2012-12-23 19:43:31 +0000
+++ src/mailman/model/docs/membership.rst 2013-06-19 02:50:33 +0000
@@ -217,7 +217,7 @@
regardless of their role.
>>> def sortkey(member):
- ... return (member.address.email, int(member.role))
+ ... return (member.address.email, member.role.value)
>>> for member in sorted(mlist.subscribers.members, key=sortkey):
... print member.address.email, member.role
[email protected] MemberRole.member
=== modified file 'src/mailman/model/docs/users.rst'
--- src/mailman/model/docs/users.rst 2012-09-05 01:31:50 +0000
+++ src/mailman/model/docs/users.rst 2013-06-19 02:50:33 +0000
@@ -332,8 +332,7 @@
>>> len(members)
4
>>> def sortkey(member):
- ... return (member.address.email, member.mailing_list,
- ... int(member.role))
+ ... return member.address.email, member.mailing_list, member.role.value
>>> for member in sorted(members, key=sortkey):
... print member.address.email, member.mailing_list.list_id, \
... member.role
=== modified file 'src/mailman/rest/addresses.py'
--- src/mailman/rest/addresses.py 2013-01-01 14:05:42 +0000
+++ src/mailman/rest/addresses.py 2013-06-19 02:50:33 +0000
@@ -178,7 +178,7 @@
def membership_key(member):
# Sort first by mailing list, then by address, then by role.
- return member.list_id, member.address.email, int(member.role)
+ return member.list_id, member.address.email, member.role.value
class AddressMemberships(MemberCollection):
=== modified file 'src/mailman/rest/helpers.py'
--- src/mailman/rest/helpers.py 2013-03-21 18:35:58 +0000
+++ src/mailman/rest/helpers.py 2013-06-19 02:50:33 +0000
@@ -36,7 +36,7 @@
from cStringIO import StringIO
from datetime import datetime, timedelta
-from flufl.enum import Enum
+from enum import Enum
from lazr.config import as_boolean
from restish import http
from restish.http import Response
@@ -79,7 +79,7 @@
seconds = obj.seconds + obj.microseconds / 1000000.0
return '{0}d{1}s'.format(obj.days, seconds)
return '{0}d'.format(obj.days)
- elif hasattr(obj, 'enum') and issubclass(obj.enum, Enum):
+ elif isinstance(obj, Enum):
# It's up to the decoding validator to associate this name with
# the right Enum class.
return obj.name
=== modified file 'src/mailman/rest/lists.py'
--- src/mailman/rest/lists.py 2013-03-21 18:35:58 +0000
+++ src/mailman/rest/lists.py 2013-06-19 02:50:33 +0000
@@ -57,7 +57,7 @@
return None
try:
role = MemberRole[segments[0]]
- except ValueError:
+ except KeyError:
# Not a valid role.
return None
# No more segments.
@@ -76,7 +76,7 @@
return None
try:
return (), dict(role=MemberRole[segments[1]]), ()
- except ValueError:
+ except KeyError:
# Not a valid role.
return None
=== modified file 'src/mailman/rest/moderation.py'
--- src/mailman/rest/moderation.py 2013-01-01 14:05:42 +0000
+++ src/mailman/rest/moderation.py 2013-06-19 02:50:33 +0000
@@ -60,7 +60,7 @@
resource.update(data)
# Check for a matching request type, and insert the type name into the
# resource.
- request_type = RequestType(resource.pop('_request_type'))
+ request_type = RequestType[resource.pop('_request_type')]
if request_type not in expected_request_types:
return None
resource['type'] = request_type.name
@@ -205,7 +205,7 @@
return http.not_found()
key, data = results
try:
- request_type = RequestType(data['_request_type'])
+ request_type = RequestType[data['_request_type']]
except ValueError:
return http.bad_request()
if request_type is RequestType.subscription:
=== modified file 'src/mailman/rest/validator.py'
--- src/mailman/rest/validator.py 2013-01-01 14:05:42 +0000
+++ src/mailman/rest/validator.py 2013-06-19 02:50:33 +0000
@@ -48,9 +48,13 @@
self._enum_class = enum_class
def __call__(self, enum_value):
- # This will raise a ValueError if the enum value is unknown. Let that
- # percolate up.
- return self._enum_class[enum_value]
+ # This will raise a KeyError if the enum value is unknown. The
+ # Validator API requires turning this into a ValueError.
+ try:
+ return self._enum_class[enum_value]
+ except KeyError as exception:
+ # Retain the error message.
+ raise ValueError(exception.message)
def subscriber_validator(subscriber):
=== modified file 'src/mailman/rules/docs/moderation.rst'
--- src/mailman/rules/docs/moderation.rst 2011-09-24 01:42:39 +0000
+++ src/mailman/rules/docs/moderation.rst 2013-06-19 02:50:33 +0000
@@ -124,7 +124,7 @@
::
>>> def memberkey(member):
- ... return member.mailing_list, member.address.email, int(member.role)
+ ... return member.mailing_list, member.address.email, member.role.value
>>> dump_list(mlist.members.members, key=memberkey)
<Member: Anne Person <[email protected]>
=== modified file 'src/mailman/utilities/importer.py'
--- src/mailman/utilities/importer.py 2013-01-01 14:05:42 +0000
+++ src/mailman/utilities/importer.py 2013-06-19 02:50:33 +0000
@@ -28,6 +28,7 @@
import sys
import datetime
+from mailman.interfaces.action import FilterAction
from mailman.interfaces.autorespond import ResponseAction
from mailman.interfaces.digests import DigestFrequency
from mailman.interfaces.mailinglist import Personalization, ReplyToMunging
@@ -47,6 +48,7 @@
bounce_info_stale_after=seconds_to_delta,
bounce_you_are_disabled_warnings_interval=seconds_to_delta,
digest_volume_frequency=DigestFrequency,
+ filter_action=FilterAction,
newsgroup_moderation=NewsgroupModeration,
personalize=Personalization,
reply_goes_to_list=ReplyToMunging,
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders