Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ nosetests.xml

# rope
.ropeproject
/.vs
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/.vs
.vs

I don't think the / is needed.

39 changes: 39 additions & 0 deletions pyorbital/tlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,44 @@ def read(platform, tle_file=None, line1=None, line2=None):
return Tle(platform, tle_file=tle_file, line1=line1, line2=line2)


def get_all_platforms(tle_file=None):
"""Read all *platform* name from tle file
tle_file - list path files
"""
Comment thread
19as marked this conversation as resolved.
platforms = list()
fid = io.open(tle_file, 'rb')
for line in fid:
line = line.decode('utf-8')
line = line.strip()
if not line.startswith('1') and not line.startswith('2') and len(line) > 0:
platforms.append(line)
l_1 = next(fid).decode('utf-8')
l_2 = next(fid).decode('utf-8')
fid.close()

return platforms


def get_platform(tle_file=None):
"""Read *platform* name from tle file
tle_file - path to tle file
"""
Comment thread
19as marked this conversation as resolved.
try:
fid = io.open(tle_file, 'rb')
Comment thread
19as marked this conversation as resolved.
for line in fid:
line = line.decode('utf-8')
line = line.strip()
if not line.startswith('1') and not line.startswith('2') and len(line) > 0:
yield line
l_1 = next(fid).decode('utf-8')
l_2 = next(fid).decode('utf-8')
Comment thread
19as marked this conversation as resolved.
except IOError:
LOGGER.error("TLE file %s not found.", tle_file)
finally:
if fid:
fid.close()


def fetch(destination):
"""Fetch TLE from internet and save it to `destination`."""
with io.open(destination, mode="w", encoding="utf-8") as dest:
Expand Down Expand Up @@ -213,6 +251,7 @@ def _open(filename):
for l_0 in fid:
l_0 = l_0.decode('utf-8')
if l_0.strip() == self._platform:
if l_0.strip().upper() == self._platform:
Comment thread
19as marked this conversation as resolved.
l_1 = next(fid).decode('utf-8')
l_2 = next(fid).decode('utf-8')
tle = l_1.strip() + "\n" + l_2.strip()
Expand Down