Skip to content

Commit 1e3ad4d

Browse files
valgurscivision
authored andcommitted
add .bz2 decompression support
1 parent 3b85aa3 commit 1e3ad4d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ where ease of cross-platform install and correctness are primary goals.
2727
* Plain ASCII or seamlessly read compressed ASCII in:
2828
* `.gz` GZIP
2929
* `.Z` LZW
30+
* `.bz2` bzip2
3031
* `.zip`
3132
* Hatanaka compressed RINEX (plain `.crx` or `.crx.gz` etc.)
3233
* Python `io.StringIO` text stream RINEX'

src/georinex/rio.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22
import typing as T
33
import gzip
4+
import bz2
45
import zipfile
56
from pathlib import Path
67
from contextlib import contextmanager
@@ -48,6 +49,14 @@ def opener(fn: T.TextIO | Path, header: bool = False) -> T.Iterator[T.TextIO]:
4849
# even with 'rt' doesn't decompress until read.
4950
f = io.StringIO(crx2rnx(f.read()))
5051
yield f
52+
elif suffix == ".bz2":
53+
with bz2.open(fn, "rt") as f:
54+
version, is_crinex = rinex_version(first_nonblank_line(f))
55+
f.seek(0)
56+
57+
if is_crinex and not header:
58+
f = io.StringIO(crx2rnx(f.read()))
59+
yield f
5160
elif suffix == ".zip":
5261
with zipfile.ZipFile(fn, "r") as z:
5362
flist = z.namelist()

src/georinex/tests/test_hatanaka.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def test_obs3_gz():
7979

8080

8181
@pytest.mark.timeout(30)
82-
def test_obs3():
83-
fn = R / "P43300USA_R_20190012056_17M_15S_MO.crx"
82+
@pytest.mark.parametrize("suffix", [".crx", ".crx.bz2"])
83+
def test_obs3(suffix):
84+
fn = R / ("P43300USA_R_20190012056_17M_15S_MO" + suffix)
8485

8586
info = gr.rinexinfo(fn)
8687

0 commit comments

Comments
 (0)