File: satcfg.py

package info (click to toggle)
gr-satellites 5.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,836 kB
  • sloc: python: 29,546; cpp: 5,448; ansic: 1,247; sh: 118; makefile: 24
file content (29 lines) | stat: -rw-r--r-- 671 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2019 Daniel Estevez <daniel@destevez.net>
#
# This file is part of gr-satellites
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

from pathlib import Path


def get_cfg(norad):
    """
    Opens and returns the local configuration for selected satellite
    """
    config_dir = Path.home() / '.gr_satellites'
    config_filename = config_dir / 'sat.cfg'

    if not config_filename.exists():
        return []

    with open(config_filename) as f:
        for row in f:
            sat = row.strip().split(' ')
            if len(sat) > 1 and norad == int(sat[0]):
                return sat[1:]
    return []