• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Open-MSS / MSS / 16371583884

18 Jul 2025 01:19PM UTC coverage: 70.054% (-0.9%) from 70.952%
16371583884

push

github

web-flow
fix:fix for airspace access and shapely use (#2839)

* fix for airspace access and shapely use

* pep8 fixes

17 of 18 new or added lines in 1 file covered. (94.44%)

1738 existing lines in 41 files now uncovered.

14427 of 20594 relevant lines covered (70.05%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/mslib/plugins/io/csv.py
1
# -*- coding: utf-8 -*-
2
"""
3

4
    mslib.plugins.io.csv
5
    ~~~~~~~~~~~~~~~~~~~~
6

7
    plugin for csv format flight track export
8

9
    This file is part of MSS.
10

11
    :copyright: Copyright 2008-2014 Deutsches Zentrum fuer Luft- und Raumfahrt e.V.
12
    :copyright: Copyright 2011-2014 Marc Rautenhaus (mr)
13
    :copyright: Copyright 2016-2025 by the MSS team, see AUTHORS.
14
    :license: APACHE-2.0, see LICENSE for details.
15

16
    Licensed under the Apache License, Version 2.0 (the "License");
17
    you may not use this file except in compliance with the License.
18
    You may obtain a copy of the License at
19

20
       http://www.apache.org/licenses/LICENSE-2.0
21

22
    Unless required by applicable law or agreed to in writing, software
23
    distributed under the License is distributed on an "AS IS" BASIS,
24
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
    See the License for the specific language governing permissions and
26
    limitations under the License.
27
"""
28

29
import unicodecsv as csv
1✔
30
import os
1✔
31
from pathlib import Path
1✔
32

33
import mslib.msui.flighttrack as ft
1✔
34

35

36
def save_to_csv(filename, name, waypoints):
1✔
37
    if not filename:
1✔
38
        raise ValueError("fileexportname to save flight track cannot be None")
×
39
    path = Path(filename)
1✔
40
    with path.open("wb") as csvfile:
1✔
41
        csv_writer = csv.writer(csvfile, dialect='excel', delimiter=";", lineterminator="\n")
1✔
42
        csv_writer.writerow([name])
1✔
43
        csv_writer.writerow(["Index", "Location", "Lat (+-90)", "Lon (+-180)", "Flightlevel", "Pressure (hPa)",
1✔
44
                             "Leg dist. (km)", "Cum. dist. (km)", "Comments"])
45
        for i, wp in enumerate(waypoints):
1✔
46
            loc = str(wp.location)
1✔
47
            lat = f"{wp.lat:.3f}"
1✔
48
            lon = f"{wp.lon:.3f}"
1✔
49
            lvl = f"{wp.flightlevel:.3f}"
1✔
50
            pre = f"{wp.pressure / 100.:.3f}"
1✔
51
            leg = f"{wp.distance_to_prev:.3f}"
1✔
52
            cum = f"{wp.distance_total:.3f}"
1✔
53
            com = str(wp.comments)
1✔
54
            csv_writer.writerow([i, loc, lat, lon, lvl, pre, leg, cum, com])
1✔
55

56

57
def load_from_csv(filename):
1✔
58
    waypoints = []
1✔
59
    path = Path(filename)
1✔
60
    with path.open("rb") as in_file:
1✔
61
        lines = in_file.readlines()
1✔
62
    if len(lines) < 4:
1✔
UNCOV
63
        raise SyntaxError("CSV file requires at least 4 lines!")
×
64
    dialect = csv.Sniffer().sniff(lines[-1].decode("utf-8"))
1✔
65
    csv_reader = csv.reader(lines, encoding="utf-8", dialect=dialect)
1✔
66
    name = next(csv_reader)[0]
1✔
67
    next(csv_reader)  # header
1✔
68
    for row in csv_reader:
1✔
69
        wp = ft.Waypoint()
1✔
70
        wp.location = row[1]
1✔
71
        wp.lat = float(row[2])
1✔
72
        wp.lon = float(row[3])
1✔
73
        wp.flightlevel = float(row[4])
1✔
74
        wp.pressure = float(row[5]) * 100.
1✔
75
        wp.distance_to_prev = float(row[6])
1✔
76
        wp.distance_total = float(row[7])
1✔
77
        wp.comments = row[8]
1✔
78
        waypoints.append(wp)
1✔
79
    name = os.path.basename(filename.replace(".csv", "").strip())
1✔
80
    return name, waypoints
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc