Skip to content

Commit a6b7c5b

Browse files
committed
pep-8 pycharm pass, force deprecation for movement service
* pep-8 pass on the entire package * force deprecation warning for python 2.7 * rename package movement to deprecated status * promote country service for postal validation
1 parent 504663f commit a6b7c5b

16 files changed

+168
-167
lines changed

examples/country_postal_inquiry.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

examples/postal_inquiry.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,56 @@
11
#!/usr/bin/env python
22
"""
3-
PostalCodeInquiryRequest classes are used to validate and receive additional
3+
ValidatePostalRequest classes are used to validate and receive additional
44
information about postal codes.
55
"""
66
import logging
7-
import sys
8-
97
from example_config import CONFIG_OBJ
10-
from fedex.services.package_movement import PostalCodeInquiryRequest
11-
from fedex.tools.conversion import sobject_to_dict
8+
from fedex.services.country_service import FedexValidatePostalRequest
129

13-
# Un-comment to see the response from Fedex printed in stdout.
14-
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
10+
# Set this to the INFO level to see the response from Fedex printed in stdout.
11+
logging.basicConfig(level=logging.INFO)
1512

1613
# We're using the FedexConfig object from example_config.py in this dir.
17-
inquiry = PostalCodeInquiryRequest(CONFIG_OBJ)
18-
inquiry.PostalCode = '29631'
19-
inquiry.CountryCode = 'US'
20-
21-
# If you'd like to see some documentation on the ship service WSDL, un-comment
14+
customer_transaction_id = "*** ValidatePostal Request v4 using Python ***" # Optional transaction_id
15+
inquiry = FedexValidatePostalRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id)
16+
inquiry.Address.PostalCode = '29631'
17+
inquiry.Address.CountryCode = 'US'
18+
inquiry.Address.StreetLines = ['104 Knox Road']
19+
inquiry.Address.City = 'Clemson'
20+
inquiry.Address.StateOrProvinceCode = 'SC'
21+
22+
# If you'd like to see some documentation on the country service WSDL, un-comment
2223
# this line. (Spammy).
2324
# print(inquiry.client)
2425

2526
# Un-comment this to see your complete, ready-to-send request as it stands
2627
# before it is actually sent. This is useful for seeing what values you can
2728
# change.
2829
# print(inquiry.CarrierCode)
29-
# print(inquiry.ClientDetail)
30-
# print(inquiry.TransactionDetail)
30+
# print(inquiry.Address)
31+
# print(inquiry.ShipDateTime)
32+
# print(inquiry.CheckForMismatch)
33+
# print(inquiry.RoutingCode)
3134

3235
# Fires off the request, sets the 'response' attribute on the object.
3336
inquiry.send_request()
3437

3538
# See the response printed out.
36-
# print(inquiry.response)
37-
38-
# This will convert the response to a python dict object. To
39-
# make it easier to work with.
40-
# from fedex.tools.conversion import basic_sobject_to_dict
41-
# print(basic_sobject_to_dict(inquiry.response))
42-
43-
# This will dump the response data dict to json.
44-
# from fedex.tools.conversion import sobject_to_json
45-
# print(sobject_to_json(inquiry.response))
39+
print(inquiry.response)
4640

4741
# Here is the overall end result of the query.
4842
print("HighestSeverity: {}".format(inquiry.response.HighestSeverity))
49-
print("ExpressFreightContractorDeliveryArea: {}".format(sobject_to_dict(inquiry.response.ExpressDescription)))
50-
print("ExpressDescription: {}".format(sobject_to_dict(inquiry.response.ExpressFreightDescription)))
43+
print("")
44+
45+
print("State/Province: {}".format(inquiry.response.PostalDetail.StateOrProvinceCode))
46+
print("City First Initial: {}".format(inquiry.response.PostalDetail.CityFirstInitials))
47+
print("Clean Postal Code: {}".format(inquiry.response.PostalDetail.CleanedPostalCode))
48+
49+
for loc_description in inquiry.response.PostalDetail.LocationDescriptions:
50+
print("Location ID: {}".format(loc_description.LocationId))
51+
print("Location No.: {}".format(loc_description.LocationNumber))
52+
print("Country Code: {}".format(loc_description.CountryCode))
53+
print("Postal Code: {}".format(loc_description.PostalCode))
54+
print("Service Area: {}".format(loc_description.ServiceArea))
55+
print("Airport ID: {}".format(loc_description.AirportId))
56+
print("FedEx Europe First Origin: {}".format(loc_description.FedExEuropeFirstOrigin))
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
"""
3+
PostalCodeInquiryRequest classes are used to validate and receive additional
4+
information about postal codes.
5+
"""
6+
import logging
7+
import sys
8+
import warnings
9+
from example_config import CONFIG_OBJ
10+
from fedex.services.package_movement import PostalCodeInquiryRequest
11+
from fedex.tools.conversion import sobject_to_dict
12+
13+
# Un-comment to see the response from Fedex printed in stdout.
14+
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
15+
16+
warnings.simplefilter('always', DeprecationWarning) # Show deprecation on this module in py2.7.
17+
18+
# We're using the FedexConfig object from example_config.py in this dir.
19+
inquiry = PostalCodeInquiryRequest(CONFIG_OBJ)
20+
inquiry.PostalCode = '29631'
21+
inquiry.CountryCode = 'US'
22+
23+
# If you'd like to see some documentation on the ship service WSDL, un-comment
24+
# this line. (Spammy).
25+
# print(inquiry.client)
26+
27+
# Un-comment this to see your complete, ready-to-send request as it stands
28+
# before it is actually sent. This is useful for seeing what values you can
29+
# change.
30+
# print(inquiry.CarrierCode)
31+
# print(inquiry.ClientDetail)
32+
# print(inquiry.TransactionDetail)
33+
34+
# Fires off the request, sets the 'response' attribute on the object.
35+
inquiry.send_request()
36+
37+
# See the response printed out.
38+
# print(inquiry.response)
39+
40+
# This will convert the response to a python dict object. To
41+
# make it easier to work with.
42+
# from fedex.tools.conversion import basic_sobject_to_dict
43+
# print(basic_sobject_to_dict(inquiry.response))
44+
45+
# This will dump the response data dict to json.
46+
# from fedex.tools.conversion import sobject_to_json
47+
# print(sobject_to_json(inquiry.response))
48+
49+
# Here is the overall end result of the query.
50+
print("HighestSeverity: {}".format(inquiry.response.HighestSeverity))
51+
print("ExpressFreightContractorDeliveryArea: {}".format(sobject_to_dict(inquiry.response.ExpressDescription)))
52+
print("ExpressDescription: {}".format(sobject_to_dict(inquiry.response.ExpressFreightDescription)))

examples/rate_request.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@
123123
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
124124
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))
125125

126-
# Not sure if 'NOTE' checking should be put in base class.
127-
# For now can check notifications manually.
128-
# if notification.Severity == 'NOTE':
129-
# self.logger.warning(FedexFailure(notification.Code,
130-
# notification.Message))
126+
# Check for warnings, this is also logged by the base class.
131127
if rate_request.response.HighestSeverity == 'NOTE':
132128
for notification in rate_request.response.Notifications:
133129
if notification.Severity == 'NOTE':

examples/track_shipment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
print("Status Description: {}".format(match.StatusDetail.Description))
7171
if hasattr(match, 'StatusDetail.AncillaryDetails'):
7272
print("Status AncillaryDetails Reason: {}".format(match.StatusDetail.AncillaryDetails[-1].Reason))
73-
print("Status AncillaryDetails Description: {}".format(match.StatusDetail.AncillaryDetails[-1].ReasonDescription))
73+
print("Status AncillaryDetails Description: {}"
74+
"".format(match.StatusDetail.AncillaryDetails[-1].ReasonDescription))
7475
if hasattr(match, 'ServiceCommitMessage'):
7576
print("Commit Message: {}".format(match.ServiceCommitMessage))
7677
if hasattr(match, 'Notification'):

fedex/base_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
class GeneralSudsPlugin(MessagePlugin):
1919
def __init__(self, **kwargs):
20-
2120
self.request_logger = logging.getLogger('fedex.request')
2221
self.response_logger = logging.getLogger('fedex.response')
2322
self.kwargs = kwargs

fedex/services/address_validation_service.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, config_obj, *args, **kwargs):
3737
"""@ivar: Holds the AddressToValidate WSDL object."""
3838
# Call the parent FedexBaseService class for basic setup work.
3939
super(FedexAddressValidationRequest, self).__init__(
40-
self._config_obj, 'AddressValidationService_v4.wsdl', *args, **kwargs)
40+
self._config_obj, 'AddressValidationService_v4.wsdl', *args, **kwargs)
4141

4242
def _prepare_wsdl_objects(self):
4343
"""
@@ -63,12 +63,12 @@ def _assemble_and_send_request(self):
6363
self.logger.debug(self.VersionId)
6464
# Fire off the query.
6565
return self.client.service.addressValidation(
66-
WebAuthenticationDetail=self.WebAuthenticationDetail,
67-
ClientDetail=self.ClientDetail,
68-
TransactionDetail=self.TransactionDetail,
69-
Version=self.VersionId,
70-
InEffectAsOfTimestamp=datetime.datetime.now(),
71-
AddressesToValidate=self.AddressesToValidate)
66+
WebAuthenticationDetail=self.WebAuthenticationDetail,
67+
ClientDetail=self.ClientDetail,
68+
TransactionDetail=self.TransactionDetail,
69+
Version=self.VersionId,
70+
InEffectAsOfTimestamp=datetime.datetime.now(),
71+
AddressesToValidate=self.AddressesToValidate)
7272

7373
def add_address(self, address_item):
7474
"""

fedex/services/availability_commitment_service.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, config_obj, *args, **kwargs):
5858
# Exception: binding 'ns:ValidationAvailabilityAndCommitmentServiceSoapBinding', not-found
5959

6060
super(FedexAvailabilityCommitmentRequest, self).__init__(
61-
self._config_obj, 'AvailabilityAndCommitmentService_v4.wsdl', *args, **kwargs)
61+
self._config_obj, 'AvailabilityAndCommitmentService_v4.wsdl', *args, **kwargs)
6262

6363
def _prepare_wsdl_objects(self):
6464
"""
@@ -88,13 +88,13 @@ def _assemble_and_send_request(self):
8888
self.logger.debug(self.VersionId)
8989
# Fire off the query.
9090
return self.client.service.serviceAvailability(
91-
WebAuthenticationDetail=self.WebAuthenticationDetail,
92-
ClientDetail=self.ClientDetail,
93-
TransactionDetail=self.TransactionDetail,
94-
Version=self.VersionId,
95-
Origin=self.Origin,
96-
Destination=self.Destination,
97-
ShipDate=self.ShipDate,
98-
CarrierCode=self.CarrierCode,
99-
Service=self.Service,
100-
Packaging=self.Packaging)
91+
WebAuthenticationDetail=self.WebAuthenticationDetail,
92+
ClientDetail=self.ClientDetail,
93+
TransactionDetail=self.TransactionDetail,
94+
Version=self.VersionId,
95+
Origin=self.Origin,
96+
Destination=self.Destination,
97+
ShipDate=self.ShipDate,
98+
CarrierCode=self.CarrierCode,
99+
Service=self.Service,
100+
Packaging=self.Packaging)

fedex/services/country_service.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, config_obj, *args, **kwargs):
4848
"""@ivar: Holds the CheckForMismatch boolean objects."""
4949

5050
super(FedexValidatePostalRequest, self).__init__(
51-
self._config_obj, 'CountryService_v4.wsdl', *args, **kwargs)
51+
self._config_obj, 'CountryService_v4.wsdl', *args, **kwargs)
5252

5353
def _prepare_wsdl_objects(self):
5454
"""
@@ -77,12 +77,12 @@ def _assemble_and_send_request(self):
7777
self.logger.debug(self.VersionId)
7878
# Fire off the query.
7979
return self.client.service.validatePostal(
80-
WebAuthenticationDetail=self.WebAuthenticationDetail,
81-
ClientDetail=self.ClientDetail,
82-
TransactionDetail=self.TransactionDetail,
83-
Version=self.VersionId,
84-
Address=self.Address,
85-
ShipDateTime=self.ShipDateTime,
86-
CarrierCode=self.CarrierCode,
87-
CheckForMismatch=self.CheckForMismatch,
88-
RoutingCode=self.RoutingCode)
80+
WebAuthenticationDetail=self.WebAuthenticationDetail,
81+
ClientDetail=self.ClientDetail,
82+
TransactionDetail=self.TransactionDetail,
83+
Version=self.VersionId,
84+
Address=self.Address,
85+
ShipDateTime=self.ShipDateTime,
86+
CarrierCode=self.CarrierCode,
87+
CheckForMismatch=self.CheckForMismatch,
88+
RoutingCode=self.RoutingCode)

fedex/services/location_service.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, config_obj, *args, **kwargs):
5353
"""@ivar: Holds the LocationSortDetail WSDL object."""
5454

5555
super(FedexSearchLocationRequest, self).__init__(
56-
self._config_obj, 'LocationsService_v3.wsdl', *args, **kwargs)
56+
self._config_obj, 'LocationsService_v3.wsdl', *args, **kwargs)
5757

5858
def _prepare_wsdl_objects(self):
5959
"""
@@ -85,13 +85,13 @@ def _assemble_and_send_request(self):
8585
self.logger.debug(self.VersionId)
8686
# Fire off the query.
8787
return self.client.service.searchLocations(
88-
WebAuthenticationDetail=self.WebAuthenticationDetail,
89-
ClientDetail=self.ClientDetail,
90-
TransactionDetail=self.TransactionDetail,
91-
Version=self.VersionId,
92-
LocationsSearchCriterion=self.LocationsSearchCriterion,
93-
PhoneNumber=self.PhoneNumber,
94-
MultipleMatchesAction=self.MultipleMatchesAction,
95-
Constraints=self.Constraints,
96-
Address=self.Address,
97-
SortDetail=self.SortDetail)
88+
WebAuthenticationDetail=self.WebAuthenticationDetail,
89+
ClientDetail=self.ClientDetail,
90+
TransactionDetail=self.TransactionDetail,
91+
Version=self.VersionId,
92+
LocationsSearchCriterion=self.LocationsSearchCriterion,
93+
PhoneNumber=self.PhoneNumber,
94+
MultipleMatchesAction=self.MultipleMatchesAction,
95+
Constraints=self.Constraints,
96+
Address=self.Address,
97+
SortDetail=self.SortDetail)

0 commit comments

Comments
 (0)