mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2026-01-10 01:14:20 +01:00
fix all linting for pylint3
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
Module used to describe all of the different data types
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
RESET_SEQ = "\033[0m"
|
||||
@@ -22,13 +26,19 @@ KEYWORD_COLORS = {
|
||||
}
|
||||
|
||||
def formatter_message(message, use_color = True):
|
||||
if use_color:
|
||||
message = message.replace("$RESET", RESET_SEQ).replace("$BOLD", BOLD_SEQ)
|
||||
else:
|
||||
message = message.replace("$RESET", "").replace("$BOLD", "")
|
||||
return message
|
||||
"""
|
||||
Syntax highlight certain keywords
|
||||
"""
|
||||
if use_color:
|
||||
message = message.replace("$RESET", RESET_SEQ).replace("$BOLD", BOLD_SEQ)
|
||||
else:
|
||||
message = message.replace("$RESET", "").replace("$BOLD", "")
|
||||
return message
|
||||
|
||||
def format_word(message, word, color_seq, bold=False, underline=False):
|
||||
"""
|
||||
Surround the fiven word with a sequence
|
||||
"""
|
||||
replacer = color_seq + word + RESET_SEQ
|
||||
if underline:
|
||||
replacer = UNDERLINE_SEQ + replacer
|
||||
@@ -45,6 +55,9 @@ class Formatter(logging.Formatter):
|
||||
self.use_color = use_color
|
||||
|
||||
def format(self, record):
|
||||
"""
|
||||
Format and highlight certain keywords
|
||||
"""
|
||||
levelname = record.levelname
|
||||
if self.use_color and levelname in KEYWORD_COLORS:
|
||||
levelname_color = KEYWORD_COLORS[levelname] + levelname + RESET_SEQ
|
||||
@@ -71,6 +84,9 @@ class CustomLogger(logging.Logger):
|
||||
return
|
||||
|
||||
def trade(self, message, *args, **kws):
|
||||
"""
|
||||
Print a syntax highlighted trade signal
|
||||
"""
|
||||
if self.isEnabledFor(self.TRADE):
|
||||
message = format_word(message, 'CLOSED ', YELLOW, bold=True)
|
||||
message = format_word(message, 'OPENED ', LIGHT_BLUE, bold=True)
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
"""
|
||||
This module is used to house all of the functions which are used
|
||||
to handle the http authentication of the client
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import hmac
|
||||
import time
|
||||
|
||||
def generate_auth_payload(API_KEY, API_SECRET):
|
||||
"""
|
||||
Generate a signed payload
|
||||
|
||||
@return json Oject headers
|
||||
"""
|
||||
nonce = _gen_nonce()
|
||||
authMsg, sig = _gen_signature(API_KEY, API_SECRET, nonce)
|
||||
|
||||
@@ -15,6 +25,9 @@ def generate_auth_payload(API_KEY, API_SECRET):
|
||||
}
|
||||
|
||||
def generate_auth_headers(API_KEY, API_SECRET, path, body):
|
||||
"""
|
||||
Generate headers for a signed payload
|
||||
"""
|
||||
nonce = str(_gen_nonce())
|
||||
signature = "/api/v2/{}{}{}".format(path, nonce, body)
|
||||
h = hmac.new(API_SECRET.encode('utf8'), signature.encode('utf8'), hashlib.sha384)
|
||||
|
||||
Reference in New Issue
Block a user