| Conditions | 3 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| 1 | # -*- coding: utf-8 -*- |
||
| 16 | 1 | def parse_line(self, line): |
|
| 17 | 1 | params = line.split() |
|
| 18 | 1 | (uid, type_code, belligerent), params = params[0:3], params[3:] |
|
| 19 | |||
| 20 | 1 | chief_type, code = type_code.split('.') |
|
| 21 | 1 | try: |
|
| 22 | 1 | chief_type = to_unit_type(chief_type) |
|
| 23 | 1 | except Exception: |
|
| 24 | # Use original string as unit type |
||
| 25 | pass |
||
| 26 | |||
| 27 | 1 | unit = { |
|
| 28 | 'id': uid, |
||
| 29 | 'code': code, |
||
| 30 | 'type': chief_type, |
||
| 31 | 'belligerent': to_belligerent(belligerent), |
||
| 32 | } |
||
| 33 | 1 | if params: |
|
| 34 | 1 | hibernation, skill, recharge_time = params |
|
| 35 | 1 | unit.update({ |
|
| 36 | 'hibernation': int(hibernation), |
||
| 37 | 'skill': to_skill(skill), |
||
| 38 | 'recharge_time': float(recharge_time), |
||
| 39 | }) |
||
| 40 | 1 | self.data.append(unit) |
|
| 41 | |||
| 44 |