~johndrinkwater/zim/git-plugin

« back to all changes in this revision

Viewing changes to zim/history.py

  • Committer: John Drinkwater
  • Date: 2011-07-01 12:53:43 UTC
  • mfrom: (391.1.24 pyzim-trunk)
  • Revision ID: john@nextraweb.com-20110701125343-lxy8b50an9c867wx
Merge from main branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
 
26
26
class HistoryPath(Path):
27
 
        '''Path withsome additional info from the history.
 
27
        '''Path with some additional info from the history.
28
28
 
29
29
        Adds attributes 'cursor', 'scroll', 'is_first' and 'is_last'.
30
30
        Both 'cursor' and 'scroll' give a position within the page and
245
245
                if child == path: return None
246
246
                else: return child
247
247
 
 
248
        def get_record(self, path, need_cursor=False):
 
249
                '''Get a history record for 'path'
 
250
 
 
251
                @param path: a L{Path} object
 
252
                @keyword check_cursor: if C{True} only history records are
 
253
                returned that have a value for the cursor that is not C{None}
 
254
 
 
255
                @returns: a L{HistoryPath} object or None
 
256
                '''
 
257
                for record in self.get_history():
 
258
                        if record == path:
 
259
                                if need_cursor:
 
260
                                        if not record.cursor is None:
 
261
                                                return record
 
262
                                        else:
 
263
                                                continue
 
264
                                else:
 
265
                                        return record
 
266
 
248
267
        def get_history(self):
249
268
                '''Generator function that yields history records, latest first'''
250
269
                for i in range(len(self.history)-1, -1, -1):