SHARE
TWEET

pathlib.PosiPath additions

DeaD_EyE Sep 25th, 2018 74 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top