Reading handshake into python works

This commit is contained in:
Jonas Linter
2025-09-25 09:47:38 +02:00
parent 9ea09ffa3f
commit 35da6d3c24
11 changed files with 44 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<OTA_ResRetrieveRS xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
<ReservationsList>
<HotelReservation CreateDateTime="2025-09-25T07:09:25.703515+00:00" ResStatus="Requested" RoomStayReservation="true">
<HotelReservation CreateDateTime="2025-09-25T07:41:25.075608+00:00" ResStatus="Requested" RoomStayReservation="true">
<UniqueID Type="14" ID="6b34fe24ac2ff811"/>
<RoomStays>
<RoomStay>

View File

@@ -1,7 +1,11 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "alpine-bits-python-server"
version = "0.1.0"
description = "Add your description here"
description = "Alpine Bits Python Server implementation"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
@@ -13,13 +17,15 @@ dependencies = [
"xsdata[cli,lxml,soap]>=25.7",
]
[project.scripts]
alpine-bits-server = "alpine_bits_python.main:main"
[tool.hatch.build.targets.wheel]
packages = ["src/alpine_bits_python_server"]
packages = ["src/alpine_bits_python"]
[tool.pytest.ini_options]
testpaths = ["tests"]
testpaths = ["test"]
pythonpath = ["src"]
[tool.ruff]
src = ["src", "tests"]
src = ["src", "test"]

View File

@@ -0,0 +1,5 @@
"""Entry point for alpine_bits_python package."""
from .main import main
if __name__ == "__main__":
main()

View File

@@ -11,7 +11,7 @@ import json
from typing import Dict, List, Optional, Any
from xml.etree import ElementTree as ET
from generated.alpinebits import OtaPingRq, OtaPingRs, WarningStatus
from .generated.alpinebits import OtaPingRq, OtaPingRs, WarningStatus
from xsdata_pydantic.bindings import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig

View File

@@ -1,4 +1,4 @@
from generated.alpinebits import (
from .alpinebits import (
BaseByGuestAmtType,
BookingRuleCodeContext,
CommentName1,

View File

@@ -1,12 +1,12 @@
from .alpinebits_guestrequests import ResGuest, RoomStay
import generated.alpinebits as ab
from .generated import alpinebits as ab
from io import BytesIO
import sys
from datetime import datetime, timezone
import re
from xsdata_pydantic.bindings import XmlSerializer
from simplified_access import (
from .simplified_access import (
CommentData,
CommentsData,
CommentListItemData,

View File

@@ -4,7 +4,7 @@ from dataclasses import dataclass
from enum import Enum
# Import the generated classes
from generated.alpinebits import OtaHotelResNotifRq, OtaResRetrieveRs, CommentName2
from .generated.alpinebits import OtaHotelResNotifRq, OtaResRetrieveRs, CommentName2
# Define type aliases for the two Customer types
NotifCustomer = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile.Customer

View File

@@ -0,0 +1 @@
"""Utility functions for alpine_bits_python."""

View File

@@ -0,0 +1,5 @@
"""Entry point for util package."""
from .handshake_util import main
if __name__ == "__main__":
main()

View File

@@ -1,4 +1,5 @@
from generated.alpinebits import OtaPingRq, OtaPingRs
from ..generated.alpinebits import OtaPingRq, OtaPingRs
from xsdata_pydantic.bindings import XmlParser
@@ -6,15 +7,26 @@ from generated.alpinebits import OtaPingRq, OtaPingRs
def main():
# test parsing a ping request sample
path = "../../AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml"
path = "AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml"
with open(
path, "r", encoding="utf-8") as f:
xml = f.read()
# Parse the XML into the request object
request = OtaPingRq.from_xml(xml)
print("Parsed OTA_PingRQ:", request)
# Test parsing back
parser = XmlParser()
parsed_result = parser.from_string(xml, OtaPingRq)
print(parsed_result.echo_data)
if __name__ == "__main__":

2
uv.lock generated
View File

@@ -5,7 +5,7 @@ requires-python = ">=3.13"
[[package]]
name = "alpine-bits-python-server"
version = "0.1.0"
source = { virtual = "." }
source = { editable = "." }
dependencies = [
{ name = "generateds" },
{ name = "lxml" },