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

clean()   A

Complexity

Conditions 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
cc 1
dl 0
loc 15
ccs 4
cts 4
cp 1
crap 1
rs 9.4286
1
# -*- coding: utf-8 -*-
2
3 1
from il2fb.commons.weather import Gust, Turbulence
4
5 1
from . import ValuesParser
6
7
8 1
class WeatherSectionParser(ValuesParser):
9
    """
10
    Parses ``WEATHER`` section.
11
    View :ref:`detailed description <weather-section>`.
12
    """
13
14 1
    def check_section_name(self, section_name):
15
        """
16
        Implements abstract method. See
17
        :meth:`SectionParser.check_section_name` for semantics.
18
        """
19 1
        return section_name == "WEATHER"
20
21 1
    def clean(self):
22
        """
23
        Redefines base method. See :meth:`SectionParser.clean` for
24
        semantics.
25
        """
26 1
        gust = int(self.data['Gust'])
27 1
        turbulence = int(self.data['Turbulence'])
28 1
        return {
29
            'weather': {
30
                'wind': {
31
                    'direction': float(self.data['WindDirection']),
32
                    'speed': float(self.data['WindSpeed']),
33
                },
34
                'gust': Gust.get_by_value(gust),
35
                'turbulence': Turbulence.get_by_value(turbulence),
36
            },
37
        }
38