~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 02:03:42 UTC
  • Revision ID: william.grant@canonical.com-20120123020342-sxal2reak5s8p0l6
Extract _format_message into a normal function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
    return memo, start, finish
122
122
 
123
123
 
 
124
def _format_message(message):
 
125
    return {
 
126
        'date': message.get('date'),
 
127
        'from': message.get('from'),
 
128
        'subject': message.get('subject'),
 
129
        'message-id': message.get('message-id'),
 
130
        }
 
131
 
 
132
 
124
133
class CassandraConnection(object):
125
134
 
126
135
    def __init__(self, keyspace, host):
151
160
            % (message_dict.get('message-id', None), archive_uuid))
152
161
        return message_uuid
153
162
 
154
 
    def _format_message(self, message):
155
 
        return {
156
 
            'date': message.get('date'),
157
 
            'from': message.get('from'),
158
 
            'subject': message.get('subject'),
159
 
            'message-id': message.get('message-id'),
160
 
            }
161
 
 
162
163
    def _trim(self, sequence, end):
163
164
        """Return the sequence with one of the ends trimmed.
164
165
 
208
209
 
209
210
        return (
210
211
            str(pairs[0][0]),
211
 
            [self._format_message(messages[id]) for id in ids],
 
212
            [_format_message(messages[id]) for id in ids],
212
213
            str(pairs[-1][0]),
213
214
            )