schema
¶
Modules:
Classes:
-
BookingSchema– -
HutBookingsSchema– -
OccupancyStatusEnum–Enum with with occuptation status.
-
PlacesSchema– -
ReservationStatusEnum–Enum with reservation status.
-
ContactSchema–Schema for a contact.
-
HutSchema–Hut schema.
-
BaseHutConverterSchema–Base class used for a converter schema.
-
BaseHutSourceSchema–Base class for a hut source.
-
SourceDataSchema–SourceData schema
-
SourcePropertiesSchema–Properties saved together with the source data.
-
AnswerEnum–Anser enum.
-
CapacitySchema–Hut capacities.
-
HutTypeEnum–Enum with hut types.
-
HutTypeSchema–Hut type schema.
-
OpenMonthlySchema–Shows for every month if it is usally, open, partially open or closed.
-
OwnerSchema–Schema for the owner.
-
PhotoSchemaOld–Photo schema.
-
AuthorSchema–Author information.
-
LicenseSchema–License information.
-
SourceSchema–Source information.
-
PhotoSchema–Schema for a hut photo.
Attributes¶
Classes¶
BookingSchema
¶
Attributes:
-
model_config– -
date(date) – -
reservation_status(ReservationStatusEnum) – -
unattended(bool) – -
places(PlacesSchema) – -
link(str | None) –
Attributes¶
model_config
class-attribute
instance-attribute
¶
reservation_status
class-attribute
instance-attribute
¶
reservation_status: ReservationStatusEnum = unknown
HutBookingsSchema
¶
Attributes:
-
model_config– -
source_id(int) – -
start_date(date) – -
days(int) – -
link(str | None) – -
bookings(list[BookingSchema]) –
PlacesSchema
¶
Attributes:
-
model_config– -
free(int) – -
total(int) – -
occupancy_percent(float) – -
occupancy_steps(float) – -
occupancy_status(OccupancyStatusEnum) –
ReservationStatusEnum
¶
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¶
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.
SourceDataSchema
¶
SourceData schema
Methods:
Attributes:
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¶
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, ...)",
)
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, ...)",
)
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¶
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.",
)
AuthorSchema
¶
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) –
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) –
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.",
)