Skip to content

Commit

Permalink
Merge branch 'main' into NPI-3421-improve-sp3-nodata-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
treefern committed Jul 26, 2024
2 parents 74cf333 + bdead64 commit 9ea7ede
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 279 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/python-cicd-units.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Python CICD pipelines - Unittesting

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
python -m unittest discover -s tests -v
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ __pycache__
.vscode
.idea
# Other files
scratch
scratch/
21 changes: 14 additions & 7 deletions gnssanalysis/gn_io/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base functions for file reading"""

import base64 as _base64
import gzip as _gzip
import hashlib as _hashlib
Expand Down Expand Up @@ -27,13 +28,19 @@ def path2bytes(path: _Union[_Path, str, bytes]) -> bytes:

if isinstance(path, _Path):
path = path.as_posix()

if path.endswith(".Z"):
databytes = _lzw2bytes(path)
elif path.endswith(".gz"):
databytes = _gz2bytes(path)
else:
databytes = _txt2bytes(path)
try:
if path.endswith(".Z"):
databytes = _lzw2bytes(path)
elif path.endswith(".gz"):
databytes = _gz2bytes(path)
else:
databytes = _txt2bytes(path)
except FileNotFoundError:
_logging.error(f"File {path} not found. Returning empty bytes.")
return None
except Exception as e:
_logging.error(f"Error reading file {path} with error {e}. Returning empty bytes.")
return None
return databytes


Expand Down
Loading

0 comments on commit 9ea7ede

Please sign in to comment.