1414from pandas .io .common import urlencode
1515from pandas .compat import StringIO , bytes_to_str
1616
17- from pandas_datareader ._utils import RemoteDataError , SymbolWarning
17+ from pandas_datareader ._utils import (RemoteDataError , SymbolWarning ,
18+ _sanitize_dates , _init_session )
1819
1920import requests_ftp
2021requests_ftp .monkeypatch_session ()
@@ -47,7 +48,7 @@ def __init__(self, symbols, start=None, end=None,
4748 retry_count = 3 , pause = 0.1 , timeout = 30 , session = None ):
4849 self .symbols = symbols
4950
50- start , end = self . _sanitize_dates (start , end )
51+ start , end = _sanitize_dates (start , end )
5152 self .start = start
5253 self .end = end
5354
@@ -56,14 +57,7 @@ def __init__(self, symbols, start=None, end=None,
5657 self .retry_count = retry_count
5758 self .pause = pause
5859 self .timeout = timeout
59- self .session = self ._init_session (session , retry_count )
60-
61- def _init_session (self , session , retry_count ):
62- if session is None :
63- session = requests .Session ()
64- session .mount ('file://' , FileAdapter ())
65- # do not set requests max_retries here to support arbitrary pause
66- return session
60+ self .session = _init_session (session , retry_count )
6761
6862 @property
6963 def url (self ):
@@ -143,27 +137,6 @@ def _read_lines(self, out):
143137 rs .index .name = rs .index .name .encode ('ascii' , 'ignore' ).decode ()
144138 return rs
145139
146- def _sanitize_dates (self , start , end ):
147- """
148- Return (datetime_start, datetime_end) tuple
149- if start is None - default is 2010/01/01
150- if end is None - default is today
151- """
152- if is_number (start ):
153- # regard int as year
154- start = dt .datetime (start , 1 , 1 )
155- start = to_datetime (start )
156-
157- if is_number (end ):
158- end = dt .datetime (end , 1 , 1 )
159- end = to_datetime (end )
160-
161- if start is None :
162- start = dt .datetime (2010 , 1 , 1 )
163- if end is None :
164- end = dt .datetime .today ()
165- return start , end
166-
167140
168141class _DailyBaseReader (_BaseReader ):
169142 """ Base class for Google / Yahoo daily reader """
0 commit comments