hut_services
¶
Modules:
-
core– -
geocode– -
osm– -
refuges_info– -
services– -
wikicommons– -
wikidata–
Classes:
-
AnswerEnum–Anser enum.
-
AuthorSchema–Author information.
-
BaseHutConverterSchema–Base class used for a converter schema.
-
BaseHutSourceSchema–Base class for a hut source.
-
CapacitySchema–Hut capacities.
-
ContactSchema–Schema for a contact.
-
HutSchema–Hut schema.
-
HutTypeEnum–Enum with hut types.
-
HutTypeSchema–Hut type schema.
-
LicenseSchema–License information.
-
OpenMonthlySchema–Shows for every month if it is usally, open, partially open or closed.
-
OwnerSchema–Schema for the owner.
-
PhotoSchema–Schema for a hut photo.
-
PhotoSchemaOld–Photo schema.
-
SourceDataSchema–SourceData schema
-
SourcePropertiesSchema–Properties saved together with the source data.
-
SourceSchema–Source information.
-
LocationEleSchema–Location with longitude, latitude and (optional) elevation in WSG84.
-
LocationSchema–Location with longitude, latitude and optional elevation in WSG84.
-
TranslationSchema–Field with different translations.
-
BaseService–Base service which is inheritated by other services.
-
GeocodeService–Service to get Information from
-
OsmService–Service to get huts from
-
RefugesInfoService–Service to get huts from
Functions:
-
file_cache–Chaches function, if 'forever' is True, cache will never expire (and 'expire_in_seconds' will be ignored).
Attributes:
-
clear_file_cache–Cleares cache.
-
HutSourceSchema(TypeAlias) –Hut source schema, used for typing.
-
SERVICES(dict[str, BaseService[HutSourceSchema]]) –
Attributes¶
HutSourceSchema
module-attribute
¶
HutSourceSchema: TypeAlias = BaseHutSourceSchema[
SourceDataSchema, SourcePropertiesSchema
]
Hut source schema, used for typing.
With pydantic BaseModel and SourcePrpertiesSchema.
SERVICES
module-attribute
¶
SERVICES: dict[str, BaseService[HutSourceSchema]] = {
"osm": OsmService(),
"refuges": RefugesInfoService(),
"wikidata": WikidataService(),
}
Classes¶
AnswerEnum
¶
Anser enum.
'yesish' and 'noish' means it is likely to be 'yes' or 'no'. 'maybe' means is is either 'yes' or 'no'.
Attributes:
Attributes¶
AuthorSchema
¶
BaseHutConverterSchema
¶
Base class used for a converter schema.
Attributes:
-
source(SourceSchema | None) –Source data
All attributes as in HutSchema either as
attribute or pydantic computed_field.
Examples:
See hut_services.osm.schema.OsmHut0Convert.
Classes:
-
FieldNotImplementedError–Field is not implemented.
Methods:
-
get_hut–Convert to hut.
Attributes:
-
source_data(TSourceData) – -
include_photos(bool) – -
slug(str) – -
name(TranslationSchema) – -
source(SourceSchema | None) – -
author(AuthorSchema | None) – -
source_name(str) – -
location(LocationEleSchema) – -
description(TranslationSchema) – -
notes(list[TranslationSchema]) – -
owner(OwnerSchema | None) – -
url(str) – -
contacts(list[ContactSchema]) – -
country_code(str | None) – -
comment(str) – -
capacity(CapacitySchema) – -
hut_type(HutTypeSchema) – -
photos(list[PhotoSchema]) – -
open_monthly(OpenMonthlySchema) – -
is_active(bool) – -
is_public(bool) – -
extras(dict[str, Any]) –
Attributes¶
source_data
class-attribute
instance-attribute
¶
Classes¶
FieldNotImplementedError
¶
FieldNotImplementedError(
obj: BaseHutConverterSchema, field: str
)
Field is not implemented.
Parameters:
-
(obj¶BaseHutConverterSchema) –Current object.
-
(field¶str) –Field which is not implementd.
Functions¶
Functions¶
BaseHutSourceSchema
¶
Base class for a hut source.
Attributes:
-
source_name(str) –Name of the source (e.g. osm, wikipedia, ...).
-
name(str) –Original hut name.
-
location(LocationEleSchema | None) –Location of the hut.
-
source_id(str) –Originial source id of the hut.
-
source_data(TSourceData_co | None) –Source data for this hut.
-
source_properties(TProperties_co | None) –Additinal source data properties.
-
version(int) –Version of the service when this entry was created.
-
created(datetime) –Created.
Examples:
class MyHutSource(BaseHutSourceSchema[MyHutSchema, SourcePropertiesSchema]):
source_name: str = "my"
Or with different properties: hut_services.osm.schema.OsmHutSource.
Methods:
Attributes:
-
model_config– -
source_name(str) – -
name(str) – -
location(LocationEleSchema | None) – -
source_id(str) – -
source_data(TSourceData_co | None) – -
source_properties(TProperties_co | None) – -
version(int) – -
created(datetime) – -
source_properties_schema(dict) –Returns JSON schema for the 'source_properties' fields.
Attributes¶
model_config
class-attribute
instance-attribute
¶
source_name
class-attribute
instance-attribute
¶
source_name: str = Field(
"unknown",
description="Name of the source (e.g. osm, wikipedia, ...).",
)
location
class-attribute
instance-attribute
¶
location: LocationEleSchema | None = Field(
None, description="Location of the hut."
)
source_id
class-attribute
instance-attribute
¶
source_data
class-attribute
instance-attribute
¶
source_properties
class-attribute
instance-attribute
¶
source_properties: TProperties_co | None = Field(
None, description="Additinal source data properties."
)
version
class-attribute
instance-attribute
¶
version: int = Field(
default=0,
description="Version of the service when this entry was created.",
)
created
class-attribute
instance-attribute
¶
created: datetime = Field(
default_factory=now,
description="Version of the service when this entry was created.",
)
source_properties_schema
property
¶
Returns JSON schema for the 'source_properties' fields.
Returns:
-
dict–JSON schema.
Functions¶
show
¶
show(
source_id: bool = True,
location: bool = True,
elevation: bool = True,
source_name: bool = True,
version: bool = False,
created: bool = False,
) -> str
Returns a formatted string with the hut information which can be printed.
Parameters:
-
(source_id¶bool, default:True) –Show source ID.
-
(location¶bool, default:True) –Show location.
-
(elevation¶bool, default:True) –Show elevation.
-
(source_name¶bool, default:True) –Show source name.
-
(version¶bool, default:False) –Show verions.
-
(created¶bool, default:False) –Show created date.
Returns:
-
str–Formatted string.
CapacitySchema
¶
Hut capacities.
Hint
For unattended accomodations the opened attribute should be used.
Attributes:
-
open–Capacity when the hut is open
-
closed–Capacity when the hut is closed (shelter, winterroom, ...)
Attributes:
-
model_config– -
if_open(NaturalInt | None) – -
if_closed(NaturalInt | None) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
if_open
class-attribute
instance-attribute
¶
if_open: NaturalInt | None = Field(
None,
alias="open",
description="Capacity when the hut is open",
)
if_closed
class-attribute
instance-attribute
¶
if_closed: NaturalInt | None = Field(
None,
alias="closed",
description="Capacity when the hut is closed (shelter, winterroom, ...)",
)
ContactSchema
¶
Schema for a contact.
Attributes:
-
name(str) –Contact name (persion or organization), can also be empty.
-
email(str) –E-mail address.
-
phone(str) –Phone number.
-
mobile(str) –Mobule phone number.
-
function(str) –Function, e.g. hut warden.
-
url(str) –Additional url for this contact (not the hut website).
-
address(str) –Address (street, city).
-
note(TranslationSchema) –Additional note/information.
-
is_active(bool) –Contact is active.
-
is_public(bool) –Show contact public.
Methods:
-
extract_phone_numbers–Extracts phone numbers from a string and returns them formatted
-
number_to_phone_or_mobile–Given a phone number it returns it eihter as
phoneormobilenumber.
Attributes:
-
model_config– -
name(str) – -
email(str) – -
phone(str) – -
mobile(str) – -
function(str) – -
url(str) – -
address(str) – -
note(TranslationSchema) – -
is_active(bool) – -
is_public(bool) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
note
class-attribute
instance-attribute
¶
note: TranslationSchema = Field(
default_factory=TranslationSchema
)
Functions¶
extract_phone_numbers
classmethod
¶
extract_phone_numbers(
numbers_string: str, region: str | None
) -> list[str]
Extracts phone numbers from a string and returns them formatted
with international code.
Uses the phonenumbers package.
Parameters:
Returns:
-
list[str]–A list with formatted phone numbers.
number_to_phone_or_mobile
classmethod
¶
number_to_phone_or_mobile(
numbers: str | Sequence[str],
region: str | None,
formatted: bool = False,
) -> PhoneMobile
Given a phone number it returns it eihter as phone or mobile number.
Uses the phonenumbers package.
Parameters:
-
(numbers¶str | Sequence[str]) –List or string of phone numbers, they are extraced and the two assigned to phone and mobile.
-
(region¶str | None) –Country code.
-
(formatted¶bool, default:False) –Phone list is alreaad formatted
Returns:
-
PhoneMobile–Tuple with
phoneandmobilenumber ((phone, mobile)).
HutSchema
¶
Hut schema.
Attributes:
-
slug(str) –Hut slug, if empty it is replaced by slugified
name. -
name(TranslationSchema) –Original hut name.
-
location(LocationEleSchema) –Location of the hut.
-
description(TranslationSchema) –Description.
-
notes(Sequence[TranslationSchema]) –Additional public notes to the hut.
-
owner(OwnerSchema | None) –Hut owner.
-
url(str) –Hut website.
-
contacts(Sequence[ContactSchema]) –Hut contacts.
-
country_code(str | None) –Country.
-
comment(str) –Additional private comment to the hut.
-
capacity(CapacitySchema) –Cpacities of the hut.
-
type(CapacitySchema) –Hut type (e.g.
selfhut). -
photos(list[PhotoSchema]) –Hut photos.
-
open_monthly(OpenMonthlySchema) –Monthly value if open, closed or partially open.
-
is_active(bool) –Hut is active.
-
is_public(bool) –Show hut public.
-
extras(Mapping[str, Any]) –Additional information to the hut as dictionary.
-
source(SourceSchema | None) –Short name of source (e.g. 'hrs' for alpsonline.org, or 'sac', 'refuges', ...).
Methods:
Attributes:
-
model_config– -
slug(str) – -
name(TranslationSchema) – -
location(LocationEleSchema) – -
description(TranslationSchema) – -
license(LicenseSchema | None) – -
source(SourceSchema | None) – -
author(AuthorSchema | None) – -
notes(Sequence[TranslationSchema]) – -
owner(OwnerSchema | None) – -
url(str) – -
contacts(Sequence[ContactSchema]) – -
country_code(str | None) – -
comment(str) – -
capacity(CapacitySchema) – -
hut_type(HutTypeSchema) – -
photos(list[PhotoSchema]) – -
open_monthly(OpenMonthlySchema) – -
is_active(bool) – -
is_public(bool) – -
extras(Mapping[str, Any]) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
name
class-attribute
instance-attribute
¶
name: TranslationSchema = Field(
..., description="Original hut name."
)
location
class-attribute
instance-attribute
¶
location: LocationEleSchema = Field(
...,
description="Location of the hut with optional elevation.",
)
description
class-attribute
instance-attribute
¶
description: TranslationSchema = Field(
default_factory=TranslationSchema
)
license
class-attribute
instance-attribute
¶
license: LicenseSchema | None = Field(
None,
description="License for the hut information (mainly descpription)",
)
source
class-attribute
instance-attribute
¶
source: SourceSchema | None = Field(
None,
description="Source origin information (e.g. 'hrs' for alpsonline.org, or 'sac', 'refuges', ...).",
)
author
class-attribute
instance-attribute
¶
author: AuthorSchema | None = Field(
None,
description="Author of the hut information, this is an addition to the source information (e.g. custom author)",
)
notes
class-attribute
instance-attribute
¶
notes: Sequence[TranslationSchema] = Field(
..., description="Additional notes to the hut."
)
contacts
class-attribute
instance-attribute
¶
contacts: Sequence[ContactSchema] = Field(
default_factory=list
)
country_code
class-attribute
instance-attribute
¶
comment
class-attribute
instance-attribute
¶
comment: str = Field(
"",
max_length=20000,
description="Additional private comment, e.g for review.",
)
extras
class-attribute
instance-attribute
¶
extras: Mapping[str, Any] = Field(
default_factory=dict,
description="Additional information as dictionary.",
)
Functions¶
HutTypeEnum
¶
HutTypeSchema
¶
Hut type schema.
Defines the type of the hut if it is open and closed. E.g. a hut can be a 'selfhut' if it is closed.
If a hut is always open do not add anything to closed. If it is specifcally closed, e.g. during winter ass 'closed'.
Attributes:
-
open–Type when the hut is open
-
closed–Type when the hut is closed (bivouac, selfhut, closed, ...)
Attributes:
-
model_config– -
if_open(HutTypeEnum) – -
if_closed(HutTypeEnum | None) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
if_open
class-attribute
instance-attribute
¶
if_open: HutTypeEnum = Field(
unknown,
alias="open",
description="Type when the hut is open",
)
if_closed
class-attribute
instance-attribute
¶
if_closed: HutTypeEnum | None = Field(
None,
alias="closed",
description="Type when the hut is closed (bivouac, selfhut, closed, ...)",
)
LicenseSchema
¶
License information.
Attributes:
-
slug(str) –Identifier or slug of the license (e.g. by-sa, cc-0, ...).
-
url(HttpUrl | None) –URL of the license.
-
name(str) –Fullname of the license.
Attributes:
-
model_config– -
slug(str) – -
url(HttpUrl | None) – -
name(str) –
OpenMonthlySchema
¶
Shows for every month if it is usally, open, partially open or closed. Can be accessed as index, but it starts with 1 (month_01)!.
Attributes:
-
url(str) –URL which shows if it is open or not.
-
month_mm(OpenMonthly) –Month (starting with 01).
Methods:
-
__getitem__– -
__setitem__– -
__iter__– -
__next__– -
set_month–
Attributes:
-
model_config– -
url(str) – -
month_01(AnswerEnum) – -
month_02(AnswerEnum) – -
month_03(AnswerEnum) – -
month_04(AnswerEnum) – -
month_05(AnswerEnum) – -
month_06(AnswerEnum) – -
month_07(AnswerEnum) – -
month_08(AnswerEnum) – -
month_09(AnswerEnum) – -
month_10(AnswerEnum) – -
month_11(AnswerEnum) – -
month_12(AnswerEnum) –
OwnerSchema
¶
Schema for the owner.
Attributes:
-
slug(str) –Owner slug, if empty it is replaced by slugified
name. -
name(str) –Owner name, required.
-
url(str) –Owners URL (not the hut website).
-
note(TranslationSchema) –Additonal (public) note to the owner.
-
comment(str) –Private comment to the owner.
-
contacts(ContactSchema | None) –Contacts used for the owner.
Methods:
-
add_slug–
Attributes:
-
model_config– -
slug(str) – -
name(str) – -
url(str) – -
note(TranslationSchema) – -
comment(str) – -
contacts(ContactSchema | None) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
note
class-attribute
instance-attribute
¶
note: TranslationSchema = Field(
default_factory=TranslationSchema
)
Functions¶
PhotoSchema
¶
Schema for a hut photo.
Attributes:
-
model_config– -
licenses(list[LicenseSchema]) – -
caption(TranslationSchema) – -
source(SourceSchema | None) – -
author(AuthorSchema | None) – -
comment(str) – -
raw_url(HttpUrl) – -
width(int) – -
height(int) – -
url(HttpUrl) – -
capture_date(datetime | None) – -
tags(set[str] | None) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
caption
class-attribute
instance-attribute
¶
caption: TranslationSchema = Field(
default_factory=TranslationSchema
)
comment
class-attribute
instance-attribute
¶
comment: str = Field(
"",
max_length=20000,
description="Additional private comment, e.g for review.",
)
raw_url
class-attribute
instance-attribute
¶
raw_url: HttpUrl = Field(
...,
description="Url to the raw image, this can be used to download or embed the image.",
)
width
class-attribute
instance-attribute
¶
height
class-attribute
instance-attribute
¶
url
class-attribute
instance-attribute
¶
url: HttpUrl = Field(
...,
description="Url to the image on the side, this should not be used to include it direclty, rather to just link to it.",
)
PhotoSchemaOld
¶
Photo schema.
Attributes:
-
model_config– -
attribution(str) – -
url(str) – -
thumb(str) – -
caption(TranslationSchema | None) – -
comment(str) – -
is_public(bool) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
attribution
class-attribute
instance-attribute
¶
attribution: str = Field(
"",
description="Attribution, resp. copyright information as markdown text",
)
thumb
class-attribute
instance-attribute
¶
caption
class-attribute
instance-attribute
¶
caption: TranslationSchema | None = Field(
None, description="Original hut name."
)
comment
class-attribute
instance-attribute
¶
comment: str = Field(
"",
max_length=20000,
description="Additional private comment, e.g for review.",
)
SourceDataSchema
¶
SourceData schema
Methods:
Attributes:
SourcePropertiesSchema
¶
Properties saved together with the source data.
Examples:
See hut_services.osm.schema.OsmProperties.
SourceSchema
¶
Source information.
Attributes:
-
ident(str) –Identifier or slug of the source.
-
name(str) –Name of the source, either person or organization (e.g refuges, wikicommon, sac, ...)
-
url(HttpUrl | None) –URL of the source.
Attributes:
-
model_config– -
ident(str) – -
name(str) – -
url(HttpUrl | None) –
LocationEleSchema
¶
Location with longitude, latitude and (optional) elevation in WSG84.
Attributes:
-
lat(Latitude) –Latitude.
-
lon(Longitude) –Longitude.
-
ele(Elevation | None) –Elevation in meter.
Methods:
Attributes:
-
lat(Latitude) – -
lon(Longitude) – -
lon_lat(tuple[Longitude, Latitude]) –Tuple with (
longitude,latitude). -
model_config– -
ele(Elevation | None) – -
lon_lat_ele(tuple[Longitude, Latitude, Elevation]) –Tuple with longitude, latitude and elevation. If elevation is not defined it returns 0.
-
geojson(Point) –Retuns as geojson point.
LocationSchema
¶
Location with longitude, latitude and optional elevation in WSG84.
Attributes:
-
lon(Longitude) –Longitude (x).
-
lat(Latitude) –Latitude (y).
-
ele(Latitude) –Elevation in meter.
Methods:
-
check_field_aliases– -
from_swiss–Takes LV03 or LV95 (newest) coordiates.
-
__str__–
Attributes:
-
model_config– -
lat(Latitude) – -
lon(Longitude) – -
lon_lat(tuple[Longitude, Latitude]) –Tuple with (
longitude,latitude). -
geojson(Point) –Retuns as geojson point.
Attributes¶
lon_lat
property
¶
Functions¶
from_swiss
classmethod
¶
from_swiss(
ch_lat: float, ch_lon: float, ele: float | None
) -> LocationSchema | LocationEleSchema
Takes LV03 or LV95 (newest) coordiates. More information.
Parameters:
-
(ch_lat¶float) –Latitude in swiss format (east).
-
(ch_lon¶float) –Longitude in swiss format (north).
-
(ele¶float | None) –Elevation in meter.
Returns:
-
LocationSchema | LocationEleSchema–LocationSchemaobject.
TranslationSchema
¶
BaseService
¶
BaseService(
support_bbox: bool = False,
support_limit: bool = False,
support_offset: bool = False,
support_convert: bool = False,
support_booking: bool = False,
)
Base service which is inheritated by other services.
Warning
Do not use this directly.
The following attributes are used to define which paramets are supported by a service.
Attributes:
-
support_bbox(bool) –Support for
bboxas parameter. -
support_limit(bool) –Support for
limitas parameter. -
support_offset(bool) –Support for
offsetas parameter. -
support_convert(bool) –Support for
convertas parameter.
Examples:
Custom service base in BaseService.
For this the two schemas MyHutSource and MyInfoHutConvert need to be defined as well.
from typing import Any
from hut_services.core.schema.geo import BBox
from hut_services import BaseService, HutSchema
# TODO: define this somewhere:
from my_service.schema import MyHutSource, MyInfoHutConvert
class MyService(BaseService[MyHutSource]):
def __init__(self, request_url: str = "http://hut.info"):
super().__init__(support_bbox=True,
support_limit=True,
support_offset=True,
support_convert=True)
self.request_url = request_url
def get_huts_from_source(
self, bbox: BBox | None = None, limit: int = 1,
offset: int = 0, **kwargs: Any
) -> list[MyHutSource]:
src_huts = httpx.get(self.request_url)
return [MyHutSource(**h) for h in src_huts]
def convert(self, src: MyHutSource) -> HutSchema:
return MyInfoHutConvert(source=src.source_data).get_hut()
Classes:
-
MethodNotImplementedError–Method is not implemented exception.
Methods:
-
clear_all_cache–Clears the cache of all services!
-
get_huts_from_source–Get all huts from source.
-
convert–Convert one hut from source to
HutSchema. -
get_huts–Get all huts form source and converts them.
-
get_bookings–Get bookings for a list of huts.
Attributes:
-
support_bbox(bool) – -
support_limit(bool) – -
support_offset(bool) – -
support_convert(bool) – -
support_booking(bool) –
Attributes¶
Classes¶
MethodNotImplementedError
¶
MethodNotImplementedError(obj: BaseService, method: str)
Method is not implemented exception.
Parameters:
-
(obj¶BaseService) –Service object (e.g.
MyService). -
(method¶str) –Method which is not implemented.
Functions¶
Functions¶
get_huts_from_source
¶
convert
¶
convert(
src: Mapping | Any, include_photos: bool = True
) -> HutSchema
get_huts
¶
get_huts(
bbox: BBox | None = None,
limit: int = 1,
offset: int = 0,
include_photos: bool = True,
**kwargs: Any,
) -> list[HutSchema]
Get all huts form source and converts them.
Calls get_huts_from_source()
and convert().
Returns:
-
list[HutSchema]–Converted huts from source.
get_bookings
¶
get_bookings(
date: datetime | date | Literal["now"] | None = None,
days: int | None = None,
source_ids: list[int | str] | None = None,
lang: str = "de",
request_interval: float | None = None,
) -> dict[int | str, HutBookingsSchema]
Get bookings for a list of huts.
Parameters:
-
(date¶datetime | date | Literal['now'] | None, default:None) –Start daye for the bookings
-
(days¶int | None, default:None) –Duration in days
-
(source_ids¶list[int | str] | None, default:None) –A list of ids to return (source id, not the hut id), if set to
Noneall are returned -
(lang¶str, default:'de') –Language for the response
-
(request_interval¶float | None, default:None) –Interval between requests (if each huts needs a request)
Returns:
-
dict[int | str, HutBookingsSchema]–A dictionary with the bookings (key = source id).
GeocodeService
¶
Service to get Information from Nominatim.
Note
This is not used to get huts, rather to get additional info (like location) from huts.
Classes:
-
MethodNotImplementedError–Method is not implemented exception.
Methods:
-
clear_all_cache–Clears the cache of all services!
-
get_huts_from_source–Get all huts from source.
-
get_huts–Get all huts form source and converts them.
-
get_bookings–Get bookings for a list of huts.
-
get_location_by_name–Get location (coordinates) from a name (uses 'https://nominatim.openstreetmap.org).
-
get_elevations–Get elevations from a list of locations (coordinates) (uses 'https://open-elevation.com).
-
get_elevation–Get elevation from a location (coordinates) (uses 'https://open-elevation.com).
-
convert–
Attributes:
-
support_bbox(bool) – -
support_limit(bool) – -
support_offset(bool) – -
support_convert(bool) – -
support_booking(bool) – -
loc_request_url– -
ele_request_url– -
httpx_client–
Attributes¶
loc_request_url
instance-attribute
¶
ele_request_url
instance-attribute
¶
Classes¶
MethodNotImplementedError
¶
MethodNotImplementedError(obj: BaseService, method: str)
Method is not implemented exception.
Parameters:
-
(obj¶BaseService) –Service object (e.g.
MyService). -
(method¶str) –Method which is not implemented.
Functions¶
Functions¶
get_huts_from_source
¶
get_huts
¶
get_huts(
bbox: BBox | None = None,
limit: int = 1,
offset: int = 0,
include_photos: bool = True,
**kwargs: Any,
) -> list[HutSchema]
Get all huts form source and converts them.
Calls get_huts_from_source()
and convert().
Returns:
-
list[HutSchema]–Converted huts from source.
get_bookings
¶
get_bookings(
date: datetime | date | Literal["now"] | None = None,
days: int | None = None,
source_ids: list[int | str] | None = None,
lang: str = "de",
request_interval: float | None = None,
) -> dict[int | str, HutBookingsSchema]
Get bookings for a list of huts.
Parameters:
-
(date¶datetime | date | Literal['now'] | None, default:None) –Start daye for the bookings
-
(days¶int | None, default:None) –Duration in days
-
(source_ids¶list[int | str] | None, default:None) –A list of ids to return (source id, not the hut id), if set to
Noneall are returned -
(lang¶str, default:'de') –Language for the response
-
(request_interval¶float | None, default:None) –Interval between requests (if each huts needs a request)
Returns:
-
dict[int | str, HutBookingsSchema]–A dictionary with the bookings (key = source id).
get_location_by_name
¶
get_location_by_name(
name: str, client: Client | None = None
) -> LocationEleSchema | None
Get location (coordinates) from a name (uses 'https://nominatim.openstreetmap.org).
get_elevations
¶
get_elevations(
locations: Sequence[LocationSchema | LocationEleSchema],
client: Client | None = None,
) -> list[LocationEleSchema]
Get elevations from a list of locations (coordinates) (uses 'https://open-elevation.com).
get_elevation
¶
get_elevation(
location: LocationSchema | LocationEleSchema,
client: Client | None = None,
) -> LocationEleSchema
Get elevation from a location (coordinates) (uses 'https://open-elevation.com).
OsmService
¶
Service to get huts from Open Street Map with overpass api.
Note
The methods are descriebed in BaseService.
Classes:
-
MethodNotImplementedError–Method is not implemented exception.
Methods:
-
clear_all_cache–Clears the cache of all services!
-
get_huts–Get all huts form source and converts them.
-
get_bookings–Get bookings for a list of huts.
-
get_huts_from_source– -
convert–
Attributes:
-
support_bbox(bool) – -
support_limit(bool) – -
support_offset(bool) – -
support_convert(bool) – -
support_booking(bool) – -
request_url–
Attributes¶
Classes¶
MethodNotImplementedError
¶
MethodNotImplementedError(obj: BaseService, method: str)
Method is not implemented exception.
Parameters:
-
(obj¶BaseService) –Service object (e.g.
MyService). -
(method¶str) –Method which is not implemented.
Functions¶
Functions¶
get_huts
¶
get_huts(
bbox: BBox | None = None,
limit: int = 1,
offset: int = 0,
include_photos: bool = True,
**kwargs: Any,
) -> list[HutSchema]
Get all huts form source and converts them.
Calls get_huts_from_source()
and convert().
Returns:
-
list[HutSchema]–Converted huts from source.
get_bookings
¶
get_bookings(
date: datetime | date | Literal["now"] | None = None,
days: int | None = None,
source_ids: list[int | str] | None = None,
lang: str = "de",
request_interval: float | None = None,
) -> dict[int | str, HutBookingsSchema]
Get bookings for a list of huts.
Parameters:
-
(date¶datetime | date | Literal['now'] | None, default:None) –Start daye for the bookings
-
(days¶int | None, default:None) –Duration in days
-
(source_ids¶list[int | str] | None, default:None) –A list of ids to return (source id, not the hut id), if set to
Noneall are returned -
(lang¶str, default:'de') –Language for the response
-
(request_interval¶float | None, default:None) –Interval between requests (if each huts needs a request)
Returns:
-
dict[int | str, HutBookingsSchema]–A dictionary with the bookings (key = source id).
get_huts_from_source
¶
get_huts_from_source(
bbox: BBox | None = None,
limit: int = 1,
offset: int = 0,
**kwargs: dict,
) -> list[OsmHutSource]
RefugesInfoService
¶
Service to get huts from refuges.info with its api.
Note
The methods are descriebed in BaseService.
Classes:
-
MethodNotImplementedError–Method is not implemented exception.
Methods:
-
clear_all_cache–Clears the cache of all services!
-
get_huts–Get all huts form source and converts them.
-
get_bookings–Get bookings for a list of huts.
-
get_huts_from_source– -
convert–
Attributes:
-
support_bbox(bool) – -
support_limit(bool) – -
support_offset(bool) – -
support_convert(bool) – -
support_booking(bool) – -
request_url–
Attributes¶
Classes¶
MethodNotImplementedError
¶
MethodNotImplementedError(obj: BaseService, method: str)
Method is not implemented exception.
Parameters:
-
(obj¶BaseService) –Service object (e.g.
MyService). -
(method¶str) –Method which is not implemented.
Functions¶
Functions¶
get_huts
¶
get_huts(
bbox: BBox | None = None,
limit: int = 1,
offset: int = 0,
include_photos: bool = True,
**kwargs: Any,
) -> list[HutSchema]
Get all huts form source and converts them.
Calls get_huts_from_source()
and convert().
Returns:
-
list[HutSchema]–Converted huts from source.
get_bookings
¶
get_bookings(
date: datetime | date | Literal["now"] | None = None,
days: int | None = None,
source_ids: list[int | str] | None = None,
lang: str = "de",
request_interval: float | None = None,
) -> dict[int | str, HutBookingsSchema]
Get bookings for a list of huts.
Parameters:
-
(date¶datetime | date | Literal['now'] | None, default:None) –Start daye for the bookings
-
(days¶int | None, default:None) –Duration in days
-
(source_ids¶list[int | str] | None, default:None) –A list of ids to return (source id, not the hut id), if set to
Noneall are returned -
(lang¶str, default:'de') –Language for the response
-
(request_interval¶float | None, default:None) –Interval between requests (if each huts needs a request)
Returns:
-
dict[int | str, HutBookingsSchema]–A dictionary with the bookings (key = source id).
get_huts_from_source
¶
get_huts_from_source(
bbox: BBox | None = None,
limit: int = 1,
offset: int = 0,
**kwargs: Any,
) -> list[RefugesInfoHutSource]
Functions¶
file_cache
¶
file_cache(
func: None | Callable = None,
ignore: Sequence = [],
expire_in_seconds: int = default_seconds,
forever: bool = False,
) -> Any
Chaches function, if 'forever' is True, cache will never expire (and 'expire_in_seconds' will be ignored).