~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-01-31 05:16:12 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: curtis.hovey@canonical.com-20120131051612-164b2cj3xf3ci35n
Removed the exceptional rule for replies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
)
8
8
 
9
9
 
10
 
class UnparsableDateRange(Exception):
11
 
    """The date_range was not in the format of 2012-01-01..2012-01-31."""
12
 
 
13
 
 
14
10
class UnsupportedDisplayType(Exception):
15
11
    """Raised when an Unsupported display_type is requested."""
16
12
 
19
15
    """Raised when an Unsupported order is requested."""
20
16
 
21
17
 
22
 
class MessageIdNotFound(Exception):
23
 
    """No message matching the message_id was found in the archive."""
24
 
 
25
 
 
26
18
SUPPORTED_DISPLAY_TYPES = (
27
19
    'all',
28
20
    'text-only',
81
73
        else:
82
74
            raise Exception('!!')
83
75
 
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.
89
81
 
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
95
 
            and 31.
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
120
108
        parameters = {}
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
146
130
            else:
147
131
                raise ValueError('Bad request')
148
132
        data = response.read()