@@ -64,7 +64,7 @@ def __next__(self):
6464 raise AbstractMethodError (self )
6565
6666
67- def _is_url (url ) -> bool :
67+ def is_url (url ) -> bool :
6868 """
6969 Check to see if a URL has a valid protocol.
7070
@@ -102,7 +102,7 @@ def _expand_user(
102102 return filepath_or_buffer
103103
104104
105- def _validate_header_arg (header ) -> None :
105+ def validate_header_arg (header ) -> None :
106106 if isinstance (header , bool ):
107107 raise TypeError (
108108 "Passing a bool to header is invalid. "
@@ -112,7 +112,7 @@ def _validate_header_arg(header) -> None:
112112 )
113113
114114
115- def _stringify_path (
115+ def stringify_path (
116116 filepath_or_buffer : FilePathOrBuffer [AnyStr ],
117117) -> FilePathOrBuffer [AnyStr ]:
118118 """Attempt to convert a path-like object to a string.
@@ -193,9 +193,9 @@ def get_filepath_or_buffer(
193193 compression, str,
194194 should_close, bool)
195195 """
196- filepath_or_buffer = _stringify_path (filepath_or_buffer )
196+ filepath_or_buffer = stringify_path (filepath_or_buffer )
197197
198- if isinstance (filepath_or_buffer , str ) and _is_url (filepath_or_buffer ):
198+ if isinstance (filepath_or_buffer , str ) and is_url (filepath_or_buffer ):
199199 req = urlopen (filepath_or_buffer )
200200 content_encoding = req .headers .get ("Content-Encoding" , None )
201201 if content_encoding == "gzip" :
@@ -250,7 +250,7 @@ def file_path_to_url(path: str) -> str:
250250_compression_to_extension = {"gzip" : ".gz" , "bz2" : ".bz2" , "zip" : ".zip" , "xz" : ".xz" }
251251
252252
253- def _get_compression_method (
253+ def get_compression_method (
254254 compression : Optional [Union [str , Mapping [str , str ]]]
255255) -> Tuple [Optional [str ], Dict [str , str ]]:
256256 """
@@ -283,7 +283,7 @@ def _get_compression_method(
283283 return compression , compression_args
284284
285285
286- def _infer_compression (
286+ def infer_compression (
287287 filepath_or_buffer : FilePathOrBuffer , compression : Optional [str ]
288288) -> Optional [str ]:
289289 """
@@ -317,7 +317,7 @@ def _infer_compression(
317317 # Infer compression
318318 if compression == "infer" :
319319 # Convert all path types (e.g. pathlib.Path) to strings
320- filepath_or_buffer = _stringify_path (filepath_or_buffer )
320+ filepath_or_buffer = stringify_path (filepath_or_buffer )
321321 if not isinstance (filepath_or_buffer , str ):
322322 # Cannot infer compression of a buffer, assume no compression
323323 return None
@@ -338,7 +338,7 @@ def _infer_compression(
338338 raise ValueError (msg )
339339
340340
341- def _get_handle (
341+ def get_handle (
342342 path_or_buf ,
343343 mode : str ,
344344 encoding = None ,
@@ -396,12 +396,12 @@ def _get_handle(
396396 f = path_or_buf
397397
398398 # Convert pathlib.Path/py.path.local or string
399- path_or_buf = _stringify_path (path_or_buf )
399+ path_or_buf = stringify_path (path_or_buf )
400400 is_path = isinstance (path_or_buf , str )
401401
402- compression , compression_args = _get_compression_method (compression )
402+ compression , compression_args = get_compression_method (compression )
403403 if is_path :
404- compression = _infer_compression (path_or_buf , compression )
404+ compression = infer_compression (path_or_buf , compression )
405405
406406 if compression :
407407
@@ -421,7 +421,7 @@ def _get_handle(
421421
422422 # ZIP Compression
423423 elif compression == "zip" :
424- zf = BytesZipFile (path_or_buf , mode , ** compression_args )
424+ zf = _BytesZipFile (path_or_buf , mode , ** compression_args )
425425 # Ensure the container is closed as well.
426426 handles .append (zf )
427427 if zf .mode == "w" :
@@ -472,7 +472,7 @@ def _get_handle(
472472
473473 if memory_map and hasattr (f , "fileno" ):
474474 try :
475- wrapped = MMapWrapper (f )
475+ wrapped = _MMapWrapper (f )
476476 f .close ()
477477 f = wrapped
478478 except Exception :
@@ -485,7 +485,7 @@ def _get_handle(
485485 return f , handles
486486
487487
488- class BytesZipFile (zipfile .ZipFile , BytesIO ): # type: ignore
488+ class _BytesZipFile (zipfile .ZipFile , BytesIO ): # type: ignore
489489 """
490490 Wrapper for standard library class ZipFile and allow the returned file-like
491491 handle to accept byte strings via `write` method.
@@ -518,7 +518,7 @@ def closed(self):
518518 return self .fp is None
519519
520520
521- class MMapWrapper (BaseIterator ):
521+ class _MMapWrapper (BaseIterator ):
522522 """
523523 Wrapper for the Python's mmap class so that it can be properly read in
524524 by Python's csv.reader class.
@@ -537,7 +537,7 @@ def __init__(self, f: IO):
537537 def __getattr__ (self , name : str ):
538538 return getattr (self .mmap , name )
539539
540- def __iter__ (self ) -> "MMapWrapper " :
540+ def __iter__ (self ) -> "_MMapWrapper " :
541541 return self
542542
543543 def __next__ (self ) -> str :
0 commit comments