##// END OF EJS Templates
Wrap os.path functions in method calls...
Thomas Kluyver -
Show More
@@ -10,7 +10,7 for f in d.files('*.py'):
10 This module requires Python 2.5 or later.
10 This module requires Python 2.5 or later.
11
11
12
12
13 URL: http://www.jorendorff.com/articles/python/path
13 URL: http://pypi.python.org/pypi/path.py
14 Author: Jason Orendorff <jason.orendorff\x40gmail\x2ecom> (and others - see the url!)
14 Author: Jason Orendorff <jason.orendorff\x40gmail\x2ecom> (and others - see the url!)
15 Date: 9 Mar 2007
15 Date: 9 Mar 2007
16 """
16 """
@@ -99,7 +99,7 class path(unicode):
99
99
100 # --- Operations on path strings.
100 # --- Operations on path strings.
101
101
102 isabs = os.path.isabs
102 def isabs(s): return os.path.isabs(s)
103 def abspath(self): return self.__class__(os.path.abspath(self))
103 def abspath(self): return self.__class__(os.path.abspath(self))
104 def normcase(self): return self.__class__(os.path.normcase(self))
104 def normcase(self): return self.__class__(os.path.normcase(self))
105 def normpath(self): return self.__class__(os.path.normpath(self))
105 def normpath(self): return self.__class__(os.path.normpath(self))
@@ -107,7 +107,7 class path(unicode):
107 def expanduser(self): return self.__class__(os.path.expanduser(self))
107 def expanduser(self): return self.__class__(os.path.expanduser(self))
108 def expandvars(self): return self.__class__(os.path.expandvars(self))
108 def expandvars(self): return self.__class__(os.path.expandvars(self))
109 def dirname(self): return self.__class__(os.path.dirname(self))
109 def dirname(self): return self.__class__(os.path.dirname(self))
110 basename = os.path.basename
110 def basename(s): return os.path.basename(s)
111
111
112 def expand(self):
112 def expand(self):
113 """ Clean up a filename by calling expandvars(),
113 """ Clean up a filename by calling expandvars(),
@@ -752,33 +752,36 class path(unicode):
752 return m.digest()
752 return m.digest()
753
753
754 # --- Methods for querying the filesystem.
754 # --- Methods for querying the filesystem.
755 # N.B. We can't assign the functions directly, because they may on some
756 # platforms be implemented in C, and compiled functions don't get bound.
757 # See gh-737 for discussion of this.
755
758
756 exists = os.path.exists
759 def exists(s): return os.path.exists(s)
757 isdir = os.path.isdir
760 def isdir(s): return os.path.isdir(s)
758 isfile = os.path.isfile
761 def isfile(s): return os.path.isfile(s)
759 islink = os.path.islink
762 def islink(s): return os.path.islink(s)
760 ismount = os.path.ismount
763 def ismount(s): return os.path.ismount(s)
761
764
762 if hasattr(os.path, 'samefile'):
765 if hasattr(os.path, 'samefile'):
763 samefile = os.path.samefile
766 def samefile(s, o): return os.path.samefile(s, o)
764
767
765 getatime = os.path.getatime
768 def getatime(s): return os.path.getatime(s)
766 atime = property(
769 atime = property(
767 getatime, None, None,
770 getatime, None, None,
768 """ Last access time of the file. """)
771 """ Last access time of the file. """)
769
772
770 getmtime = os.path.getmtime
773 def getmtime(s): return os.path.getmtime(s)
771 mtime = property(
774 mtime = property(
772 getmtime, None, None,
775 getmtime, None, None,
773 """ Last-modified time of the file. """)
776 """ Last-modified time of the file. """)
774
777
775 if hasattr(os.path, 'getctime'):
778 if hasattr(os.path, 'getctime'):
776 getctime = os.path.getctime
779 def getctime(s): return os.path.getctime(s)
777 ctime = property(
780 ctime = property(
778 getctime, None, None,
781 getctime, None, None,
779 """ Creation time of the file. """)
782 """ Creation time of the file. """)
780
783
781 getsize = os.path.getsize
784 def getsize(s): return os.path.getsize(s)
782 size = property(
785 size = property(
783 getsize, None, None,
786 getsize, None, None,
784 """ Size of the file, in bytes. """)
787 """ Size of the file, in bytes. """)
General Comments 0
You need to be logged in to leave comments. Login now