-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_file.py
53 lines (44 loc) · 1.47 KB
/
get_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
def get_file(folderpath):
if os.access(folderpath, os.F_OK):
for x in range(0, 2):
if not len(os.listdir(folderpath)) == 0:
folderpath += "/" + os.listdir(folderpath)[0]
else:
break
else:
return None
return folderpath+"/000000.dcm"
def get_folder(folderpath):
if os.access(folderpath, os.F_OK):
for x in range(0, 2):
if not len(os.listdir(folderpath)) == 0:
if len(os.listdir(folderpath)) == 2:
folderpath += "/" + os.listdir(folderpath)[1]
else:
folderpath += "/" + os.listdir(folderpath)[0]
else:
break
return folderpath+"/"
def get_folder_other(folderpath):
if os.access(folderpath, os.F_OK):
for x in range(0, 2):
if not len(os.listdir(folderpath)) == 0:
folderpath += "/" + os.listdir(folderpath)[0]
else:
break
return folderpath+"/"
def get_full_path(init_folder):
DDSM = []
if os.access(init_folder, os.F_OK):
folderList = os.listdir(init_folder)
for i in folderList:
DDSM.append(get_file(init_folder+i))
return DDSM
def get_full_path_folder(init_folder):
DDSM = []
if os.access(init_folder, os.F_OK):
folderList = os.listdir(init_folder)
for i in folderList:
DDSM.append(get_folder(init_folder+i))
return DDSM