hydrus/include/ClientFiles.py

46 lines
1.0 KiB
Python
Raw Normal View History

2015-03-18 21:46:29 +00:00
import gc
2019-01-09 22:59:03 +00:00
from . import HydrusData
from . import HydrusExceptions
from . import HydrusGlobals as HG
2015-06-24 22:10:14 +00:00
import os
2015-03-18 21:46:29 +00:00
2018-08-08 20:29:54 +00:00
def GetAllPaths( raw_paths, do_human_sort = True ):
2015-03-18 21:46:29 +00:00
file_paths = []
paths_to_process = raw_paths
while len( paths_to_process ) > 0:
next_paths_to_process = []
for path in paths_to_process:
2017-11-08 22:07:12 +00:00
if HG.view_shutdown:
raise HydrusExceptions.ShutdownException()
2015-03-18 21:46:29 +00:00
if os.path.isdir( path ):
2015-11-04 22:30:28 +00:00
subpaths = [ os.path.join( path, filename ) for filename in os.listdir( path ) ]
2015-03-18 21:46:29 +00:00
next_paths_to_process.extend( subpaths )
2015-11-04 22:30:28 +00:00
else:
file_paths.append( path )
2015-03-18 21:46:29 +00:00
paths_to_process = next_paths_to_process
2018-08-08 20:29:54 +00:00
if do_human_sort:
HydrusData.HumanTextSort( file_paths )
2018-07-18 21:07:15 +00:00
2015-03-18 21:46:29 +00:00
return file_paths
2015-12-02 22:32:18 +00:00