DeaD_EyE

pathlib.PosiPath additions

Sep 25th, 2018
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import pathlib
  3. import inspect
  4.  
  5.  
  6. class EPosixPath(pathlib.PosixPath):
  7.  
  8.     def relpath(self, other):
  9.         return self.__class__(os.path.relpath(self, other))
  10.  
  11.     def is_hidden(self):
  12.         '''
  13.        Returns True if the file or dir is hidden.
  14.        '''
  15.         return str(self.name).startswith('.')
  16.  
  17.  
  18. EPosixPath.relpath.__doc__ = inspect.getdoc(os.path.relpath)
  19.  
  20. pathlib.PosixPath = EPosixPath
  21. Path = pathlib.Path
RAW Paste Data