From 4b2c144aff9d090e85b69b94ffd09d96f3ea422c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 16 Apr 2021 23:52:13 +0000 Subject: [PATCH] Restyled by yapf --- librespot/core/ApResolver.py | 3 +- librespot/crypto/DiffieHellman.py | 198 +++++++++++++------------- librespot/standard/DataInputStream.py | 30 ++-- 3 files changed, 116 insertions(+), 115 deletions(-) diff --git a/librespot/core/ApResolver.py b/librespot/core/ApResolver.py index 9eb1ae6..6652514 100644 --- a/librespot/core/ApResolver.py +++ b/librespot/core/ApResolver.py @@ -8,7 +8,8 @@ class ApResolver: @staticmethod def request(service_type: str): - response = requests.get("{}?type={}".format(ApResolver.base_url, service_type)) + response = requests.get("{}?type={}".format(ApResolver.base_url, + service_type)) return response.json() @staticmethod diff --git a/librespot/crypto/DiffieHellman.py b/librespot/crypto/DiffieHellman.py index 60f3adc..e61c1ce 100644 --- a/librespot/crypto/DiffieHellman.py +++ b/librespot/crypto/DiffieHellman.py @@ -4,106 +4,104 @@ from librespot.common.Utils import Utils class DiffieHellman: - prime_bytes: bytearray = bytes( - [ - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xC9, - 0x0F, - 0xDA, - 0xA2, - 0x21, - 0x68, - 0xC2, - 0x34, - 0xC4, - 0xC6, - 0x62, - 0x8B, - 0x80, - 0xDC, - 0x1C, - 0xD1, - 0x29, - 0x02, - 0x4E, - 0x08, - 0x8A, - 0x67, - 0xCC, - 0x74, - 0x02, - 0x0B, - 0xBE, - 0xA6, - 0x3B, - 0x13, - 0x9B, - 0x22, - 0x51, - 0x4A, - 0x08, - 0x79, - 0x8E, - 0x34, - 0x04, - 0xDD, - 0xEF, - 0x95, - 0x19, - 0xB3, - 0xCD, - 0x3A, - 0x43, - 0x1B, - 0x30, - 0x2B, - 0x0A, - 0x6D, - 0xF2, - 0x5F, - 0x14, - 0x37, - 0x4F, - 0xE1, - 0x35, - 0x6D, - 0x6D, - 0x51, - 0xC2, - 0x45, - 0xE4, - 0x85, - 0xB5, - 0x76, - 0x62, - 0x5E, - 0x7E, - 0xC6, - 0xF4, - 0x4C, - 0x42, - 0xE9, - 0xA6, - 0x3A, - 0x36, - 0x20, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - ] - ) + prime_bytes: bytearray = bytes([ + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xC9, + 0x0F, + 0xDA, + 0xA2, + 0x21, + 0x68, + 0xC2, + 0x34, + 0xC4, + 0xC6, + 0x62, + 0x8B, + 0x80, + 0xDC, + 0x1C, + 0xD1, + 0x29, + 0x02, + 0x4E, + 0x08, + 0x8A, + 0x67, + 0xCC, + 0x74, + 0x02, + 0x0B, + 0xBE, + 0xA6, + 0x3B, + 0x13, + 0x9B, + 0x22, + 0x51, + 0x4A, + 0x08, + 0x79, + 0x8E, + 0x34, + 0x04, + 0xDD, + 0xEF, + 0x95, + 0x19, + 0xB3, + 0xCD, + 0x3A, + 0x43, + 0x1B, + 0x30, + 0x2B, + 0x0A, + 0x6D, + 0xF2, + 0x5F, + 0x14, + 0x37, + 0x4F, + 0xE1, + 0x35, + 0x6D, + 0x6D, + 0x51, + 0xC2, + 0x45, + 0xE4, + 0x85, + 0xB5, + 0x76, + 0x62, + 0x5E, + 0x7E, + 0xC6, + 0xF4, + 0x4C, + 0x42, + 0xE9, + 0xA6, + 0x3A, + 0x36, + 0x20, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + ]) prime: int = int.from_bytes(prime_bytes, "big") private_key: int public_key: int diff --git a/librespot/standard/DataInputStream.py b/librespot/standard/DataInputStream.py index 5a59d56..063d389 100644 --- a/librespot/standard/DataInputStream.py +++ b/librespot/standard/DataInputStream.py @@ -3,16 +3,20 @@ from librespot.standard.FilterInputStream import FilterInputStream class DataInputStream(FilterInputStream, DataInput): - def read(self, b: bytearray = None, offset: int = None, length: int = None) -> int: + def read(self, + b: bytearray = None, + offset: int = None, + length: int = None) -> int: if b is not None and offset is None and length is None: return self.input_stream.read(b, 0, len(b)) if b is not None and offset is not None and length is not None: return self.input_stream.read(b, offset, length) raise TypeError() - def read_fully( - self, b: bytearray = None, offset: int = None, length: int = None - ) -> None: + def read_fully(self, + b: bytearray = None, + offset: int = None, + length: int = None) -> None: if b is not None and offset is None and length is None: offset = 0 length = len(b) @@ -90,16 +94,14 @@ class DataInputStream(FilterInputStream, DataInput): def read_long(self) -> int: self.read_fully(self.read_buffer, 0, 8) - return ( - (self.read_buffer[0] << 56) - + ((self.read_buffer[1] & 255) << 48) - + ((self.read_buffer[2] & 255) << 40) - + ((self.read_buffer[3] & 255) << 32) - + ((self.read_buffer[4] & 255) << 24) - + ((self.read_buffer[5] & 255) << 16) - + ((self.read_buffer[6] & 255) << 8) - + ((self.read_buffer[7] & 255) << 0) - ) + return ((self.read_buffer[0] << 56) + + ((self.read_buffer[1] & 255) << 48) + + ((self.read_buffer[2] & 255) << 40) + + ((self.read_buffer[3] & 255) << 32) + + ((self.read_buffer[4] & 255) << 24) + + ((self.read_buffer[5] & 255) << 16) + + ((self.read_buffer[6] & 255) << 8) + + ((self.read_buffer[7] & 255) << 0)) def read_float(self) -> float: pass