10
class UnparsableDateRange(Exception):
11
"""The date_range was not in the format of 2012-01-01..2012-01-31."""
14
10
class UnsupportedDisplayType(Exception):
15
11
"""Raised when an Unsupported display_type is requested."""
82
74
raise Exception('!!')
84
def get_messages(self, archive_id, message_ids=None, date_range=None,
85
limit=None, memo=None, order=None, headers=None,
86
include_hidden=False, max_body_length=None,
76
def get_messages(self, archive_id, message_ids=None, limit=None,
77
memo=None, order=None, headers=None,
78
max_body_length=None, include_hidden=False,
87
79
display_type='all'):
88
80
"""Retrieve specified messages.
90
82
:param archive_id: The archive to retrieve messages from.
91
83
:param message_ids: (optional) Retrieve only messages with these ids.
92
:param date_range: Retrieve the messages from or between a range of
93
dates. Example: 2012-01-01..2012-01-31 retrieve all the messages
94
between the 01 and 31 of January, including message from 01
96
84
:param limit: The maximum number of messages to return. The server
97
85
may, at its discretion, return fewer.
98
86
:param memo: (optional) Opaque identifier describing the position in
121
109
if message_ids is not None:
122
110
parameters['message_ids'] = message_ids
123
if date_range is not None:
124
parameters['date_range'] = date_range
125
111
if limit is not None:
126
112
parameters['limit'] = limit
127
113
if memo is not None:
141
127
raise UnsupportedOrder
142
128
elif response.reason == UnsupportedDisplayType.__doc__:
143
129
raise UnsupportedDisplayType
144
elif response.reason == UnparsableDateRange.__doc__:
145
raise UnparsableDateRange
147
131
raise ValueError('Bad request')
148
132
data = response.read()