Last change
on this file since a80a4a7 was
22a1a77,
checked in by Ted Faber <faber@…>, 13 years ago
|
Checkpoint: untested operations stuff
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[22a1a77] | 1 | #!/usr/local/bin/python |
---|
| 2 | |
---|
| 3 | class operation_status: |
---|
| 4 | """ |
---|
| 5 | Collection of standard codes and format ofr operationstatus |
---|
| 6 | """ |
---|
| 7 | success = 0 |
---|
| 8 | access = 1 |
---|
| 9 | busy= 2 |
---|
| 10 | unsupp = 3 |
---|
| 11 | bad_param = 4 |
---|
| 12 | internal = 5 |
---|
| 13 | partial = 6 |
---|
| 14 | no_target = 7 |
---|
| 15 | federant = 8 |
---|
| 16 | code_str = { |
---|
| 17 | success: "Success", |
---|
| 18 | access : "Access Denied", |
---|
| 19 | busy : "Resource busy, try again later", |
---|
| 20 | unsupp : "Operation not supported", |
---|
| 21 | bad_param: "Bad parameter for operation", |
---|
| 22 | internal : "Internal Error", |
---|
| 23 | partial: "Partial Embedding", |
---|
| 24 | no_target: "No such target", |
---|
| 25 | federant: "Federant Error", |
---|
| 26 | } |
---|
| 27 | str_code = dict([ (v, k) for k, v in code_str.iteritems() ]) |
---|
| 28 | |
---|
| 29 | def __init__(self, target, code=None, description=None): |
---|
| 30 | self.target = target |
---|
| 31 | self.code = code |
---|
| 32 | if description is not None: |
---|
| 33 | self.description = description |
---|
| 34 | elif code in operation_status.code_str: |
---|
| 35 | self.description = operation_status.code_str[code] |
---|
| 36 | else: |
---|
| 37 | self.description = None |
---|
| 38 | |
---|
| 39 | def to_dict(self): |
---|
| 40 | rv = { 'target': self.target, 'code': self.code, } |
---|
| 41 | if self.description is not None: rv['description'] = self.description |
---|
| 42 | return rv |
---|
Note: See
TracBrowser
for help on using the repository browser.