Example #1
0
class Flight(xsd.ComplexType):
    tail_number = xsd.Attribute(xsd.String)
    type = xsd.Attribute(xsd.Integer, use=xsd.Use.OPTIONAL)
    takeoff_airport = xsd.Element(Airport)
    takeoff_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
    landing_airport = xsd.Element(Airport)
    landing_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
Example #2
0
class Airport(xsd.ComplexType):
    type = xsd.Element(xsd.String)
    code = xsd.Element(xsd.String)

    @classmethod
    def create(cls, type, code):
        airport = Airport()
        airport.type = type
        airport.code = code
        return airport
Example #3
0
class Status(xsd.ComplexType):
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    action = xsd.Element(xsd.String(enumeration=["INSERTED", "UPDATED", "EXISTS"]))
    id = xsd.Element(xsd.Long)

    @classmethod
    def create(cls, action, id):
        instance = cls()
        instance.action = action
        instance.id = id
        return instance
Example #4
0
class Airport(xsd.ComplexType):
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    code_type = xsd.Element(xsd.String(enumeration=["ICAO", "IATA", "FAA"]))
    code = xsd.Element(xsd.String)

    @classmethod
    def create(cls, code_type, code):
        instance = cls()
        instance.code_type = code_type
        instance.code = code
        return instance
Example #5
0
class Weight(xsd.ComplexType):
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    value = xsd.Element(xsd.Integer)
    unit = xsd.Element(xsd.String(enumeration=["kg", "lb"]))

    @classmethod
    def create(cls, value, unit):
        instance = cls()
        instance.value = value
        instance.unit = unit
        return instance
Example #6
0
    def test_boolean_correctly_renders_false_value_in_xml(self):
        # regression test for http://code.google.com/p/soapbox/issues/detail?id=3
        # before xsd.Boolean would render [true, false] Python values *both*
        # to as 'true' in the xml.
        parent = etree.Element('parent')
        xsd.Element(xsd.Boolean).render(parent, 'b', True)
        self.assertEqual(b'<parent><b>true</b></parent>',
                         etree.tostring(parent))

        parent = etree.Element('parent')
        xsd.Element(xsd.Boolean).render(parent, 'b', False)
        self.assertEqual(b'<parent><b>false</b></parent>',
                         etree.tostring(parent))
class PredictorType(xsd.ComplexType):
    '''
    '''
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    name = xsd.Attribute(xsd.String, use=xsd.Use.REQUIRED)
    file = xsd.Element(xsd.String)
    positions = xsd.Element('PositionsType')

    @classmethod
    def create(cls, file, positions):
        instance = cls()
        instance.file = file
        instance.positions = positions
        return instance
class ResultsResponseType(xsd.ComplexType):
    '''
    '''
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    version = xsd.Element(xsd.String)
    result_url = xsd.Element(xsd.String)
    predictors = xsd.Element('PredictorsType')

    @classmethod
    def create(cls, version, result_url, predictors):
        instance = cls()
        instance.version = version
        instance.result_url = result_url
        instance.predictors = predictors
        return instance
Example #9
0
class StoragelogisticsRequest(xsd.ComplexType):
    '''
    '''
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    storagemediumid = xsd.Element(xsd.String)
    eventtype = xsd.Element(xsd.Integer)
    storagemediumlocation = xsd.Element(xsd.String)
    storagemediumdestination = xsd.Element(xsd.String)
    useridentifiervalue = xsd.Element(xsd.String)
    userpassword = xsd.Element(xsd.String)
    eventdatetime = xsd.Element(xsd.String)

    @classmethod
    def create(cls, storagemediumid, eventtype, storagemediumlocation,
               storagemediumdestination, useridentifiervalue, userpassword,
               eventdatetime):
        instance = cls()
        instance.storagemediumid = storagemediumid
        instance.eventtype = eventtype
        instance.storagemediumlocation = storagemediumlocation
        instance.storagemediumdestination = storagemediumdestination
        instance.useridentifiervalue = useridentifiervalue
        instance.userpassword = userpassword
        instance.eventdatetime = eventdatetime
        return instance
Example #10
0
 def test_wrong_type(self):
     mixed = xsd.Element(xsd.DateTime)
     xmlelement = etree.Element("flight")
     try:
         mixed.render(xmlelement, "takeoff_datetime", 1)
     except Exception:
         pass
     else:
         self.assertTrue(False)
Example #11
0
    def test_string_element(self):
        tail_number = xsd.Element(xsd.String())
        xmlelement = etree.Element("aircraft")
        tail_number.render(xmlelement, "tail_number", "LN-KKU")
        self.assertEqual(
            b"""<aircraft>
  <tail_number>LN-KKU</tail_number>
</aircraft>
""", etree.tostring(xmlelement, pretty_print=True))
Example #12
0
    def test_element_true(self):
        mixed = xsd.Element(xsd.Boolean, )
        xmlelement = etree.Element("complexType")
        mixed.render(xmlelement, "mixed", True)
        expected_xml = b"""<complexType>
  <mixed>true</mixed>
</complexType>
"""
        xml = etree.tostring(xmlelement, pretty_print=True)
        self.assertEqual(expected_xml, xml)
class EchoType(xsd.ComplexType):
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    value = xsd.Element(xsd.String, nillable=False)

    @classmethod
    def create(cls, value):
        instance = cls()
        instance.value = value
        return instance
Example #14
0
    def test_rendering(self):
        dt = datetime(2001, 10, 26, 21, 32, 52)
        mixed = xsd.Element(xsd.DateTime)
        xmlelement = etree.Element("flight")
        mixed.render(xmlelement, "takeoff_datetime", dt)
        expected_xml = b"""<flight>
  <takeoff_datetime>2001-10-26T21:32:52</takeoff_datetime>
</flight>
"""
        xml = etree.tostring(xmlelement, pretty_print=True)
        self.assertEqual(expected_xml, xml)
Example #15
0
class StoragelogisticsResponse(xsd.ComplexType):
    '''
    '''
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    returncode = xsd.Element(xsd.Integer, nillable=True)

    @classmethod
    def create(cls, returncode):
        instance = cls()
        instance.returncode = returncode
        return instance
class ResultsResponseTypeWrapper(xsd.ComplexType):
    '''
    '''
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    resultsResponse = xsd.Element(xsd.String)

    @classmethod
    def create(cls, resultsResponse):
        instance = cls()
        instance.resultsResponse = resultsResponse
        return instance
Example #17
0
class Flight(xsd.ComplexType):
    tail_number = xsd.Element(xsd.String)
    takeoff_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
    takeoff_airport = xsd.Element(Airport)
    landing_airport = xsd.Element(Airport)
    takeoff_pilot = xsd.Element(Pilot, minOccurs=0)
    landing_pilot = xsd.Element(Pilot, minOccurs=0)
    passengers = xsd.ListElement(xsd.String, "passenger", maxOccurs=10, minOccurs=0)
def _echo_service(handler=None, input_header=None, output_header=None):
    if handler is None:
        handler, handler_state = _echo_handler()

    EchoSchema = xsd.Schema(
        'http://soap.example/echo/types',
        elementFormDefault=xsd.ElementFormDefault.UNQUALIFIED,
        simpleTypes=(InputVersion, OutputVersion),
        complexTypes=(EchoType, InputHeader, OutputHeader),
        elements={
            'echoRequest': xsd.Element(EchoType),
            'echoResponse': xsd.Element(EchoType),
            'InputVersion': xsd.Element(InputVersion),
            'OutputVersion': xsd.Element(OutputVersion),
        },
    )
    echo_method = xsd.Method(
        function=handler,
        soapAction='echo',
        input='echoRequest',
        inputPartName='input_',
        input_header=input_header,
        output='echoResponse',
        output_header=output_header,
        outputPartName='result',
        operationName='echoOperation',
    )
    return soap.Service(
        name='TestService',
        targetNamespace='http://soap.example/echo',
        location='http://soap.example/ws',
        schema=EchoSchema,
        version=soap.SOAPVersion.SOAP11,
        methods={
            'echo': echo_method,
        },
    )
Example #19
0
class Airport(xsd.ComplexType):
    type = xsd.Element(xsd.String)
    code = xsd.Element(xsd.String)
                                maxOccurs=UNBOUNDED)


Schema_4c1ac = xsd.Schema(
    imports=[],
    targetNamespace='shmr',
    elementFormDefault='unqualified',
    simpleTypes=[],
    attributeGroups=[],
    groups=[],
    complexTypes=[
        FastaType, ResultsResponseTypeWrapper, ResultsResponseType,
        PredictorsType, PredictorType, PositionsType, PosType
    ],
    elements={
        'doSHMR': xsd.Element('FastaType'),
        'doSHMRResponse': xsd.Element('ResultsResponseTypeWrapper')
    },
)

################################################################################
# Methods

doSHMR_method = xsd.Method(
    soapAction='shmr#doSHMR',
    input='doSHMR',
    inputPartName='parameters',
    output='doSHMRResponse',
    outputPartName='parameters',
    operationName='doSHMR',
)
Example #21
0
 class TestType(xsd.ComplexType):
     foo = xsd.Element(xsd.String, tagname='bar')
Example #22
0
    def create(cls, action, id):
        instance = cls()
        instance.action = action
        instance.id = id
        return instance


Schema_c8319 = xsd.Schema(
    imports=[],
    targetNamespace='http://flightdataservices.com/ops.xsd',
    elementFormDefault='unqualified',
    simpleTypes=[Pilot],
    attributeGroups=[],
    groups=[],
    complexTypes=[Airport, Weight, Ops, Status],
    elements={'ops': xsd.Element('Ops'), 'status': xsd.Element('Status')},
)


################################################################################
# Operations


def PutOps(request, ops):
    '''
    '''
    # TODO: Put your implementation here.
    return status


################################################################################
Example #23
0
class GetStockPrice(xsd.ComplexType):
    company = xsd.Element(xsd.String, minOccurs=1)
    datetime = xsd.Element(xsd.DateTime)
Example #24
0
        return instance


Schema_55b49 = xsd.Schema(
    imports=[],
    targetNamespace='http://ESSArch_Instance.ra.se/StorageLogisticsService',
    elementFormDefault='unqualified',
    #elementFormDefault='qualified',
    #elementFormDefault=xsd.ElementFormDefault.UNQUALIFIED,
    #elementFormDefault=xsd.ElementFormDefault.QUALIFIED,
    simpleTypes=[],
    attributeGroups=[],
    groups=[],
    complexTypes=[],
    elements={
        'storagelogisticsResponse': xsd.Element(StoragelogisticsResponse()),
        'storagelogisticsRequest': xsd.Element(StoragelogisticsRequest())
    },
)

################################################################################
# Operations


#@permission_required('StorageLogistics_ws.StorageLogistics')
def storagelogistics(request, storagelogisticsRequest):
    logger.debug(
        'Request parameters before replace: storagemediumlocation=%s storagemediumdestination=%s useridentifiervalue=%s storagemediumid=%s eventtype=%s userpassword=%s eventdatetime=%s',
        storagelogisticsRequest.storagemediumlocation,
        storagelogisticsRequest.storagemediumdestination,
        storagelogisticsRequest.useridentifiervalue,
Example #25
0
class Ops(xsd.ComplexType):
    INHERITANCE = None
    INDICATOR = xsd.Sequence
    aircraft = xsd.Element(xsd.String)
    flight_number = xsd.Element(xsd.String)
    type = xsd.Element(xsd.String(enumeration=["COMMERCIAL", "INCOMPLETE", "ENGINE_RUN_UP", "TEST", "TRAINING", "FERRY", "POSITIONING", "LINE_TRAINING"]))
    takeoff_airport = xsd.Element("Airport")
    takeoff_gate_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
    takeoff_datetime = xsd.Element(xsd.DateTime)
    takeoff_fuel = xsd.Element("Weight", minOccurs=0)
    takeoff_gross_weight = xsd.Element("Weight", minOccurs=0)
    takeoff_pilot = xsd.Element("Pilot", minOccurs=0)
    landing_airport = xsd.Element("Airport")
    landing_gate_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
    landing_datetime = xsd.Element(xsd.DateTime)
    landing_fuel = xsd.Element("Weight", minOccurs=0)
    landing_pilot = xsd.Element("Pilot", minOccurs=0)
    destination_airport = xsd.Element("Airport", minOccurs=0)
    captain_code = xsd.Element(xsd.String, minOccurs=0)
    first_officer_code = xsd.Element(xsd.String, minOccurs=0)
    V2 = xsd.Element(xsd.Integer, minOccurs=0)
    Vref = xsd.Element(xsd.Integer, minOccurs=0)
    Vapp = xsd.Element(xsd.Integer, minOccurs=0)

    @classmethod
    def create(cls, aircraft, flight_number, type, takeoff_airport, takeoff_datetime, landing_airport, landing_datetime):
        instance = cls()
        instance.aircraft = aircraft
        instance.flight_number = flight_number
        instance.type = type
        instance.takeoff_airport = takeoff_airport
        instance.takeoff_datetime = takeoff_datetime
        instance.landing_airport = landing_airport
        instance.landing_datetime = landing_datetime
        return instance
Example #26
0
class StockPrice(xsd.ComplexType):
    nillable = xsd.Element(xsd.Int, nillable=True)
    prices = xsd.ListElement(xsd.Decimal(fractionDigits=2), tagname="price", minOccurs=0, maxOccurs=xsd.UNBOUNDED, nillable=True)
Example #27
0
 class Test(xsd.ComplexType):
     value = xsd.Element(xsd.String(pattern=r"^a*$"))
Example #28
0
    @classmethod
    def create(cls, action, id):
        instance = cls()
        instance.action = action
        instance.id = id
        return instance


Schema = xsd.Schema(targetNamespace="http://flightdataservices.com/ops.xsd",
                    elementFormDefault="unqualified",
                    simpleTypes=[Pilot],
                    attributeGroups=[],
                    groups=[],
                    complexTypes=[Airport, Weight, Ops, Status],
                    elements={
                        "ops": xsd.Element("Ops"),
                        "status": xsd.Element("Status")
                    })

PutOps_method = xsd.Method(
    soapAction="http://polaris.flightdataservices.com/ws/ops/PutOps",
    input="ops",  # Pointer to Schema.elements
    inputPartName="body",
    output="status",  # Pointer to Schema.elements
    outputPartName="body",
    operationName="PutOps")

PutOpsPort_SERVICE = soap.Service(
    name="PutOpsPort",
    targetNamespace="http://flightdataservices.com/ops.wsdl",
    location="http://127.0.0.1:8088/mockPutOpsBinding",
Example #29
0
class GetStockPrice(xsd.ComplexType):
    company = xsd.Element(xsd.String, minOccurs=1)
    datetime = xsd.Element(xsd.DateTime)


class StockPrice(xsd.ComplexType):
    nillable = xsd.Element(xsd.Int, nillable=True)
    prices = xsd.ListElement(xsd.Decimal(fractionDigits=2), tagname="price", minOccurs=0, maxOccurs=xsd.UNBOUNDED, nillable=True)


Schema = xsd.Schema(
      # Should be unique URL, can be any string.
      targetNamespace="http://code.google.com/p/soapbox/stock.xsd",
      # Register all complex types to schema.
      complexTypes=[GetStockPrice, StockPrice],
      elements={"getStockPrice": xsd.Element("GetStockPrice"),
                  "stockPrice": xsd.Element("StockPrice")}
)


def get_stock_price(request, gsp):
    print gsp.company, gsp.datetime
    sp = StockPrice(nillable=xsd.NIL)
    sp.prices.append(13.29)
    sp.prices.append(4.56)
    sp.prices.append(xsd.NIL)
    return sp

get_stock_price_method = xsd.Method(
    function=get_stock_price,
    soapAction="http://code.google.com/p/soapbox/stock/get_stock_price",
Example #30
0
 class B1(xsd.ComplexType):
     a = xsd.Element("soapbox.xsd.String")
     b = xsd.Element("soapbox.xsd.Integer")