Completed
Push — master ( 410210...caabd8 )
by Oleksandr
01:07
created

il2fb.parsers.mission.sections.MainParser._to_time()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
cc 1
dl 0
loc 4
ccs 4
cts 4
cp 1
crap 1
rs 10
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 MainParser(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