Browse Source

Add beginning of an anonymous reviewer

Change-Id: I37b6081829e0e78710b02c7028916a77a212c3c3
Joshua Harlow 3 years ago
parent
commit
8de878cbcb

+ 2
- 2
nerdreviewer/reviewer.py View File

@@ -18,7 +18,7 @@ import six
18 18
 @six.add_metaclass(abc.ABCMeta)
19 19
 class Reviewer(object):
20 20
 
21
-    def __init__(self, name=u"John Doe"):
21
+    def __init__(self, name):
22 22
         self._name = name
23 23
 
24 24
     @property
@@ -36,4 +36,4 @@ class Reviewer(object):
36 36
 
37 37
     @abc.abstractproperty
38 38
     def personality(self):
39
-        """Current personality profile/dict of this reviewer"""
39
+        """Current personality profile of this reviewer"""

+ 0
- 0
nerdreviewer/reviewers/__init__.py View File


+ 56
- 0
nerdreviewer/reviewers/anonymous.py View File

@@ -0,0 +1,56 @@
1
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+#    not use this file except in compliance with the License. You may obtain
3
+#    a copy of the License at
4
+#
5
+#         http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+#    Unless required by applicable law or agreed to in writing, software
8
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+#    License for the specific language governing permissions and limitations
11
+#    under the License.
12
+
13
+import random
14
+
15
+from nerdreviewer import personality
16
+from nerdreviewer import reviewer
17
+
18
+
19
+class AnonymousReviewer(reviewer.Reviewer):
20
+    PREFIXES = [
21
+        "AnonymousCoward",
22
+        "JohnDoe",
23
+        "JaneDoe",
24
+    ]
25
+
26
+    def __init__(self):
27
+        name = random.choice(self.PREFIXES)
28
+        name += str(random.randint(1, 1000))
29
+        super(AnonymousReviewer, self).__init__(name)
30
+        moods = list(personality.Mood)
31
+        mood = random.choice(moods)
32
+        self._mood = mood
33
+        self._personality = {
34
+            mood: 1.0,
35
+        }
36
+        for mood in moods:
37
+            if mood not in self._personality:
38
+                self._personality[mood] = 0.0
39
+
40
+    def review(self, a_review):
41
+        pass
42
+
43
+    @property
44
+    def description(self):
45
+        mood = self._mood.value.lower()
46
+        lines = [
47
+            "%s is a %s reviewer" % (self.name, mood),
48
+            "",
49
+            "%s will never stop or get tired" % (self.name),
50
+        ]
51
+        return "\n".join(lines)
52
+
53
+    @property
54
+    def personality(self):
55
+        """Current personality profile/dict of this reviewer"""
56
+        return self._personality.copy()

Loading…
Cancel
Save