Skip to content

camptocamp

Camptocamp.org hut service package.

Modules:

  • open_period –

    Parse opening months from camptocamp's free text access_period field.

  • 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:

Classes

CamptocampApiResponse

Response from camptocamp API.

Attributes:

Attributes

documents instance-attribute
documents: list[CamptocampDocument]
total class-attribute instance-attribute
total: int | None = None

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:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True,
    extra="allow",
    populate_by_name=True,
)
document_id instance-attribute
document_id: int
version instance-attribute
version: int
locales instance-attribute
locales: list[CamptocampLocale]
geometry instance-attribute
quality class-attribute instance-attribute
quality: str | None = None
waypoint_type class-attribute instance-attribute
waypoint_type: str | None = None
elevation class-attribute instance-attribute
elevation: int | None = None
available_langs class-attribute instance-attribute
available_langs: list[str] | None = None
areas class-attribute instance-attribute
areas: list[CamptocampArea] = Field(default_factory=list)
protected class-attribute instance-attribute
protected: bool = False
type class-attribute instance-attribute
type: str | None = 'w'
capacity class-attribute instance-attribute
capacity: int | None = None
capacity_staffed class-attribute instance-attribute
capacity_staffed: int | None = None
phone class-attribute instance-attribute
phone: str | None = None
phone_custodian class-attribute instance-attribute
phone_custodian: str | None = None
url class-attribute instance-attribute
url: str | None = None
custodian class-attribute instance-attribute
custodian: str | None = None
custodianship class-attribute instance-attribute
custodianship: str | None = None
matress_unstaffed class-attribute instance-attribute
matress_unstaffed: bool | None = None
blanket_unstaffed class-attribute instance-attribute
blanket_unstaffed: bool | None = None
gas_unstaffed class-attribute instance-attribute
gas_unstaffed: bool | None = None
heating_unstaffed class-attribute instance-attribute
heating_unstaffed: bool | None = None
associations class-attribute instance-attribute
associations: dict[str, Any] | None = None

Functions

get_id
get_id() -> str

Get the document ID as string.

get_name
get_name() -> str

Get the name from the first locale.

get_location
get_location() -> LocationEleSchema

Extract location from geometry.

get_locale
get_locale(lang: str) -> CamptocampLocale | None

Get locale for specific language.

get_image_ids
get_image_ids() -> list[int]

Get image document ids from the associated images.

CamptocampHut0Convert

Convert Camptocamp data to HutSchema.

Classes:

Methods:

Attributes:

Attributes

source_data class-attribute instance-attribute
source_data: TSourceData = Field(..., exclude=True)
include_photos class-attribute instance-attribute
include_photos: bool = True
slug property
slug: str
location property
country_code property
country_code: str | None
comment property
comment: str
is_active property
is_active: bool
is_bookable property
is_bookable: bool

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.

extras property
extras: dict[str, Any]
name property

Get name with translations.

source_name property
source_name: str
description property
description: TranslationSchema

Get description with translations.

author property
author: AuthorSchema | None

Get author information.

source property
source: SourceSchema | None

Get source information.

license property
license: LicenseSchema | None

Get license information.

notes property
notes: list[TranslationSchema]

Get notes including access and period information.

owner property
owner: OwnerSchema | None

Get owner information.

photos property
photos: list[PhotoSchema]

Get photos associated with this hut from camptocamp.org.

url property
url: str

Hut website if available (the camptocamp page link is in source).

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.

hut_type property
hut_type: HutTypeSchema

Guess hut type based on waypoint_type and other info.

open_monthly property
open_monthly: OpenMonthlySchema

Opening months parsed from the (free text) access period.

is_public property
is_public: bool

Determine if hut is public.

contacts property
contacts: list[ContactSchema]

Get contact information.

Classes

FieldNotImplementedError
FieldNotImplementedError(
    obj: BaseHutConverterSchema, field: str
)

Field is not implemented.

Parameters:

Functions

Functions

get_hut
get_hut() -> HutSchema

Convert to hut.

Returns:

CamptocampHutSource

Data from camptocamp.org database.

Methods:

  • __str__ –
  • show –

    Returns a formatted string with the hut information which can be printed.

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(coerce_numbers_to_str=True)
name class-attribute instance-attribute
name: str = Field(..., description='Original hut name.')
location class-attribute instance-attribute
location: LocationEleSchema | None = Field(
    None, description="Location of the hut."
)
source_id class-attribute instance-attribute
source_id: str = Field(
    ..., description="Originial source id of the hut."
)
source_data class-attribute instance-attribute
source_data: TSourceData_co | None = Field(
    None, description="Source data for this hut."
)
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
source_properties_schema: dict

Returns JSON schema for the 'source_properties' fields.

Returns:

  • dict –

    JSON schema.

source_name class-attribute instance-attribute
source_name: str = 'camptocamp'

Functions

__str__
__str__() -> str
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:

Attributes

version class-attribute instance-attribute
version: int | None = None
lang instance-attribute
lang: str
title instance-attribute
title: str
summary class-attribute instance-attribute
summary: str | None = None
description class-attribute instance-attribute
description: str | None = None
access class-attribute instance-attribute
access: str | None = None
access_period class-attribute instance-attribute
access_period: str | None = None

CamptocampProperties

Properties saved together with the source data.

Attributes:

Attributes

quality class-attribute instance-attribute
quality: str = Field(
    ..., description="Quality indicator from camptocamp"
)
waypoint_type class-attribute instance-attribute
waypoint_type: str = Field(
    default="hut",
    description="Waypoint type from camptocamp",
)

CamptocampService

CamptocampService(
    request_url: str = "https://api.camptocamp.org/waypoints",
)

Service to get huts from Camptocamp.org using their API.

Note

The methods are described in BaseService.

Classes:

Methods:

Attributes:

Attributes

support_bbox class-attribute instance-attribute
support_bbox: bool = support_bbox
support_limit class-attribute instance-attribute
support_limit: bool = support_limit
support_offset class-attribute instance-attribute
support_offset: bool = support_offset
support_convert class-attribute instance-attribute
support_convert: bool = support_convert
support_booking class-attribute instance-attribute
support_booking: bool = support_booking
request_url instance-attribute
request_url = request_url

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

clear_all_cache classmethod
clear_all_cache() -> None

Clears the cache of all services!

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 None all 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 TotalFallback for 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 in PlacesSchema.total_fallback for 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:

convert
convert(
    src: Mapping | Any, include_photos: bool = True
) -> HutSchema

Convert CamptocampHutSource to HutSchema.

Parameters:

  • src
    (Mapping | Any) –

    Source data (CamptocampHutSource or dict)

  • include_photos
    (bool, default: True ) –

    Whether to include photos

Returns: