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

il2fb.parsers.mission.sections.StaticCameraSectionParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check_section_name() 0 2 1
A clean() 0 2 1
A parse_line() 0 5 1
1
# -*- coding: utf-8 -*-
2
3
4 1
from il2fb.commons.spatial import Point3D
5 1
from il2fb.commons.structures import BaseStructure
6
7 1
from ..converters import to_belligerent
8 1
from . import CollectingParser
9
10
11 1
class StaticCamera(BaseStructure):
12 1
    __slots__ = ['belligerent', 'pos', ]
13
14 1
    def __init__(self, belligerent, pos):
15 1
        self.belligerent = belligerent
16 1
        self.pos = pos
17
18 1
    def __repr__(self):
19 1
        return (
20
            "<StaticCamera '{0};{1};{2}'>"
21
            .format(self.pos.x, self.pos.y, self.pos.z)
22
        )
23
24
25 1
class StaticCameraSectionParser(CollectingParser):
26
    """
27
    Parses ``StaticCamera`` section.
28
    View :ref:`detailed description <static-camera-section>`.
29
    """
30
31 1
    def check_section_name(self, section_name):
32 1
        return section_name == "StaticCamera"
33
34 1
    def parse_line(self, line):
35 1
        pos_x, pos_y, pos_z, belligerent = line.split()
36 1
        self.data.append(StaticCamera(
37
            belligerent=to_belligerent(belligerent),
38
            pos=Point3D(pos_x, pos_y, pos_z),
39
        ))
40
41 1
    def clean(self):
42
        return {'cameras': self.data, }
43