Skip to content

schema

Modules:

Classes:

Attributes

Classes

BookingSchema

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
date instance-attribute
date: date
reservation_status class-attribute instance-attribute
reservation_status: ReservationStatusEnum = unknown
unattended instance-attribute
unattended: bool
places instance-attribute
places: PlacesSchema
link: str | None = None

HutBookingsSchema

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
source_id class-attribute instance-attribute
source_id: int = Field(
    ...,
    description="ID of the booking provider, e.g. alpsonline.org.",
)
start_date instance-attribute
start_date: date
days instance-attribute
days: int
link: str | None = None
bookings instance-attribute
bookings: list[BookingSchema]

OccupancyStatusEnum

Enum with with occuptation status.

Attributes:

Attributes

unknown class-attribute instance-attribute
unknown = 'unknown'
empty class-attribute instance-attribute
empty = 'empty'
low class-attribute instance-attribute
low = 'low'
medium class-attribute instance-attribute
medium = 'medium'
high class-attribute instance-attribute
high = 'high'
full class-attribute instance-attribute
full = 'full'

PlacesSchema

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
free instance-attribute
free: int
total instance-attribute
total: int
occupancy_percent property
occupancy_percent: float
occupancy_steps property
occupancy_steps: float
occupancy_status property
occupancy_status: OccupancyStatusEnum

ReservationStatusEnum

Enum with reservation status.

Attributes:

Attributes

unknown class-attribute instance-attribute
unknown = 'unknown'
possible class-attribute instance-attribute
possible = 'possible'
not_possible class-attribute instance-attribute
not_possible = 'not_possible'
not_online class-attribute instance-attribute
not_online = 'not_online'

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:

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
name class-attribute instance-attribute
name: str = Field('', max_length=70)
email class-attribute instance-attribute
email: str = Field('', max_length=70)
phone class-attribute instance-attribute
phone: str = Field('', max_length=30)
mobile class-attribute instance-attribute
mobile: str = Field('', max_length=30)
function class-attribute instance-attribute
function: str = Field('', max_length=20)
url class-attribute instance-attribute
url: str = Field('', max_length=200)
address class-attribute instance-attribute
address: str = Field('', max_length=200)
note class-attribute instance-attribute
note: TranslationSchema = Field(
    default_factory=TranslationSchema
)
is_active class-attribute instance-attribute
is_active: bool = True
is_public class-attribute instance-attribute
is_public: bool = False

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:

  • numbers_string
    (str) –

    A string with phone numbers in it.

  • region
    (str | None) –

    Country code.

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 phone and mobile number ((phone, mobile)).

HutSchema

Hut schema.

Attributes:

Methods:

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
slug class-attribute instance-attribute
slug: str = Field('', max_length=50)
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."
)
owner class-attribute instance-attribute
owner: OwnerSchema | None = Field(None)
url class-attribute instance-attribute
url: str = Field('', max_length=200)
contacts class-attribute instance-attribute
contacts: Sequence[ContactSchema] = Field(
    default_factory=list
)
country_code class-attribute instance-attribute
country_code: str | None = Field(
    None, max_length=2, min_length=2
)
comment class-attribute instance-attribute
comment: str = Field(
    "",
    max_length=20000,
    description="Additional private comment, e.g for review.",
)
capacity instance-attribute
capacity: CapacitySchema
hut_type class-attribute instance-attribute
hut_type: HutTypeSchema = Field(..., alias='type')
photos class-attribute instance-attribute
photos: list[PhotoSchema] = Field(default_factory=list)
open_monthly instance-attribute
open_monthly: OpenMonthlySchema
is_active class-attribute instance-attribute
is_active: bool = Field(default=True)
is_public class-attribute instance-attribute
is_public: bool = Field(default=True)
extras class-attribute instance-attribute
extras: Mapping[str, Any] = Field(
    default_factory=dict,
    description="Additional information as dictionary.",
)

Functions

__str__
__str__() -> str
add_slug
add_slug() -> HutSchema

BaseHutConverterSchema

Base class used for a converter schema.

Attributes:

All attributes as in HutSchema either as attribute or pydantic computed_field.

Examples:

See hut_services.osm.schema.OsmHut0Convert.

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
name property
source property
source: SourceSchema | None
author property
author: AuthorSchema | None
source_name property
source_name: str
location property
description property
description: TranslationSchema
notes property
notes: list[TranslationSchema]
owner property
owner: OwnerSchema | None
url property
url: str
contacts property
contacts: list[ContactSchema]
country_code property
country_code: str | None
comment property
comment: str
capacity property
capacity: CapacitySchema
hut_type property
hut_type: HutTypeSchema
photos property
photos: list[PhotoSchema]
open_monthly property
open_monthly: OpenMonthlySchema
is_active property
is_active: bool
is_public property
is_public: bool
extras property
extras: dict[str, Any]

Classes

FieldNotImplementedError
FieldNotImplementedError(
    obj: BaseHutConverterSchema, field: str
)

Field is not implemented.

Parameters:

Functions

Functions

get_hut
get_hut() -> HutSchema

Convert to hut.

Returns:

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:

  • __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)
source_name class-attribute instance-attribute
source_name: str = Field(
    "unknown",
    description="Name of the source (e.g. osm, wikipedia, ...).",
)
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.

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.

SourceDataSchema

SourceData schema

Methods:

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)

Functions

get_id
get_id() -> str

Get source id.

get_name
get_name() -> str

Get source hut name.

SourcePropertiesSchema

Properties saved together with the source data.

Examples:

See hut_services.osm.schema.OsmProperties.

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

yes class-attribute instance-attribute
yes = 'yes'
yesish class-attribute instance-attribute
yesish = 'yesish'
maybe class-attribute instance-attribute
maybe = 'maybe'
noish class-attribute instance-attribute
noish = 'noish'
no class-attribute instance-attribute
no = 'no'
unknown class-attribute instance-attribute
unknown = 'unknown'

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:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
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, ...)",
)

HutTypeEnum

Enum with hut types.

Attributes:

Attributes

unknown class-attribute instance-attribute
unknown = 'unknown'
closed class-attribute instance-attribute
closed = 'closed'
campgr class-attribute instance-attribute
campgr = 'campgr'
shelter class-attribute instance-attribute
shelter = 'shelter'
camping class-attribute instance-attribute
camping = 'camping'
bivouac class-attribute instance-attribute
bivouac = 'bivouac'
selfhut class-attribute instance-attribute
selfhut = 'selfhut'
hut class-attribute instance-attribute
hut = 'hut'
alp class-attribute instance-attribute
alp = 'alp'
bhotel class-attribute instance-attribute
bhotel = 'bhotel'
hostel class-attribute instance-attribute
hostel = 'hostel'
hotel class-attribute instance-attribute
hotel = 'hotel'
special class-attribute instance-attribute
special = 'special'
resta class-attribute instance-attribute
resta = 'resta'

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:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
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, ...)",
)

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:

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
url class-attribute instance-attribute
url: str = Field(
    "", description="URL which shows if it is open or not."
)
month_01 class-attribute instance-attribute
month_01: AnswerEnum = unknown
month_02 class-attribute instance-attribute
month_02: AnswerEnum = unknown
month_03 class-attribute instance-attribute
month_03: AnswerEnum = unknown
month_04 class-attribute instance-attribute
month_04: AnswerEnum = unknown
month_05 class-attribute instance-attribute
month_05: AnswerEnum = unknown
month_06 class-attribute instance-attribute
month_06: AnswerEnum = unknown
month_07 class-attribute instance-attribute
month_07: AnswerEnum = unknown
month_08 class-attribute instance-attribute
month_08: AnswerEnum = unknown
month_09 class-attribute instance-attribute
month_09: AnswerEnum = unknown
month_10 class-attribute instance-attribute
month_10: AnswerEnum = unknown
month_11 class-attribute instance-attribute
month_11: AnswerEnum = unknown
month_12 class-attribute instance-attribute
month_12: AnswerEnum = unknown

Functions

__getitem__
__getitem__(month: int) -> AnswerEnum
__setitem__
__setitem__(month: int, value: AnswerEnum) -> None
__iter__
__iter__()
__next__
__next__() -> AnswerEnum
set_month
set_month(month: int, value: AnswerEnum) -> None

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:

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
slug class-attribute instance-attribute
slug: str = Field('', max_length=50)
name class-attribute instance-attribute
name: str = Field(..., max_length=100)
url class-attribute instance-attribute
url: str = Field('', max_length=200)
note class-attribute instance-attribute
note: TranslationSchema = Field(
    default_factory=TranslationSchema
)
comment class-attribute instance-attribute
comment: str = ''
contacts class-attribute instance-attribute
contacts: ContactSchema | None = None

Functions

add_slug
add_slug() -> OwnerSchema

PhotoSchemaOld

Photo schema.

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
attribution class-attribute instance-attribute
attribution: str = Field(
    "",
    description="Attribution, resp. copyright information as markdown text",
)
url instance-attribute
url: str
thumb class-attribute instance-attribute
thumb: str = Field(
    "", description="Url to thumbnail (around 400px)."
)
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.",
)
is_public class-attribute instance-attribute
is_public: bool = Field(default=True)

AuthorSchema

Author information.

Attributes:

  • name (str) –

    Name of the author.

  • url (None | HttpUrl) –

    URL of the author.

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
name instance-attribute
name: str
url class-attribute instance-attribute
url: None | HttpUrl = None

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:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
slug instance-attribute
slug: str
url class-attribute instance-attribute
url: HttpUrl | None = None
name class-attribute instance-attribute
name: str = Field('', max_length=300)

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:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
ident class-attribute instance-attribute
ident: str = Field('', max_length=300)
name class-attribute instance-attribute
name: str = Field('', max_length=300)
url class-attribute instance-attribute
url: HttpUrl | None = None

PhotoSchema

Schema for a hut photo.

Attributes:

Attributes

model_config class-attribute instance-attribute
model_config = ConfigDict(
    from_attributes=True, extra="allow"
)
licenses instance-attribute
licenses: list[LicenseSchema]
caption class-attribute instance-attribute
caption: TranslationSchema = Field(
    default_factory=TranslationSchema
)
source instance-attribute
source: SourceSchema | None
author instance-attribute
author: AuthorSchema | None
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
width: int = Field(
    ..., description="Image width in pixels."
)
height class-attribute instance-attribute
height: int = Field(
    ..., description="Image height in pixels."
)
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.",
)
capture_date instance-attribute
capture_date: datetime | None
tags class-attribute instance-attribute
tags: set[str] | None = None