Skip to content

Commit

Permalink
Place open function in dedicated module
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Jul 20, 2024
1 parent 0bffdf3 commit f762f01
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
3 changes: 2 additions & 1 deletion localtileserver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# flake8: noqa: F401
from localtileserver._version import __version__
from localtileserver.client import TileClient, get_or_create_tile_client, open
from localtileserver.client import TileClient, get_or_create_tile_client
from localtileserver.helpers import hillshade, parse_shapely, polygon_to_geojson, save_new_raster
from localtileserver.io import open
from localtileserver.report import Report
from localtileserver.tiler import get_cache_dir, make_vsi, purge_cache
from localtileserver.validate import validate_cog
Expand Down
26 changes: 0 additions & 26 deletions localtileserver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,29 +589,3 @@ def get_or_create_tile_client(
del source
raise e
return source, _internally_created


def open(
source: Union[
pathlib.Path,
str,
TileClient,
rasterio.io.DatasetReaderBase,
],
port: Union[int, str] = "default",
debug: bool = False,
):
"""Open a raster file as a TileClient.
Parameters
----------
source : pathlib.Path, str, TileClient, rasterio.io.DatasetReaderBase
The source dataset to use for the tile client.
port : int
The port on your host machine to use for the tile server. This defaults
to getting an available port.
debug : bool
Run the tile server in debug mode.
"""
return get_or_create_tile_client(source, port=port, debug=debug)[0]
32 changes: 32 additions & 0 deletions localtileserver/io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pathlib
from typing import Union

import rasterio

from localtileserver.client import TileClient, get_or_create_tile_client


def open(
source: Union[
pathlib.Path,
str,
TileClient,
rasterio.io.DatasetReaderBase,
],
port: Union[int, str] = "default",
debug: bool = False,
):
"""Open a raster file as a TileClient.
Parameters
----------
source : pathlib.Path, str, TileClient, rasterio.io.DatasetReaderBase
The source dataset to use for the tile client.
port : int
The port on your host machine to use for the tile server. This defaults
to getting an available port.
debug : bool
Run the tile server in debug mode.
"""
return get_or_create_tile_client(source, port=port, debug=debug)[0]

0 comments on commit f762f01

Please sign in to comment.