Completed
Push — master ( 24fe2a...025da3 )
by Oleksandr
01:08
created

il2fb.parsers.mission.strip_comments()   A

Complexity

Conditions 4

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4
Metric Value
cc 4
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 4
rs 9.2
1
# -*- coding: utf-8 -*-
2
3 1
from .constants import COMMENT_MARKERS
4
5
6 1
def move_if_present(dst, src, dst_key, src_key=None):
7 1
    src_key = src_key or dst_key
8 1
    if src_key in src:
9 1
        dst[dst_key] = src.pop(src_key)
10
11
12 1
def set_if_present(dst, key, value):
13 1
    if value:
14 1
        dst[key] = value
15
16
17 1
def strip_comments(line):
18 1
    for marker in COMMENT_MARKERS:
19 1
        try:
20 1
            index = line.index(marker)
21 1
        except ValueError:
22
            pass
23
        else:
24 1
            line = line[:index]
25
26
    return line.strip()
27