Completed
Push — master ( 025da3...410210 )
by Oleksandr
01:36
created

_get_belligerent_name()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
cc 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
1
# -*- coding: utf-8 -*-
2
3 1
from il2fb.commons.organization import Belligerents
4
5 1
from . import CollectingParser
6
7
8 1
class MDSScoutsParser(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(MDSScoutsParser, 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
            },
37
        }
38