@@ -41,15 +41,15 @@ def _download_nasdaq_symbols(timeout):
41
41
42
42
lines = []
43
43
try :
44
- ftp_session .retrlines ('RETR ' + _NASDAQ_TICKER_LOC , lines .append )
44
+ ftp_session .retrlines ('RETR ' + _NASDAQ_TICKER_LOC , lines .append )
45
45
except all_errors as err :
46
46
raise RemoteDataError ('Error downloading from %r: $s' %
47
47
(_NASDAQ_FTP_SERVER , err ))
48
48
finally :
49
49
ftp_session .close ()
50
50
51
51
# Sanity Checking
52
- if not lines [- 1 ].startwith ('File Creation Time:' ):
52
+ if not lines [- 1 ].startswith ('File Creation Time:' ):
53
53
raise RemoteDataError ('Missing expected footer. Found %r' % lines [- 1 ])
54
54
55
55
# Convert Y/N to True/False.
@@ -74,8 +74,10 @@ def get_nasdaq_symbols(retry_count=3, timeout=30, pause=None):
74
74
Returns
75
75
-------
76
76
nasdaq_tickers : pandas.DataFrame
77
- DataFrame wiht company tickers, names, and other properties.
77
+ DataFrame with company tickers, names, and other properties.
78
78
"""
79
+ global _ticker_cache
80
+
79
81
if timeout < 0 :
80
82
raise ValueError ('timeout must be >= 0, not %r' % (timeout ,))
81
83
@@ -84,15 +86,14 @@ def get_nasdaq_symbols(retry_count=3, timeout=30, pause=None):
84
86
elif pause < 0 :
85
87
raise ValueError ('pause must be >= 0, not %r' % (pause ,))
86
88
87
- global _ticker_cache
88
89
if _ticker_cache is None :
89
90
while retry_count > 0 :
90
91
try :
91
92
_ticker_cache = _download_nasdaq_symbols (timeout = timeout )
92
93
retry_count = - 1
93
- except Exception :
94
+ except RemoteDataError :
94
95
# retry on any exception
95
- if retry_count = = 0 :
96
+ if retry_count < = 0 :
96
97
raise
97
98
else :
98
99
retry_count -= 1
0 commit comments