| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| 1 | # -*- coding: utf-8 -*- |
||
| 8 | 1 | class MDSScoutsSectionParser(CollectingParser): |
|
| 9 | """ |
||
| 10 | Parses ``MDS_Scouts`` section. |
||
| 11 | View :ref:`detailed description <mds-scouts-section>`. |
||
| 12 | """ |
||
| 13 | 1 | input_prefix = "MDS_Scouts_" |
|
| 14 | 1 | output_prefix = "scouts_" |
|
| 15 | |||
| 16 | 1 | def check_section_name(self, section_name): |
|
| 17 | 1 | if not section_name.startswith(self.input_prefix): |
|
| 18 | 1 | return False |
|
| 19 | 1 | belligerent_name = self._get_belligerent_name(section_name) |
|
| 20 | 1 | return bool(belligerent_name) |
|
| 21 | |||
| 22 | 1 | def init_parser(self, section_name): |
|
| 23 | 1 | super(MDSScoutsSectionParser, self).init_parser(section_name) |
|
| 24 | 1 | belligerent_name = self._get_belligerent_name(section_name) |
|
| 25 | 1 | self.belligerent = Belligerents[belligerent_name] |
|
| 26 | 1 | self.output_key = "{}{}".format(self.output_prefix, belligerent_name) |
|
| 27 | |||
| 28 | 1 | def _get_belligerent_name(self, section_name): |
|
| 29 | 1 | return section_name[len(self.input_prefix):].lower() |
|
| 30 | |||
| 31 | 1 | def clean(self): |
|
| 32 | 1 | return { |
|
| 33 | self.output_key: { |
||
| 34 | 'belligerent': self.belligerent, |
||
| 35 | 'aircrafts': self.data, |
||
| 36 | }, |
||
| 38 |