<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import shutil <EOL> from io import open <EOL> from six import PY2 , text_type , binary_type <EOL> FILESYSTEMENCODING = sys . getfilesystemencoding ( ) or sys . getdefaultencoding ( ) <EOL> class path ( text_type ) : <EOL> """<STR_LIT>""" <EOL> if PY2 : <EOL> def __new__ ( cls , s , encoding = FILESYSTEMENCODING , errors = '<STR_LIT:strict>' ) : <EOL> if isinstance ( s , str ) : <EOL> s = s . decode ( encoding , errors ) <EOL> return text_type . __new__ ( cls , s ) <EOL> return text_type . __new__ ( cls , s ) <EOL> @ property <EOL> def parent ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . __class__ ( os . path . dirname ( self ) ) <EOL> def basename ( self ) : <EOL> return os . path . basename ( self ) <EOL> def abspath ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . __class__ ( os . path . abspath ( self ) ) <EOL> def isabs ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . isabs ( self ) <EOL> def isdir ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . isdir ( self ) <EOL> def isfile ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . isfile ( self ) <EOL> def islink ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . islink ( self ) <EOL> def ismount ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . ismount ( self ) <EOL> def rmtree ( self , ignore_errors = False , onerror = None ) : <EOL> """<STR_LIT>""" <EOL> shutil . rmtree ( self , ignore_errors = ignore_errors , onerror = onerror ) <EOL> def copytree ( self , destination , symlinks = False ) : <EOL> """<STR_LIT>""" <EOL> shutil . copytree ( self , destination , symlinks = symlinks ) <EOL> def movetree ( self , destination ) : <EOL> """<STR_LIT>""" <EOL> shutil . move ( self , destination ) <EOL> move = movetree <EOL> def unlink ( self ) : <EOL> """<STR_LIT>""" <EOL> os . unlink ( self ) <EOL> def utime ( self , arg ) : <EOL> os . utime ( self , arg ) <EOL> def open ( self , mode = '<STR_LIT:r>' , ** kwargs ) : <EOL> return open ( self , mode , ** kwargs ) <EOL> def write_text ( self , text , encoding = '<STR_LIT:utf-8>' , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( text , bytes ) : <EOL> text = text . decode ( encoding ) <EOL> with open ( self , '<STR_LIT:w>' , encoding = encoding , ** kwargs ) as f : <EOL> f . write ( text ) <EOL> def text ( self , encoding = '<STR_LIT:utf-8>' , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> with open ( self , mode = '<STR_LIT>' , encoding = encoding , ** kwargs ) as f : <EOL> text = f . read ( ) <EOL> contents = repr_as ( text , '<STR_LIT>' % self . basename ( ) ) <EOL> return contents <EOL> def bytes ( self ) : <EOL> """<STR_LIT>""" <EOL> with open ( self , mode = '<STR_LIT:rb>' ) as f : <EOL> return f . read ( ) <EOL> def write_bytes ( self , bytes , append = False ) : <EOL> """<STR_LIT>""" <EOL> if append : <EOL> mode = '<STR_LIT>' <EOL> else : <EOL> mode = '<STR_LIT:wb>' <EOL> with open ( self , mode = mode ) as f : <EOL> f . write ( bytes ) <EOL> def exists ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . exists ( self ) <EOL> def lexists ( self ) : <EOL> """<STR_LIT>""" <EOL> return os . path . lexists ( self ) <EOL> def makedirs ( self , mode = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> os . makedirs ( self , mode ) <EOL> def joinpath ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> return self . __class__ ( os . path . join ( self , * map ( self . __class__ , args ) ) ) <EOL> def listdir ( self ) : <EOL> return os . listdir ( self ) <EOL> __div__ = __truediv__ = joinpath <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , text_type . __repr__ ( self ) ) <EOL> class _repr_text ( text_type ) : <EOL> def __repr__ ( self ) : <EOL> return self . _repr <EOL> class _repr_bin ( binary_type ) : <EOL> def __repr__ ( self ) : <EOL> return self . _repr <EOL> def repr_as ( string , repr_ ) : <EOL> wrapper = _repr_text if isinstance ( string , text_type ) else _repr_bin <EOL> proxy = wrapper ( string ) <EOL> proxy . _repr = repr_ <EOL> return proxy </s>
