- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathListImage.py
More file actions
Latest commit
32 lines (26 loc) · 1.01 KB
/
Copy pathListImage.py
File metadata and controls
32 lines (26 loc) · 1.01 KB
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
#!/usr/bin/env python
#-*- encoding:utf-8 -*-
importos
importsys
fromlistdrawableimportListDrawable
classListImage(object):
def__init__(self, searchDir):
self.searchDir=searchDir
print('init ListImage searchDir: %s'%searchDir)
defimages(self):
drawableDirs=ListDrawable(self.searchDir).search()
imageFiles= [yforxinmap(self.__list_files, drawableDirs) foryinx]
returnimageFiles
def__list_files(self, d):
baseDir=d
return [os.path.join(baseDir, x) forxinos.listdir(baseDir) ifos.path.isfile(os.path.join(baseDir, x)) andself.is_image(x)]
defis_image(self, file):
returnfile.endswith('.png') orfile.endswith('.webp') orfile.endswith('.jpg')
if__name__=='__main__':
print('===execute ListImage from console===')
searchDir='./app/src/main/res'
iflen(sys.argv) ==2:
searchDir=sys.argv[1]
print('from input searchDir:', searchDir)
images=ListImage(searchDir).images()
print('searched %d images======>\n%s'% (len(images), images))