1313from abc import ABC , abstractmethod
1414from glob import _GlobberBase
1515from io import text_encoding
16- from pathlib ._os import (magic_open , vfspath , ensure_distinct_paths ,
16+ from pathlib ._os import (vfsopen , vfspath , ensure_distinct_paths ,
1717 ensure_different_files , copyfileobj )
1818from pathlib import PurePath , Path
1919from typing import Optional , Protocol , runtime_checkable
@@ -264,18 +264,18 @@ def info(self):
264264 raise NotImplementedError
265265
266266 @abstractmethod
267- def __open_rb__ (self , buffering = - 1 ):
267+ def __open_reader__ (self ):
268268 """
269269 Open the file pointed to by this path for reading in binary mode and
270- return a file object, like open(mode='rb') .
270+ return a file object.
271271 """
272272 raise NotImplementedError
273273
274274 def read_bytes (self ):
275275 """
276276 Open the file in bytes mode, read it, and close the file.
277277 """
278- with magic_open (self , mode = 'rb' , buffering = 0 ) as f :
278+ with vfsopen (self , mode = 'rb' ) as f :
279279 return f .read ()
280280
281281 def read_text (self , encoding = None , errors = None , newline = None ):
@@ -285,7 +285,7 @@ def read_text(self, encoding=None, errors=None, newline=None):
285285 # Call io.text_encoding() here to ensure any warning is raised at an
286286 # appropriate stack level.
287287 encoding = text_encoding (encoding )
288- with magic_open (self , mode = 'r' , encoding = encoding , errors = errors , newline = newline ) as f :
288+ with vfsopen (self , mode = 'r' , encoding = encoding , errors = errors , newline = newline ) as f :
289289 return f .read ()
290290
291291 @abstractmethod
@@ -394,10 +394,10 @@ def mkdir(self):
394394 raise NotImplementedError
395395
396396 @abstractmethod
397- def __open_wb__ (self , buffering = - 1 ):
397+ def __open_writer__ (self , mode ):
398398 """
399399 Open the file pointed to by this path for writing in binary mode and
400- return a file object, like open(mode='wb') .
400+ return a file object.
401401 """
402402 raise NotImplementedError
403403
@@ -407,7 +407,7 @@ def write_bytes(self, data):
407407 """
408408 # type-check for the buffer interface before truncating the file
409409 view = memoryview (data )
410- with magic_open (self , mode = 'wb' ) as f :
410+ with vfsopen (self , mode = 'wb' ) as f :
411411 return f .write (view )
412412
413413 def write_text (self , data , encoding = None , errors = None , newline = None ):
@@ -420,7 +420,7 @@ def write_text(self, data, encoding=None, errors=None, newline=None):
420420 if not isinstance (data , str ):
421421 raise TypeError ('data must be str, not %s' %
422422 data .__class__ .__name__ )
423- with magic_open (self , mode = 'w' , encoding = encoding , errors = errors , newline = newline ) as f :
423+ with vfsopen (self , mode = 'w' , encoding = encoding , errors = errors , newline = newline ) as f :
424424 return f .write (data )
425425
426426 def _copy_from (self , source , follow_symlinks = True ):
@@ -439,8 +439,8 @@ def _copy_from(self, source, follow_symlinks=True):
439439 stack .append ((child , dst .joinpath (child .name )))
440440 else :
441441 ensure_different_files (src , dst )
442- with magic_open (src , 'rb' ) as source_f :
443- with magic_open (dst , 'wb' ) as target_f :
442+ with vfsopen (src , 'rb' ) as source_f :
443+ with vfsopen (dst , 'wb' ) as target_f :
444444 copyfileobj (source_f , target_f )
445445
446446
0 commit comments