~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-02-14 21:55:15 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: curtis.hovey@canonical.com-20120214215515-vu1zn9n58ov659es
Added basic handling of date_range.

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
 
10
14
class UnsupportedDisplayType(Exception):
11
15
    """Raised when an Unsupported display_type is requested."""
12
16
 
73
77
        else:
74
78
            raise Exception('!!')
75
79
 
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,
 
80
    def get_messages(self, archive_id, message_ids=None, date_range=None,
 
81
                     limit=None, memo=None, order=None, headers=None,
 
82
                     include_hidden=False, max_body_length=None,
79
83
                     display_type='all'):
80
84
        """Retrieve specified messages.
81
85
 
82
86
        :param archive_id: The archive to retrieve messages from.
83
87
        :param message_ids: (optional) Retrieve only messages with these ids.
 
88
        :param date_range: Retrieve the messages from or between a range of
 
89
            dates. Example: 2012-01-01..2012-01-31 retrieve all the messages
 
90
            between the 01 and 31 of January, including message from 01
 
91
            and 31.
84
92
        :param limit: The maximum number of messages to return.  The server
85
93
            may, at its discretion, return fewer.
86
94
        :param memo: (optional) Opaque identifier describing the position in
108
116
        parameters = {}
109
117
        if message_ids is not None:
110
118
            parameters['message_ids'] = message_ids
 
119
        if date_range is not None:
 
120
            parameters['date_range'] = date_range
111
121
        if limit is not None:
112
122
            parameters['limit'] = limit
113
123
        if memo is not None: