@@ -491,43 +491,6 @@ def islink(self):
491
491
return S_ISLNK (self ._osstatresult .st_mode )
492
492
493
493
494
- class PosixPath (PathBase ):
495
- def chown (self , user , group , rec = 0 ):
496
- """Change ownership to the given user and group.
497
- user and group may be specified by a number or
498
- by a name. if rec is True change ownership
499
- recursively.
500
- """
501
- uid = getuserid (user )
502
- gid = getgroupid (group )
503
- if rec :
504
- for x in self .visit (rec = lambda x : x .check (link = 0 )):
505
- if x .check (link = 0 ):
506
- error .checked_call (os .chown , str (x ), uid , gid )
507
- error .checked_call (os .chown , str (self ), uid , gid )
508
-
509
- def readlink (self ):
510
- """Return value of a symbolic link."""
511
- return error .checked_call (os .readlink , self .strpath )
512
-
513
- def mklinkto (self , oldname ):
514
- """Posix style hard link to another name."""
515
- error .checked_call (os .link , str (oldname ), str (self ))
516
-
517
- def mksymlinkto (self , value , absolute = 1 ):
518
- """Create a symbolic link with the given value (pointing to another name)."""
519
- if absolute :
520
- error .checked_call (os .symlink , str (value ), self .strpath )
521
- else :
522
- base = self .common (value )
523
- # with posix local paths '/' is always a common base
524
- relsource = self .__class__ (value ).relto (base )
525
- reldest = self .relto (base )
526
- n = reldest .count (self .sep )
527
- target = self .sep .join ((".." ,) * n + (relsource ,))
528
- error .checked_call (os .symlink , target , self .strpath )
529
-
530
-
531
494
def getuserid (user ):
532
495
import pwd
533
496
@@ -544,10 +507,7 @@ def getgroupid(group):
544
507
return group
545
508
546
509
547
- FSBase = not iswin32 and PosixPath or PathBase
548
-
549
-
550
- class LocalPath (FSBase ):
510
+ class LocalPath (PathBase ):
551
511
"""Object oriented interface to os.path and other local filesystem
552
512
related information.
553
513
"""
@@ -581,6 +541,43 @@ def __init__(self, path=None, expanduser=False):
581
541
path = os .path .expanduser (path )
582
542
self .strpath = abspath (path )
583
543
544
+ if sys .platform != "win32" :
545
+
546
+ def chown (self , user , group , rec = 0 ):
547
+ """Change ownership to the given user and group.
548
+ user and group may be specified by a number or
549
+ by a name. if rec is True change ownership
550
+ recursively.
551
+ """
552
+ uid = getuserid (user )
553
+ gid = getgroupid (group )
554
+ if rec :
555
+ for x in self .visit (rec = lambda x : x .check (link = 0 )):
556
+ if x .check (link = 0 ):
557
+ error .checked_call (os .chown , str (x ), uid , gid )
558
+ error .checked_call (os .chown , str (self ), uid , gid )
559
+
560
+ def readlink (self ):
561
+ """Return value of a symbolic link."""
562
+ return error .checked_call (os .readlink , self .strpath )
563
+
564
+ def mklinkto (self , oldname ):
565
+ """Posix style hard link to another name."""
566
+ error .checked_call (os .link , str (oldname ), str (self ))
567
+
568
+ def mksymlinkto (self , value , absolute = 1 ):
569
+ """Create a symbolic link with the given value (pointing to another name)."""
570
+ if absolute :
571
+ error .checked_call (os .symlink , str (value ), self .strpath )
572
+ else :
573
+ base = self .common (value )
574
+ # with posix local paths '/' is always a common base
575
+ relsource = self .__class__ (value ).relto (base )
576
+ reldest = self .relto (base )
577
+ n = reldest .count (self .sep )
578
+ target = self .sep .join ((".." ,) * n + (relsource ,))
579
+ error .checked_call (os .symlink , target , self .strpath )
580
+
584
581
def __hash__ (self ):
585
582
s = self .strpath
586
583
if iswin32 :
0 commit comments