File: helpers.py

package info (click to toggle)
pystac-client 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,416 kB
  • sloc: python: 4,652; sh: 74; makefile: 60
file content (21 lines) | stat: -rw-r--r-- 631 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
import json
from pathlib import Path
from typing import Any

TEST_DATA = Path(__file__).parent / "data"

STAC_URLS = {
    "PLANETARY-COMPUTER": "https://planetarycomputer.microsoft.com/api/stac/v1",
    "EARTH-SEARCH": "https://earth-search.aws.element84.com/v1",
    "MLHUB": "https://api.radiant.earth/mlhub/v1",
    "SPACEBEL": "https://emc.spacebel.be",
}


def read_data_file(file_name: str, mode: str = "r", parse_json: bool = False) -> Any:
    file_path = TEST_DATA / file_name
    with file_path.open(mode=mode) as src:
        if parse_json:
            return json.load(src)
        else:
            return src.read()