pep-8 pycharm pass, force deprecation for movement service · python-fedex-devs/python-fedex@a6b7c5b · GitHub
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

Lines changed: 168 additions & 167 deletions

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
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

0 commit comments

Comments
 (0)