Skip to content

Commit 0cda8ab

Browse files
committed
Improved code quality using pylint, added docstrings wherever required
1 parent 7e22c61 commit 0cda8ab

30 files changed

+763
-225
lines changed

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Setup file
3+
"""
14
import setuptools
25
setuptools.setup(
36
name="bitpay",

setup/bitpay_setup.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def select_env():
3636

3737
set_environment(environment)
3838
select_create_key()
39-
except BitPayException as e:
40-
print(e)
39+
except BitPayException as exe:
40+
print(exe)
4141

4242

4343
def set_environment(env):
@@ -55,16 +55,16 @@ def select_create_key():
5555
create_new_key()
5656
else:
5757
load_key()
58-
except BitPayException as e:
59-
print(e)
58+
except BitPayException as exe:
59+
print(exe)
6060

6161

6262
def create_new_key():
6363
try:
6464
private_key = generate_pem()
6565
store_key(private_key)
66-
except BitPayException as e:
67-
print(e)
66+
except BitPayException as exe:
67+
print(exe)
6868

6969

7070
def store_key(private_key):
@@ -86,8 +86,8 @@ def store_key(private_key):
8686
select_tokens(private_key)
8787
else:
8888
store_key(private_key)
89-
except BitPayException as e:
90-
print(e)
89+
except BitPayException as exe:
90+
print(exe)
9191

9292

9393
def select_tokens(private_key):
@@ -99,8 +99,8 @@ def select_tokens(private_key):
9999
request_tokens(input_value.lower(), private_key)
100100
else:
101101
select_tokens(private_key)
102-
except BitPayException as e:
103-
print(e)
102+
except BitPayException as exe:
103+
print(exe)
104104

105105

106106
def request_tokens(token_type, private_key):
@@ -135,8 +135,8 @@ def request_tokens(token_type, private_key):
135135
print("Payout Token Pairing Code: ", response.json()['data'][0]['pairingCode'] + "\n")
136136

137137
update_config_file()
138-
except BitPayException as e:
139-
print(e)
138+
except BitPayException as exe:
139+
print(exe)
140140

141141

142142
def update_config_file():
@@ -167,8 +167,8 @@ def update_config_file():
167167
print(f"{api_url}/dashboard/merchant/api-tokens\r\n")
168168
print("\r\nOnce you have this Pairing Code/s approved you can move the generated files to a secure location "
169169
"and start using the Client.\r\n")
170-
except BitPayException as e:
171-
print(e)
170+
except BitPayException as exe:
171+
print(exe)
172172

173173

174174
def load_key():

src/bitpay_sdk/client.py

Lines changed: 342 additions & 157 deletions
Large diffs are not rendered by default.

src/bitpay_sdk/config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
1+
"""
2+
class Config
3+
"""
4+
5+
16
class Config:
7+
"""
8+
class Config that set and get configurations
9+
"""
10+
211
__environment = ""
312
__envconfig = ""
413

514
def __init__(self):
615
pass
716

817
def get_environment(self):
18+
"""
19+
Get method for to environment
20+
:return: environment
21+
"""
922
return self.__environment
1023

1124
def set_environment(self, environment):
25+
"""
26+
Set method for to environment
27+
:param environment: environment
28+
"""
1229
self.__environment = environment
1330

1431
def get_envconfig(self):
32+
"""
33+
Get method for to envconfig
34+
:return: envconfig
35+
"""
1536
return self.__envconfig
1637

1738
def set_envconfig(self, envconfig):
39+
"""
40+
Set method for to envconfig
41+
:param envconfig: envconfig
42+
"""
1843
self.__envconfig = envconfig

src/bitpay_sdk/env.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Test="Test"
2-
Prod="Prod"
3-
TestUrl="https://test.bitpay.com/"
4-
ProdUrl="https://bitpay.com/"
5-
BitpayApiVersion="2.0.0"
6-
BitpayPluginInfo="BitPay_Python_Client_v6.0.2111"
7-
BitpayApiFrame="std"
8-
BitpayApiFrameVersion="1.0.0"
1+
TEST = "Test"
2+
PROD = "Prod"
3+
TESTURL = "https://test.bitpay.com/"
4+
PRODURL = "https://bitpay.com/"
5+
BITPAYAPIVERSION = "2.0.0"
6+
BITPAYPLUGININFO = "BitPay_Python_Client_v6.0.2111"
7+
BITPAYAPIFRAME = "std"
8+
BITPAYAPIFRAMEVERSION = "1.0.0"
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
"""
2+
Bill Creation Exception gets raised when request for bill creation gets failed.
3+
"""
14
from .bill_exception import BillException
25

36

47
class BillCreationException(BillException):
8+
"""
9+
BillCreationException
10+
"""
511
__bitpay_message = "Failed to create bill"
612
__bitpay_code = "BITPAY-BILL-CREATE"
713
__api_code = ""
814

915
def __init__(self, message, code=112, api_code="000000"):
16+
"""
17+
Construct the BillCreationException.
18+
19+
:param message: The Exception message to throw.
20+
:param code: [optional] The Exception code to throw.
21+
:param api_code: [optional] The API Exception code to throw.
22+
"""
1023
message = self.__bitpay_code + ": " + self.__bitpay_message + ":" + message
1124
self.__api_code = api_code
12-
super(BillCreationException, self).__init__(message, code)
25+
super().__init__(message, code)
1326

1427
# def get_api_code(self):
1528
# return self.__api_code
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
"""
2+
Bill Delivery Exception gets raised when request for bill delivery gets failed.
3+
"""
14
from .bill_exception import BillException
25

36

47
class BillDeliveryException(BillException):
8+
"""
9+
BillDeliveryException
10+
"""
511
__bitpay_message = "Failed to deliver bill"
612
__bitpay_code = "BITPAY-BILL-DELIVERY"
713
__api_code = ""
814

915
def __init__(self, message, code=115, api_code="000000"):
16+
"""
17+
Construct the BillDeliveryException.
18+
19+
:param message: The Exception message to throw.
20+
:param code: [optional] The Exception code to throw.
21+
:param api_code: [optional] The API Exception code to throw.
22+
"""
1023
message = self.__bitpay_code + ": " + self.__bitpay_message + ":" + message
1124
self.__api_code = api_code
12-
super(BillDeliveryException, self).__init__(message, code)
25+
super().__init__(message, code)
1326

1427
# def get_api_code(self):
1528
# return self.__api_code
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1+
"""
2+
Bill Exception gets raised when some unexpected error occurs while processing a request
3+
or trying to manage bills.
4+
"""
15
from .bitpay_exception import BitPayException
26

37

48
class BillException(BitPayException):
9+
"""
10+
BillException
11+
"""
512
__bitpay_message = "An unexpected error occurred while trying to manage the bill"
613
__bitpay_code = "BITPAY-BILL-GENERIC"
714
__api_code = ""
815

916
def __init__(self, message="", code=111, api_code="000000"):
17+
"""
18+
Construct the BillException.
19+
20+
:param message: The Exception message to throw.
21+
:param code: [optional] The Exception code to throw.
22+
:param api_code: [optional] The API Exception code to throw.
23+
"""
1024
message = self.__bitpay_code + ": " + self.__bitpay_message + ":" + message
1125
self.__api_code = api_code
12-
super(BillException, self).__init__(message, code)
26+
super().__init__(message, code)
1327

1428
# def get_api_code(self):
1529
# return self.__api_code
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
"""
2+
Bill Query Exception gets raised when request for bill retrieval gets failed .
3+
"""
14
from .bill_exception import BillException
25

36

47
class BillQueryException(BillException):
8+
"""
9+
BillQueryException
10+
"""
511
__bitpay_message = "Failed to retrieve bill"
612
__bitpay_code = "BITPAY-REFUND-GET"
713
__api_code = ""
814

915
def __init__(self, message, code=113, api_code="000000"):
16+
"""
17+
Construct the BillQueryException.
18+
19+
:param message: The Exception message to throw.
20+
:param code: [optional] The Exception code to throw.
21+
:param api_code: [optional] The API Exception code to throw.
22+
"""
1023
message = self.__bitpay_code + ": " + self.__bitpay_message + ":" + message
1124
self.__api_code = api_code
12-
super(BillQueryException, self).__init__(message, code)
25+
super().__init__(message, code)
1326

1427
# def get_api_code(self):
1528
# return self.__api_code
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
"""
2+
Bill Update Exception gets raised when it fails to update bill
3+
"""
14
from .bill_exception import BillException
25

36

47
class BillUpdateException(BillException):
8+
"""
9+
BillUpdateException
10+
"""
511
__bitpay_message = "Failed to update bill"
612
__bitpay_code = "BITPAY-BILL-UPDATE"
713
__api_code = ""
814

915
def __init__(self, message, code=114, api_code="000000"):
16+
"""
17+
Construct the BillUpdateException.
18+
19+
:param message: The Exception message to throw.
20+
:param code: [optional] The Exception code to throw.
21+
:param api_code: [optional] The API Exception code to throw.
22+
"""
1023
message = self.__bitpay_code + ": " + self.__bitpay_message + ":" + message
1124
self.__api_code = api_code
12-
super(BillUpdateException, self).__init__(message, code)
25+
super().__init__(message, code)
1326

1427
# def get_api_code(self):
1528
# return self.__api_code

0 commit comments

Comments
 (0)