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

« back to all changes in this revision

Viewing changes to grackle/model.py

  • Committer: William Grant
  • Date: 2012-01-23 00:30:34 UTC
  • Revision ID: william.grant@canonical.com-20120123003034-olw0btbfljnypex0
Extract _make_bounds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
    return a
105
105
 
106
106
 
 
107
def _make_bounds(memo, range_start, range_finish, backward):
 
108
    start = finish = ''
 
109
    if memo != '':
 
110
        memo = uuid.UUID(memo)
 
111
    if backward:
 
112
        finish = memo
 
113
    else:
 
114
        start = memo
 
115
    if range_start is not None:
 
116
        start = _bound_timeuuid(
 
117
            start, _utc_timeuuid(range_start), max=True)
 
118
    if range_finish is not None:
 
119
        finish = _bound_timeuuid(
 
120
            finish, _utc_timeuuid(range_finish, lowest_val=False))
 
121
    return memo, start, finish
 
122
 
 
123
 
107
124
class CassandraConnection(object):
108
125
 
109
126
    def __init__(self, keyspace, host):
159
176
            reversed = order[0] == '-'
160
177
        else:
161
178
            raise AssertionError("Unsupported order.")
162
 
        if memo != '':
163
 
            memo = uuid.UUID(memo)
164
 
        if backward:
165
 
            start = ''
166
 
            finish = memo
167
 
        else:
168
 
            start = memo
169
 
            finish = ''
170
 
        if start_date is not None:
171
 
            start = _bound_timeuuid(
172
 
                start, _utc_timeuuid(start_date, lowest_val=False), max=True)
173
 
        if finish_date is not None:
174
 
            finish = _bound_timeuuid(
175
 
                finish, _utc_timeuuid(finish_date, lowest_val=False))
 
179
 
 
180
        memo, start, finish = _make_bounds(
 
181
            memo, start_date, finish_date, backward)
176
182
 
177
183
        # Get up to n+1 messages from the memo: the last item of the
178
184
        # previous batch (because that's where the memo starts) + this