Skip to content

Commit 1a4867d

Browse files
committed
Merge pull request #61 from gtaylor/pycharm_refactor
Pycharm refactor
2 parents daa958b + 36f7b1a commit 1a4867d

28 files changed

+125
-124
lines changed

examples/address_validation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ class can handle up to 100 addresses for validation.
5050

5151
# If you'd like to see some documentation on the ship service WSDL, un-comment
5252
# this line. (Spammy).
53-
#print(avs_request.client)
53+
# print(avs_request.client)
5454

5555
# Un-comment this to see your complete, ready-to-send request as it stands
5656
# before it is actually sent. This is useful for seeing what values you can
5757
# change.
58-
#print(avs_request.AddressesToValidate)
59-
#print(avs_request.ClientDetail)
60-
#print(avs_request.TransactionDetail)
58+
# print(avs_request.AddressesToValidate)
59+
# print(avs_request.ClientDetail)
60+
# print(avs_request.TransactionDetail)
6161

6262
# Fires off the request, sets the 'response' attribute on the object.
6363
avs_request.send_request()
@@ -99,4 +99,3 @@ class can handle up to 100 addresses for validation.
9999
if cur_attribute.Name == "POBox":
100100
print("Is POBox: {}".format(cur_attribute.Value == 'true'))
101101
print("")
102-

examples/create_freight_shipment.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
# Set this to the INFO level to see the response from Fedex printed in stdout.
21-
#logging.basicConfig(filename="suds.log", level=logging.DEBUG)
21+
# logging.basicConfig(filename="suds.log", level=logging.DEBUG)
2222
logging.basicConfig(level=logging.INFO)
2323

2424
# NOTE: A VALID 'freight_account_number' REQUIRED IN YOUR 'CONFIB_OBJ' FOR THIS SERVICE TO WORK.
@@ -60,7 +60,7 @@
6060

6161
# This is needed to ensure an accurate rate quote with the response.
6262
shipment.RequestedShipment.Recipient.Address.Residential = False
63-
shipment.RequestedShipment.FreightShipmentDetail.TotalHandlingUnits = 1
63+
shipment.RequestedShipment.FreightShipmentDetail.TotalHandlingUnits = 1
6464
shipment.RequestedShipment.ShippingChargesPayment.Payor.ResponsibleParty.AccountNumber = \
6565
CONFIG_OBJ.freight_account_number
6666

@@ -124,22 +124,21 @@
124124
package1.HazardousMaterials = None
125125
package1.Pieces = 12
126126

127-
128127
shipment.RequestedShipment.FreightShipmentDetail.LineItems = package1
129128

130129
# If you'd like to see some documentation on the ship service WSDL, un-comment
131130
# this line. (Spammy).
132-
#print(shipment.client)
131+
# print(shipment.client)
133132

134133
# Un-comment this to see your complete, ready-to-send request as it stands
135134
# before it is actually sent. This is useful for seeing what values you can
136135
# change.
137-
#print(shipment.RequestedShipment)
136+
# print(shipment.RequestedShipment)
138137

139138
# If you want to make sure that all of your entered details are valid, you
140139
# can call this and parse it just like you would via send_request(). If
141140
# shipment.response.HighestSeverity == "SUCCESS", your shipment is valid.
142-
#shipment.send_validation_request()
141+
# shipment.send_validation_request()
143142

144143
# Fires off the request, sets the 'response' attribute on the object.
145144
shipment.send_request()
@@ -154,7 +153,7 @@
154153

155154
# Getting the tracking number from the new shipment.
156155
print("Tracking #: {}"
157-
"".format(shipment.response.CompletedShipmentDetail.MasterTrackingId.TrackingNumber))
156+
"".format(shipment.response.CompletedShipmentDetail.MasterTrackingId.TrackingNumber))
158157

159158
# Net shipping costs.
160159
amount = shipment.response.CompletedShipmentDetail.ShipmentRating.ShipmentRateDetails[0].TotalNetCharge.Amount
@@ -187,17 +186,17 @@
187186
"""
188187
# Pipe the binary directly to the label printer. Works under Linux
189188
# without requiring PySerial. This WILL NOT work on other platforms.
190-
#label_printer = open("/dev/ttyS0", "w")
191-
#label_printer.write(label_binary_data)
192-
#label_printer.close()
189+
# label_printer = open("/dev/ttyS0", "w")
190+
# label_printer.write(label_binary_data)
191+
# label_printer.close()
193192

194193
"""
195194
This is a potential cross-platform solution using pySerial. This has not been
196195
tested in a long time and may or may not work. For Windows, Mac, and other
197196
platforms, you may want to go this route.
198197
"""
199-
#import serial
200-
#label_printer = serial.Serial(0)
201-
#print("SELECTED SERIAL PORT: "+ label_printer.portstr)
202-
#label_printer.write(label_binary_data)
203-
#label_printer.close()
198+
# import serial
199+
# label_printer = serial.Serial(0)
200+
# print("SELECTED SERIAL PORT: "+ label_printer.portstr)
201+
# label_printer.write(label_binary_data)
202+
# label_printer.close()

examples/create_shipment.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
# Who pays for the shipment?
7474
# RECIPIENT, SENDER or THIRD_PARTY
75-
shipment.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
75+
shipment.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
7676

7777
# Specifies the label type to be returned.
7878
# LABEL_DATA_ONLY or COMMON2D
@@ -112,27 +112,27 @@
112112
package1.PhysicalPackaging = 'ENVELOPE'
113113
package1.Weight = package1_weight
114114
# Un-comment this to see the other variables you may set on a package.
115-
#print(package1)
115+
# print(package1)
116116

117117
# This adds the RequestedPackageLineItem WSDL object to the shipment. It
118118
# increments the package count and total weight of the shipment for you.
119119
shipment.add_package(package1)
120120

121121
# If you'd like to see some documentation on the ship service WSDL, un-comment
122122
# this line. (Spammy).
123-
#print(shipment.client)
123+
# print(shipment.client)
124124

125125
# Un-comment this to see your complete, ready-to-send request as it stands
126126
# before it is actually sent. This is useful for seeing what values you can
127127
# change.
128-
#print(shipment.RequestedShipment)
129-
#print(shipment.ClientDetail)
130-
#print(shipment.TransactionDetail)
128+
# print(shipment.RequestedShipment)
129+
# print(shipment.ClientDetail)
130+
# print(shipment.TransactionDetail)
131131

132132
# If you want to make sure that all of your entered details are valid, you
133133
# can call this and parse it just like you would via send_request(). If
134134
# shipment.response.HighestSeverity == "SUCCESS", your shipment is valid.
135-
#print(shipment.send_validation_request())
135+
# print(shipment.send_validation_request())
136136

137137
# Fires off the request, sets the 'response' attribute on the object.
138138
shipment.send_request()
@@ -183,18 +183,17 @@
183183
"""
184184
# Pipe the binary directly to the label printer. Works under Linux
185185
# without requiring PySerial. This WILL NOT work on other platforms.
186-
#label_printer = open("/dev/ttyS0", "w")
187-
#label_printer.write(label_binary_data)
188-
#label_printer.close()
186+
# label_printer = open("/dev/ttyS0", "w")
187+
# label_printer.write(label_binary_data)
188+
# label_printer.close()
189189

190190
"""
191191
This is a potential cross-platform solution using pySerial. This has not been
192192
tested in a long time and may or may not work. For Windows, Mac, and other
193193
platforms, you may want to go this route.
194194
"""
195-
#import serial
196-
#label_printer = serial.Serial(0)
197-
#print("SELECTED SERIAL PORT: "+ label_printer.portstr)
198-
#label_printer.write(label_binary_data)
199-
#label_printer.close()
200-
195+
# import serial
196+
# label_printer = serial.Serial(0)
197+
# print("SELECTED SERIAL PORT: "+ label_printer.portstr)
198+
# label_printer.write(label_binary_data)
199+
# label_printer.close()

examples/example_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
account_number='xxxxxxxxxxx',
1717
meter_number='xxxxxxxxxxx',
1818
freight_account_number='xxxxxxxxxxx',
19-
use_test_server=True)
19+
use_test_server=True)

examples/freight_rate_request.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@
5555
payment.Payor.ResponsibleParty = rate_request.RequestedShipment.Shipper
5656
rate_request.RequestedShipment.ShippingChargesPayment = payment
5757

58-
#include estimated duties and taxes in rate quote, can be ALL or NONE
58+
# include estimated duties and taxes in rate quote, can be ALL or NONE
5959
rate_request.RequestedShipment.EdtRequestType = 'NONE'
6060

6161
# note: in order for this to work in test, you may need to use the
6262
# specially provided LTL addresses emailed to you when signing up.
6363
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Contact.PersonName = 'Sender Name'
6464
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Contact.CompanyName = 'Some Company'
6565
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Contact.PhoneNumber = '9012638716'
66-
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Address.StreetLines = ['2000 Freight LTL Testing']
66+
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Address.StreetLines = [
67+
'2000 Freight LTL Testing']
6768
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Address.City = 'Harrison'
6869
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Address.StateOrProvinceCode = 'AR'
6970
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Address.PostalCode = '72601'
@@ -80,7 +81,7 @@
8081
rate_request.RequestedShipment.FreightShipmentDetail.Role = role.SHIPPER
8182

8283
# Designates the terms of the "collect" payment for a Freight
83-
#Shipment. Can be NON_RECOURSE_SHIPPER_SIGNED or STANDARD
84+
# Shipment. Can be NON_RECOURSE_SHIPPER_SIGNED or STANDARD
8485
rate_request.RequestedShipment.FreightShipmentDetail.CollectTermsType = 'STANDARD'
8586

8687
package1_weight = rate_request.create_wsdl_object_of_type('Weight')
@@ -99,12 +100,12 @@
99100

100101
# If you'd like to see some documentation on the ship service WSDL, un-comment
101102
# this line. (Spammy).
102-
#print(rate_request.client)
103+
# print(rate_request.client)
103104

104105
# Un-comment this to see your complete, ready-to-send request as it stands
105106
# before it is actually sent. This is useful for seeing what values you can
106107
# change.
107-
#print(rate_request.RequestedShipment)
108+
# print(rate_request.RequestedShipment)
108109

109110
# Fires off the request, sets the 'response' attribute on the object.
110111
rate_request.send_request()
@@ -128,4 +129,3 @@
128129
print("{}: Net FedEx Charge {} {}".format(service.ServiceType,
129130
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
130131
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))
131-

examples/postal_inquiry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
# If you'd like to see some documentation on the ship service WSDL, un-comment
1919
# this line. (Spammy).
20-
#print(inquiry.client)
20+
# print(inquiry.client)
2121

2222
# Un-comment this to see your complete, ready-to-send request as it stands
2323
# before it is actually sent. This is useful for seeing what values you can
2424
# change.
25-
#print(inquiry.CarrierCode)
26-
#print(inquiry.ClientDetail)
27-
#print(inquiry.TransactionDetail)
25+
# print(inquiry.CarrierCode)
26+
# print(inquiry.ClientDetail)
27+
# print(inquiry.TransactionDetail)
2828

2929
# Fires off the request, sets the 'response' attribute on the object.
3030
inquiry.send_request()

examples/rate_request.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
rate_request.RequestedShipment.Recipient.Address.PostalCode = '27577'
4848
rate_request.RequestedShipment.Recipient.Address.CountryCode = 'US'
4949
# This is needed to ensure an accurate rate quote with the response.
50-
#rate_request.RequestedShipment.Recipient.Address.Residential = True
51-
#include estimated duties and taxes in rate quote, can be ALL or NONE
50+
# rate_request.RequestedShipment.Recipient.Address.Residential = True
51+
# include estimated duties and taxes in rate quote, can be ALL or NONE
5252
rate_request.RequestedShipment.EdtRequestType = 'NONE'
5353

5454
# Who pays for the rate_request?
@@ -62,7 +62,7 @@
6262

6363
package1 = rate_request.create_wsdl_object_of_type('RequestedPackageLineItem')
6464
package1.Weight = package1_weight
65-
#can be other values this is probably the most common
65+
# can be other values this is probably the most common
6666
package1.PhysicalPackaging = 'BOX'
6767
# Required, but according to FedEx docs:
6868
# "Used only with PACKAGE_GROUPS, as a count of packages within a
@@ -74,28 +74,28 @@
7474
# The result will be found in RatedPackageDetail, with specified GroupNumber.
7575
package1.GroupPackageCount = 1
7676
# Un-comment this to see the other variables you may set on a package.
77-
#print(package1)
77+
# print(package1)
7878

7979
# This adds the RequestedPackageLineItem WSDL object to the rate_request. It
8080
# increments the package count and total weight of the rate_request for you.
8181
rate_request.add_package(package1)
8282

8383
# If you'd like to see some documentation on the ship service WSDL, un-comment
8484
# this line. (Spammy).
85-
#print(rate_request.client)
85+
# print(rate_request.client)
8686

8787
# Un-comment this to see your complete, ready-to-send request as it stands
8888
# before it is actually sent. This is useful for seeing what values you can
8989
# change.
90-
#print(rate_request.RequestedShipment)
90+
# print(rate_request.RequestedShipment)
9191

9292
# Fires off the request, sets the 'response' attribute on the object.
9393
rate_request.send_request()
9494

9595
# This will show the reply to your rate_request being sent. You can access the
9696
# attributes through the response attribute on the request object. This is
9797
# good to un-comment to see the variables returned by the FedEx reply.
98-
#print(rate_request.response)
98+
# print(rate_request.response)
9999

100100
# Here is the overall end result of the query.
101101
print("HighestSeverity:", rate_request.response.HighestSeverity)
@@ -111,4 +111,3 @@
111111
print("%s: Net FedEx Charge %s %s" % (service.ServiceType,
112112
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
113113
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))
114-

examples/service_availability_request.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
avc_request.Destination.CountryCode = 'US'
3030

3131
# Can be set to FEDEX_TUBE, YOUR_PACKAGING, FEDEX_BOX etc.. Defaults to YOUR_PACKAGING if not set.
32-
#avc_request.Packaging = 'FEDEX_ENVELOPE'
32+
# avc_request.Packaging = 'FEDEX_ENVELOPE'
3333

3434
# Can be set to the expected date. Defaults to today if not set.
35-
#avc_request.ShipDate = datetime.date.today().isoformat()
35+
# avc_request.ShipDate = datetime.date.today().isoformat()
3636

3737
# Can be set to PRIORITY_OVERNIGHT, FEDEX_2_DAY, STANDARD_OVERNIGHT etc.. Defaults to showing all options if not set.
38-
#avc_request.Service = 'FEDEX_2_DAY'
38+
# avc_request.Service = 'FEDEX_2_DAY'
3939

4040
# Fires off the request, sets the 'response' attribute on the object.
4141
avc_request.send_request()
@@ -45,12 +45,12 @@
4545

4646
# Un-comment this to see your complete, ready-to-send request as it stands
4747
# before it is actually sent. This is useful for seeing what values you can change.
48-
#print(avc_request.Origin)
49-
#print(avc_request.Destination)
50-
#print(avc_request.ShipDate)
51-
#print(avc_request.CarrierCode)
52-
#print(avc_request.Service)
53-
#print(avc_request.Packaging)
48+
# print(avc_request.Origin)
49+
# print(avc_request.Destination)
50+
# print(avc_request.ShipDate)
51+
# print(avc_request.CarrierCode)
52+
# print(avc_request.Service)
53+
# print(avc_request.Packaging)
5454

5555
# This will show the reply to your avc_request being sent. You can access the
5656
# attributes through the response attribute on the request object. This is

examples/track_shipment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030

3131
# If you'd like to see some documentation on the ship service WSDL, un-comment
3232
# this line. (Spammy).
33-
#print(track.client)
33+
# print(track.client)
3434

3535
# Un-comment this to see your complete, ready-to-send request as it stands
3636
# before it is actually sent. This is useful for seeing what values you can
3737
# change.
38-
#print(track.SelectionDetails)
39-
#print(track.ClientDetail)
40-
#print(track.TransactionDetail)
38+
# print(track.SelectionDetails)
39+
# print(track.ClientDetail)
40+
# print(track.TransactionDetail)
4141

4242

4343
# Fires off the request, sets the 'response' attribute on the object.
@@ -65,9 +65,9 @@
6565
for j in range(len(match.Events)):
6666
event_match = match.Events[j]
6767
event_details.append({'created': event_match.Timestamp, 'type': event_match.EventType,
68-
'description': event_match.EventDescription})
68+
'description': event_match.EventDescription})
6969

7070
if hasattr(event_match, 'StatusExceptionDescription'):
7171
event_details[j]['exception_description'] = event_match.StatusExceptionDescription
7272

73-
print("Event {}: {}".format(j+1, event_details[j]))
73+
print("Event {}: {}".format(j + 1, event_details[j]))

fedex/base_service.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
class GeneralSudsPlugin(MessagePlugin):
19-
2019
def __init__(self, **kwargs):
2120
self.kwargs = kwargs
2221

@@ -117,8 +116,8 @@ def __init__(self, config_obj, wsdl_name, *args, **kwargs):
117116
self.logger.info("Using production server.")
118117
self.wsdl_path = os.path.join(config_obj.wsdl_path, wsdl_name)
119118

120-
self.client = Client('file:///%s' % self.wsdl_path.lstrip('/'), plugins=[GeneralSudsPlugin()])
121-
#self.client.options.cache.clear() # Clear the cache, then re-init client when changing wsdl file.
119+
self.client = Client('file:///%s' % self.wsdl_path.lstrip('/'), plugins=[GeneralSudsPlugin()])
120+
# self.client.options.cache.clear() # Clear the cache, then re-init client when changing wsdl file.
122121

123122
self.VersionId = None
124123
"""@ivar: Holds details on the version numbers of the WSDL."""

0 commit comments

Comments
 (0)