| Conditions | 8 |
| Total Lines | 24 |
| Code Lines | 21 |
| Lines | 24 |
| Ratio | 100 % |
| Tests | 14 |
| CRAP Score | 8.3518 |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 45 | 10 | View Code Duplication | def create_reply(reply, message=None, render=False): |
|
|
|||
| 46 | 10 | r = None |
|
| 47 | 10 | if isinstance(reply, replies.BaseReply): |
|
| 48 | 10 | r = reply |
|
| 49 | 10 | if message: |
|
| 50 | r.source = message.target |
||
| 51 | r.target = message.source |
||
| 52 | r.agent = message.agent |
||
| 53 | 10 | elif isinstance(reply, six.string_types): |
|
| 54 | 10 | r = TextReply( |
|
| 55 | message=message, |
||
| 56 | content=reply |
||
| 57 | ) |
||
| 58 | 10 | elif isinstance(reply, (tuple, list)): |
|
| 59 | 10 | if len(reply) > 10: |
|
| 60 | 10 | raise AttributeError("Can't add more than 10 articles" |
|
| 61 | " in an ArticlesReply") |
||
| 62 | 10 | r = ArticlesReply( |
|
| 63 | message=message, |
||
| 64 | articles=reply |
||
| 65 | ) |
||
| 66 | 10 | if r and render: |
|
| 67 | 10 | return r.render() |
|
| 68 | return r |
||
| 69 |