Permalink
Browse files

tree-wide: ongoing clean up for flake8.

  • Loading branch information...
pope1ni committed May 8, 2017
1 parent 7e41de1 commit b20b34fe901054586c901b6e13b244cf487dcbf4
View
@@ -1,15 +1,14 @@
#This was was generated by wsdl2py, try to not edit.
from soapfish import soap, xsd
class Pilot(xsd.String):
enumeration = ["CAPTAIN", "FIRST_OFFICER"]
enumeration = ['CAPTAIN', 'FIRST_OFFICER']
class Airport(xsd.ComplexType):
INHERITANCE = None
INDICATOR = xsd.Sequence
code_type = xsd.Element(xsd.String(enumeration=["ICAO", "IATA", "FAA"]))
code_type = xsd.Element(xsd.String(enumeration=['ICAO', 'IATA', 'FAA']))
code = xsd.Element(xsd.String)
@classmethod
@@ -24,7 +23,7 @@ class Weight(xsd.ComplexType):
INHERITANCE = None
INDICATOR = xsd.Sequence
value = xsd.Element(xsd.Integer)
unit = xsd.Element(xsd.String(enumeration=["kg", "lb"]))
unit = xsd.Element(xsd.String(enumeration=['kg', 'lb']))
@classmethod
def create(cls, value, unit):
@@ -39,19 +38,19 @@ class Ops(xsd.ComplexType):
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")
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")
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)
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)
@@ -74,7 +73,7 @@ def create(cls, aircraft, flight_number, type, takeoff_airport, takeoff_datetime
class Status(xsd.ComplexType):
INHERITANCE = None
INDICATOR = xsd.Sequence
action = xsd.Element(xsd.String(enumeration=["INSERTED", "UPDATED", "EXISTS"]))
action = xsd.Element(xsd.String(enumeration=['INSERTED', 'UPDATED', 'EXISTS']))
id = xsd.Element(xsd.Long)
@classmethod
@@ -86,28 +85,28 @@ def create(cls, action, id):
Schema = xsd.Schema(
targetNamespace="http://flightdataservices.com/ops.xsd",
elementFormDefault="unqualified",
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")})
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")
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",
name='PutOpsPort',
targetNamespace='http://flightdataservices.com/ops.wsdl',
location='http://127.0.0.1:8088/mockPutOpsBinding',
schema=Schema,
version=soap.SOAPVersion.SOAP11,
methods=[PutOps_method])
@@ -116,20 +115,20 @@ def create(cls, action, id):
class PutOpsPortServiceStub(soap.Stub):
SERVICE = PutOpsPort_SERVICE
def PutOps(self, ops):
return self.call("PutOps", ops)
def PutOps(self, ops): # noqa
return self.call('PutOps', ops)
if __name__ == "__main__":
if __name__ == '__main__':
from datetime import datetime
stub = PutOpsPortServiceStub()
ops = Ops()
ops.aircraft = "LN-KKU"
ops.flight_number = "1234"
ops.type = "COMMERCIAL"
ops.takeoff_airport = Airport.create(code_type="IATA", code="WAW")
ops.aircraft = 'LN-KKU'
ops.flight_number = '1234'
ops.type = 'COMMERCIAL'
ops.takeoff_airport = Airport.create(code_type='IATA', code='WAW')
ops.takeoff_datetime = datetime.now()
ops.landing_airport = Airport.create(code_type="ICAO", code="EGLL")
ops.landing_airport = Airport.create(code_type='ICAO', code='EGLL')
ops.landing_datetime = datetime.now()
status = stub.PutOps(ops)
print status.action, status.id
View
@@ -8,16 +8,15 @@ class GetStockPrice(xsd.ComplexType):
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)
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/soapfish/stock.xsd",
# Register all complex types to schema.
complexTypes=[GetStockPrice, StockPrice],
elements={"getStockPrice": xsd.Element(GetStockPrice),
"stockPrice": xsd.Element(StockPrice)}
# Should be unique URL, can be any string.
targetNamespace='http://code.google.com/p/soapfish/stock.xsd',
# Register all complex types to schema.
complexTypes=[GetStockPrice, StockPrice],
elements={'getStockPrice': xsd.Element(GetStockPrice), 'stockPrice': xsd.Element(StockPrice)}
)
@@ -31,49 +30,44 @@ def get_stock_price(request, gsp):
get_stock_price_method = xsd.Method(
function=get_stock_price,
soapAction="http://code.google.com/p/soapfish/stock/get_stock_price",
input="getStockPrice",
output="stockPrice",
operationName="GetStockPrice")
soapAction='http://code.google.com/p/soapfish/stock/get_stock_price',
input='getStockPrice',
output='stockPrice',
operationName='GetStockPrice')
SERVICE11 = soap.Service(
name="StockService",
targetNamespace="http://code.google.com/p/soapfish/stock.wsdl", # WSDL targetNamespce
name='StockService',
targetNamespace='http://code.google.com/p/soapfish/stock.wsdl', # WSDL targetNamespce
version=soap.SOAPVersion.SOAP11,
# The url were request should be send.
location="http://127.0.0.1:8000/stock/soap11",
location='http://127.0.0.1:8000/stock/soap11',
schema=Schema,
methods=[get_stock_price_method])
SERVICE12 = soap.Service(
# WSDL targetNamespce
name="StockService",
targetNamespace="http://code.google.com/p/soapfish/stock.wsdl",
name='StockService',
targetNamespace='http://code.google.com/p/soapfish/stock.wsdl',
version=soap.SOAPVersion.SOAP12,
# The url where request should be sent.
location="http://127.0.0.1:8000/stock/soap12",
location='http://127.0.0.1:8000/stock/soap12',
schema=Schema,
methods=[get_stock_price_method])
#from django.views.decorators.csrf import csrf_exempt
#dispatch11 = csrf_exempt(soap.get_django_dispatch(SERVICE11))
#dispatch12 = csrf_exempt(soap.get_django_dispatch(SERVICE12))
#-------------------------------------------------------------------------------
#This was was generated by wsdl2py, try to not edit.
# ------------------------------------------------------------------------------
class Pilot(xsd.String):
enumeration = ["CAPTAIN", "FIRST_OFFICER"]
enumeration = ['CAPTAIN', 'FIRST_OFFICER']
class Airport(xsd.ComplexType):
INHERITANCE = None
INDICATOR = xsd.Sequence
code_type = xsd.Element(xsd.String(enumeration=["ICAO", "IATA", "FAA"]))
code_type = xsd.Element(xsd.String(enumeration=['ICAO', 'IATA', 'FAA']))
code = xsd.Element(xsd.String)
@classmethod
@@ -88,7 +82,7 @@ class Weight(xsd.ComplexType):
INHERITANCE = None
INDICATOR = xsd.Sequence
value = xsd.Element(xsd.Integer)
unit = xsd.Element(xsd.String(enumeration=["kg", "lb"]))
unit = xsd.Element(xsd.String(enumeration=['kg', 'lb']))
@classmethod
def create(cls, value, unit):
@@ -103,7 +97,7 @@ class Ops(xsd.ComplexType):
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"]))
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)
@@ -138,7 +132,7 @@ def create(cls, aircraft, flight_number, type, takeoff_airport, takeoff_datetime
class Status(xsd.ComplexType):
INHERITANCE = None
INDICATOR = xsd.Sequence
action = xsd.Element(xsd.String(enumeration=["INSERTED", "UPDATED", "EXISTS"]))
action = xsd.Element(xsd.String(enumeration=['INSERTED', 'UPDATED', 'EXISTS']))
id = xsd.Element(xsd.Long)
@classmethod
@@ -150,41 +144,30 @@ def create(cls, action, id):
Schema = xsd.Schema(
targetNamespace="http://flightdataservices.com/ops.xsd",
elementFormDefault="unqualified",
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)})
elements={'ops': xsd.Element(Ops), 'status': xsd.Element(Status)})
def PutOps(request, ops):
# Put your implementation here.
def PutOps(request, ops): # noqa
print ops.aircraft, ops.takeoff_datetime
return Status(id=100, action="INSERTED")
return Status(id=100, action='INSERTED')
PutOps_method = xsd.Method(
function=PutOps,
soapAction="http://polaris.flightdataservices.com/ws/ops/PutOps",
input="ops", # Pointer to Schema.elements
output="status", # Pointer to Schema.elements
operationName="PutOps")
soapAction='http://polaris.flightdataservices.com/ws/ops/PutOps',
input='ops', # Pointer to Schema.elements
output='status', # Pointer to Schema.elements
operationName='PutOps')
SERVICE = soap.Service(
targetNamespace="http://flightdataservices.com/ops.wsdl",
location="http://polaris.flightdataservices.com/ws/ops",
targetNamespace='http://flightdataservices.com/ops.wsdl',
location='http://polaris.flightdataservices.com/ws/ops',
schema=Schema,
methods=[PutOps_method])
#Uncomment this lines to turn on dispatching.
#from django.views.decorators.csrf import csrf_exempt
#ops_dispatch = csrf_exempt(soap.get_django_dispatch(SERVICE))
#Put this lines in your urls.py:
#urlpatterns += patterns('',
# (r"^ws/ops$", "<fill the module path>.dispatch")
#)
View
@@ -12,7 +12,5 @@
sys.exit(1)
if __name__ == "__main__":
if __name__ == '__main__':
execute_manager(settings)
@@ -79,7 +79,7 @@
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
@@ -89,7 +89,7 @@
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
View
@@ -1,11 +1,8 @@
from django.conf.urls.defaults import patterns, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
url(r'^stock/soap11$', "stock.web.views.dispatch11"),
url(r'^stock/soap12$', "stock.web.views.dispatch12"),
url(r'^ws/ops$', "stock.web.views.ops_dispatch"),
urlpatterns = patterns(
'',
url(r'^stock/soap11$', 'stock.web.views.dispatch11'),
url(r'^stock/soap12$', 'stock.web.views.dispatch12'),
url(r'^ws/ops$', 'stock.web.views.ops_dispatch'),
)
@@ -1,3 +0,0 @@
from django.db import models
# Create your models here.
@@ -1,4 +1,4 @@
#Example 3. Nested ComplexTypes with attributes.
# Example 3. Nested ComplexTypes with attributes.
from __future__ import print_function
@@ -21,12 +21,11 @@ class Flight(xsd.ComplexType):
landing_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
flight = Flight(tail_number="G-DEMO") # Constructor handles field inititailization.
flight.takeoff_airport = Airport(type="IATA", code="WAW")
flight.landing_airport = Airport(type="ICAO", code="EGLL")
flight = Flight(tail_number='G-DEMO') # Constructor handles field inititailization.
flight.takeoff_airport = Airport(type='IATA', code='WAW')
flight.landing_airport = Airport(type='ICAO', code='EGLL')
print(flight.xml("flight"))
#datetime field types will accept, datetime object or string,
#that parses correctly to such object.
print(flight.xml('flight'))
# datetime field types will accept, datetime object or string, that parses correctly to such object.
flight.takeoff_datetime = datetime.now()
print(flight.xml("flight"))
print(flight.xml('flight'))
View
@@ -1,4 +1,4 @@
#Example 2. Parsing XML to object.
# Example 2. Parsing XML to object.
from __future__ import print_function
@@ -10,12 +10,12 @@ class Airport(xsd.ComplexType):
code = xsd.Element(xsd.String)
XML = """<takeoff_airport>
XML = '''<takeoff_airport>
<type>IATA</type>
<code>WAW</code>
</takeoff_airport>"""
</takeoff_airport>'''
airport = Airport.parsexml(XML)
print("Type:", airport.type)
print("Code:", airport.code)
print('Type:', airport.type)
print('Code:', airport.code)
Oops, something went wrong.

0 comments on commit b20b34f

Please sign in to comment.