OLD | NEW |
| (Empty) |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 | |
6 class Region(object): | |
7 """A region of some (unspecified) file at a (known) revision.""" | |
8 def __init__(self, start, count, revision, | |
9 author_name, author_email, author_time): | |
10 self.start = start | |
11 self.count = count | |
12 self.revision = revision | |
13 self.author_name = author_name | |
14 self.author_email = author_email | |
15 self.author_time = author_time | |
16 | |
17 def ToDict(self): | |
18 return { | |
19 'start': self.start, | |
20 'count': self.count, | |
21 'revision': self.revision, | |
22 'author_name': self.author_name, | |
23 'author_email': self.author_email, | |
24 'author_time': self.author_time | |
25 } | |
26 | |
27 | |
28 class Blame(list): | |
29 """A list of regions for a (known) revision of a (known) file.""" | |
30 def __init__(self, revision, path): | |
31 super(Blame, self).__init__() | |
32 self.revision = revision | |
33 self.path = path | |
34 | |
35 def AddRegion(self, region): | |
36 self.append(region) | |
37 | |
38 def ToDict(self): | |
39 regions = [] | |
40 for region in self: | |
41 regions.append(region.ToDict()) | |
42 return { | |
43 'revision': self.revision, | |
44 'path': self.path, | |
45 'regions': regions | |
46 } | |
OLD | NEW |