author | John Beck <John.Beck@Oracle.COM> |
Wed, 09 Oct 2013 07:10:15 -0700 | |
branch | s11-update |
changeset 2785 | b6f5c5d1d0b7 |
child 3998 | 5bd484384122 |
permissions | -rw-r--r-- |
2785
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
1 |
Adjust the Python code to work with Python 2.6 as well as Python 2.7. |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
2 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
3 |
--- boto-2.9.2/bin/mturk.orig 2013-05-02 11:07:33.957693616 -0700 |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
4 |
+++ boto-2.9.2/bin/mturk 2013-05-02 12:27:47.929525927 -0700 |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
5 |
@@ -56,11 +56,11 @@ |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
6 |
PercentAssignmentsApproved = '000000000000000000L0', |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
7 |
PercentAssignmentsRejected = '000000000000000000S0') |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
8 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
9 |
-qual_comparators = {v : k for k, v in dict( |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
10 |
+qual_comparators = dict((v, k) for k, v in dict( |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
11 |
LessThan = '<', LessThanOrEqualTo = '<=', |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
12 |
GreaterThan = '>', GreaterThanOrEqualTo = '>=', |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
13 |
EqualTo = '==', NotEqualTo = '!=', |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
14 |
- Exists = 'exists').items()} |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
15 |
+ Exists = 'exists').items()) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
16 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
17 |
example_config_file = '''Example configuration file: |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
18 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
19 |
@@ -212,11 +212,11 @@ |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
20 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
21 |
def digest_assignment(a): |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
22 |
return dict( |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
23 |
- answers = {str(x.qid): str(x.fields[0]) for x in a.answers[0]}, |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
24 |
- **{k: str(getattr(a, k)) for k in ( |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
25 |
+ answers = dict((str(x.qid), str(x.fields[0])) for x in a.answers[0]), |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
26 |
+ **dict((k, str(getattr(a, k))) for k in ( |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
27 |
'AcceptTime', 'SubmitTime', |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
28 |
'HITId', 'AssignmentId', 'WorkerId', |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
29 |
- 'AssignmentStatus')}) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
30 |
+ 'AssignmentStatus'))) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
31 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
32 |
# -------------------------------------------------- |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
33 |
# Commands |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
34 |
@@ -278,7 +278,7 @@ |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
35 |
but apparently, it does.''' |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
36 |
con.disable_hit(hit) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
37 |
global nicknames |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
38 |
- nicknames = {k: v for k, v in nicknames.items() if v != hit} |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
39 |
+ nicknames = dict((k, v) for k, v in nicknames.items() if v != hit) |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
40 |
|
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
41 |
def list_assignments(hit, only_reviewable = False): |
b6f5c5d1d0b7
PSARC 2013/140 greenlet version 0.4.0 - Python coroutines module
John Beck <John.Beck@Oracle.COM>
parents:
diff
changeset
|
42 |
assignments = map(digest_assignment, con.get_assignments( |