Completed
Push — master ( caabd8...c07396 )
by Oleksandr
01:11
created

il2fb.parsers.mission.sections.MainSectionParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 32
ccs 6
cts 6
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check_section_name() 0 6 1
A clean() 0 19 1
1
# -*- coding: utf-8 -*-
2
3 1
from il2fb.commons.weather import Conditions
4
5 1
from ..converters import to_belligerent, to_time
6 1
from . import ValuesParser
7
8
9 1
class MainSectionParser(ValuesParser):
10
    """
11
    Parses ``MAIN`` section.
12
    View :ref:`detailed description <main-section>`.
13
    """
14
15 1
    def check_section_name(self, section_name):
16
        """
17
        Implements abstract method. See
18
        :meth:`SectionParser.check_section_name` for semantics.
19
        """
20 1
        return section_name == "MAIN"
21
22 1
    def clean(self):
23
        """
24
        Redefines base method. See :meth:`SectionParser.clean` for
25
        semantics.
26
        """
27 1
        weather_conditions = int(self.data['CloudType'])
28 1
        return {
29
            'location_loader': self.data['MAP'],
30
            'time': {
31
                'value': to_time(self.data['TIME']),
32
                'is_fixed': 'TIMECONSTANT' in self.data,
33
            },
34
            'weather_conditions': Conditions.get_by_value(weather_conditions),
35
            'cloud_base': int(float(self.data['CloudHeight'])),
36
            'player': {
37
                'belligerent': to_belligerent(self.data['army']),
38
                'flight_id': self.data.get('player'),
39
                'aircraft_index': int(self.data['playerNum']),
40
                'fixed_weapons': 'WEAPONSCONSTANT' in self.data,
41
            },
42
        }
43