camptocamp
¶
Camptocamp.org hut service package.
Modules:
-
open_period–Parse opening months from camptocamp's free text
access_periodfield. -
schema–Camptocamp.org schema for hut data.
-
service–Camptocamp.org service for retrieving hut data.
-
utils–Utilities to get image data from camptocamp.org.
Classes:
-
CamptocampApiResponse–Response from camptocamp API.
-
CamptocampDocument–Camptocamp document/hut data model.
-
CamptocampHut0Convert–Convert Camptocamp data to HutSchema.
-
CamptocampHutSource–Data from camptocamp.org database.
-
CamptocampLocale–Camptocamp locale data.
-
CamptocampProperties–Properties saved together with the source data.
-
CamptocampService–Service to get huts from Camptocamp.org
Classes¶
CamptocampApiResponse
¶
Response from camptocamp API.
Attributes:
-
documents(list[CamptocampDocument]) – -
total(int | None) –
Attributes¶
CamptocampDocument
¶
Camptocamp document/hut data model.
Methods:
-
get_id–Get the document ID as string.
-
get_name–Get the name from the first locale.
-
get_location–Extract location from geometry.
-
get_locale–Get locale for specific language.
-
get_image_ids–Get image document ids from the associated images.
Attributes:
-
model_config– -
document_id(int) – -
version(int) – -
locales(list[CamptocampLocale]) – -
geometry(CamptocampGeometry) – -
quality(str | None) – -
waypoint_type(str | None) – -
elevation(int | None) – -
available_langs(list[str] | None) – -
areas(list[CamptocampArea]) – -
protected(bool) – -
type(str | None) – -
capacity(int | None) – -
capacity_staffed(int | None) – -
phone(str | None) – -
phone_custodian(str | None) – -
url(str | None) – -
custodian(str | None) – -
custodianship(str | None) – -
matress_unstaffed(bool | None) – -
blanket_unstaffed(bool | None) – -
gas_unstaffed(bool | None) – -
heating_unstaffed(bool | None) – -
associations(dict[str, Any] | None) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
areas
class-attribute
instance-attribute
¶
areas: list[CamptocampArea] = Field(default_factory=list)
Functions¶
CamptocampHut0Convert
¶
Convert Camptocamp data to HutSchema.
Classes:
-
FieldNotImplementedError–Field is not implemented.
Methods:
-
get_hut–Convert to hut.
Attributes:
-
source_data(TSourceData) – -
include_photos(bool) – -
slug(str) – -
location(LocationEleSchema) – -
country_code(str | None) – -
comment(str) – -
is_active(bool) – -
is_bookable(bool) –Whether availability can be fetched for this hut through the
-
extras(dict[str, Any]) – -
name(TranslationSchema) –Get name with translations.
-
source_name(str) – -
description(TranslationSchema) –Get description with translations.
-
author(AuthorSchema | None) –Get author information.
-
source(SourceSchema | None) –Get source information.
-
license(LicenseSchema | None) –Get license information.
-
notes(list[TranslationSchema]) –Get notes including access and period information.
-
owner(OwnerSchema | None) –Get owner information.
-
photos(list[PhotoSchema]) –Get photos associated with this hut from camptocamp.org.
-
url(str) –Hut website if available (the camptocamp page link is in
source). -
capacity(CapacitySchema) –Get capacity information.
-
hut_type(HutTypeSchema) –Guess hut type based on waypoint_type and other info.
-
open_monthly(OpenMonthlySchema) –Opening months parsed from the (free text) access period.
-
is_public(bool) –Determine if hut is public.
-
contacts(list[ContactSchema]) –Get contact information.
Attributes¶
source_data
class-attribute
instance-attribute
¶
is_bookable
property
¶
Whether availability can be fetched for this hut through the source service's online booking system.
Booking services override this (e.g. only huts with a booking structure); huts of sources without online booking are never bookable.
photos
property
¶
photos: list[PhotoSchema]
Get photos associated with this hut from camptocamp.org.
capacity
property
¶
capacity: CapacitySchema
Get capacity information.
Camptocamp's capacity is the unstaffed (winter room) number and
capacity_staffed the staffed one: only huts with a staffed capacity
have a second, smaller number for the closed season.
open_monthly
property
¶
open_monthly: OpenMonthlySchema
Opening months parsed from the (free text) access period.
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¶
CamptocampHutSource
¶
Data from camptocamp.org database.
Methods:
Attributes:
-
model_config– -
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.
-
source_name(str) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
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.
CamptocampLocale
¶
Camptocamp locale data.
Attributes:
-
version(int | None) – -
lang(str) – -
title(str) – -
summary(str | None) – -
description(str | None) – -
access(str | None) – -
access_period(str | None) –
Attributes¶
CamptocampProperties
¶
CamptocampService
¶
Service to get huts from Camptocamp.org using their API.
Note
The methods are described 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–Get huts from Camptocamp API.
-
convert–Convert CamptocampHutSource to HutSchema.
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,
total_fallback: TotalFallback
| Mapping[int | str, TotalFallback]
| 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)
-
(total_fallback¶TotalFallback | Mapping[int | str, TotalFallback] | None, default:None) –Caller-provided totals that may OVERWRITE scraped page totals — a single
TotalFallbackfor all huts or a per-hut mapping keyed by source id (int or str) / slug. Priority: booking-service total > this fallback > hut detail. Sources that publish their own totals ignore it; the field also lands inPlacesSchema.total_fallbackfor consumers.
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 = 100,
offset: int = 0,
fetch_details: bool = True,
request_interval: float = 0.5,
**kwargs: Any,
) -> list[CamptocampHutSource]
Get huts from Camptocamp API.
Parameters:
-
(bbox¶BBox | None, default:None) –Bounding box for geographic filtering
-
(limit¶int, default:100) –Maximum number of results
-
(offset¶int, default:0) –Offset for pagination
-
(fetch_details¶bool, default:True) –Whether to fetch detailed information for each hut
-
(request_interval¶float, default:0.5) –Delay in seconds between detail requests (to be nice to the API)
-
(**kwargs¶Any, default:{}) –Additional parameters
Returns:
-
list[CamptocampHutSource]–List of CamptocampHutSource objects
convert
¶
convert(
src: Mapping | Any, include_photos: bool = True
) -> HutSchema