Skip to content

Commit 805ef9d

Browse files
committed
Refactor: running black pandas-datareader and reformatted 2 files.
1 parent a1e0c77 commit 805ef9d

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

pandas_datareader/tests/io/test_jsdmx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_quartervalue(dirpath):
170170
"2011-10-01",
171171
],
172172
dtype="datetime64[ns]",
173-
name=u"Period",
173+
name="Period",
174174
freq=None,
175175
)
176176
tm.assert_index_equal(result.index, expected)

pandas_datareader/tests/yahoo/test_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def assert_option_result(self, df):
100100
]
101101
)
102102
tm.assert_index_equal(df.columns, exp_columns)
103-
assert df.index.names == [u"Strike", u"Expiry", u"Type", u"Symbol"]
103+
assert df.index.names == ["Strike", "Expiry", "Type", "Symbol"]
104104

105105
dtypes = [
106106
np.dtype(x)

pandas_datareader/yahoo/daily.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717

1818

1919
def decrypt_cryptojs_aes(data):
20-
encrypted_stores = data['context']['dispatcher']['stores']
20+
encrypted_stores = data["context"]["dispatcher"]["stores"]
2121
_cs = data["_cs"]
2222
_cr = data["_cr"]
2323

24-
_cr = b"".join(int.to_bytes(i, length=4, byteorder="big", signed=True) for i in json.loads(_cr)["words"])
24+
_cr = b"".join(
25+
int.to_bytes(i, length=4, byteorder="big", signed=True)
26+
for i in json.loads(_cr)["words"]
27+
)
2528
password = hashlib.pbkdf2_hmac("sha1", _cs.encode("utf8"), _cr, 1, dklen=32).hex()
2629

2730
encrypted_stores = b64decode(encrypted_stores)
@@ -30,12 +33,12 @@ def decrypt_cryptojs_aes(data):
3033
encrypted_stores = encrypted_stores[16:]
3134

3235
def EVPKDF(
33-
password,
34-
salt,
35-
keySize=32,
36-
ivSize=16,
37-
iterations=1,
38-
hashAlgorithm="md5",
36+
password,
37+
salt,
38+
keySize=32,
39+
ivSize=16,
40+
iterations=1,
41+
hashAlgorithm="md5",
3942
) -> tuple:
4043
"""OpenSSL EVP Key Derivation Function
4144
Args:
@@ -74,7 +77,9 @@ def EVPKDF(
7477
key, iv = key_iv[:keySize], key_iv[keySize:final_length]
7578
return key, iv
7679

77-
key, iv = EVPKDF(password, salt, keySize=32, ivSize=16, iterations=1, hashAlgorithm="md5")
80+
key, iv = EVPKDF(
81+
password, salt, keySize=32, ivSize=16, iterations=1, hashAlgorithm="md5"
82+
)
7883

7984
cipher = AES.new(key, AES.MODE_CBC, iv=iv)
8085
plaintext = cipher.decrypt(encrypted_stores)
@@ -129,19 +134,19 @@ class YahooDailyReader(_DailyBaseReader):
129134
"""
130135

131136
def __init__(
132-
self,
133-
symbols=None,
134-
start=None,
135-
end=None,
136-
retry_count=3,
137-
pause=0.1,
138-
session=None,
139-
adjust_price=False,
140-
ret_index=False,
141-
chunksize=1,
142-
interval="d",
143-
get_actions=False,
144-
adjust_dividends=True,
137+
self,
138+
symbols=None,
139+
start=None,
140+
end=None,
141+
retry_count=3,
142+
pause=0.1,
143+
session=None,
144+
adjust_price=False,
145+
ret_index=False,
146+
chunksize=1,
147+
interval="d",
148+
get_actions=False,
149+
adjust_dividends=True,
145150
):
146151
super().__init__(
147152
symbols=symbols,
@@ -225,10 +230,12 @@ def _read_one_data(self, url, params):
225230
j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1))
226231

227232
if "_cs" in j and "_cr" in j:
228-
new_j = decrypt_cryptojs_aes(j) # returns j["context"]["dispatcher"]["stores"]
233+
new_j = decrypt_cryptojs_aes(
234+
j
235+
) # returns j["context"]["dispatcher"]["stores"]
229236
# from old code
230237

231-
data = new_j['HistoricalPriceStore']
238+
data = new_j["HistoricalPriceStore"]
232239

233240
except KeyError:
234241
msg = "No data fetched for symbol {} using {}"

0 commit comments

Comments
 (0)