Skip to content

Commit bfa242f

Browse files
author
Kazuki Suzuki Przyborowski
committed
Update pycatfile.py
1 parent 4c8b861 commit bfa242f

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

pycatfile.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ def ListDir(dirpath, followlink=False, duplicates=False, include_regex=None, exc
621621
Returns:
622622
list: A list of files and directories matching the criteria.
623623
"""
624-
if os.stat not in os.supports_follow_symlinks and followlink:
624+
try:
625+
if os.stat not in os.supports_follow_symlinks and followlink:
626+
followlink = False
627+
except AttributeError:
625628
followlink = False
626629
if isinstance(dirpath, (list, tuple)):
627630
dirpath = list(filter(None, dirpath))
@@ -688,7 +691,10 @@ def ListDirAdvanced(dirpath, followlink=False, duplicates=False, include_regex=N
688691
Returns:
689692
list: A list of files and directories matching the criteria.
690693
"""
691-
if os.stat not in os.supports_follow_symlinks and followlink:
694+
try:
695+
if os.stat not in os.supports_follow_symlinks and followlink:
696+
followlink = False
697+
except AttributeError:
692698
followlink = False
693699
if isinstance(dirpath, (list, tuple)):
694700
dirpath = list(filter(None, dirpath))
@@ -3149,7 +3155,10 @@ def AppendFilesWithContent(infiles, fp, dirlistfromtxt=False, filevalues=[], ext
31493155
infilelist = list(filter(None, infiles))
31503156
elif(isinstance(infiles, (basestring, ))):
31513157
infilelist = list(filter(None, [infiles]))
3152-
if os.stat not in os.supports_follow_symlinks and followlink:
3158+
try:
3159+
if os.stat not in os.supports_follow_symlinks and followlink:
3160+
followlink = False
3161+
except AttributeError:
31533162
followlink = False
31543163
if(advancedlist):
31553164
GetDirList = ListDirAdvanced(infilelist, followlink, False)
@@ -4374,7 +4383,10 @@ def PackArchiveFile(infiles, outfile, dirlistfromtxt=False, compression="auto",
43744383
infilelist = list(filter(None, infiles))
43754384
elif(isinstance(infiles, (basestring, ))):
43764385
infilelist = list(filter(None, [infiles]))
4377-
if os.stat not in os.supports_follow_symlinks and followlink:
4386+
try:
4387+
if os.stat not in os.supports_follow_symlinks and followlink:
4388+
followlink = False
4389+
except AttributeError:
43784390
followlink = False
43794391
if(advancedlist):
43804392
GetDirList = ListDirAdvanced(infilelist, followlink, False)
@@ -7233,7 +7245,10 @@ def ListDirToArrayAlt(infiles, dirlistfromtxt=False, followlink=False, listonly=
72337245
infilelist = list(filter(None, infiles))
72347246
elif(isinstance(infiles, (basestring, ))):
72357247
infilelist = list(filter(None, [infiles]))
7236-
if os.stat not in os.supports_follow_symlinks and followlink:
7248+
try:
7249+
if os.stat not in os.supports_follow_symlinks and followlink:
7250+
followlink = False
7251+
except AttributeError:
72377252
followlink = False
72387253
if(advancedlist):
72397254
GetDirList = ListDirAdvanced(infilelist, followlink, False)

0 commit comments

Comments
 (0)