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

clean()   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.spatial import Point2D
4 1
from il2fb.commons.structures import BaseStructure
5
6 1
from ..converters import to_belligerent
7 1
from . import CollectingParser
8
9
10 1
class FrontMarker(BaseStructure):
11 1
    __slots__ = ['id', 'belligerent', 'pos', ]
12
13 1
    def __init__(self, id, belligerent, pos):
14 1
        self.id = id
15 1
        self.belligerent = belligerent
16 1
        self.pos = pos
17
18 1
    def __repr__(self):
19 1
        return "<FrontMarker '{0}'>".format(self.id)
20
21
22 1
class FrontMarkerParser(CollectingParser):
23
    """
24
    Parses ``FrontMarker`` section.
25
    View :ref:`detailed description <front-marker-section>`.
26
    """
27
28 1
    def check_section_name(self, section_name):
29 1
        return section_name == "FrontMarker"
30
31 1
    def parse_line(self, line):
32 1
        oid, pos_x, pos_y, belligerent = line.split()
33 1
        self.data.append(FrontMarker(
34
            id=oid,
35
            belligerent=to_belligerent(belligerent),
36
            pos=Point2D(pos_x, pos_y),
37
        ))
38
39 1
    def clean(self):
40
        return {'markers': self.data, }
41