-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_list.py
40 lines (35 loc) · 1.17 KB
/
plugin_list.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: Jaylin Zhou
# 24 Jan 2018
import os
import re
def listFiles(dirPath):
fileList = []
for (dirPath, dirNames, fileNames) in os.walk(path):
for fileName in fileNames:
if fileName == 'metadata.yaml':
fileList.append(os.path.join(dirPath, fileName))
return fileList
def findString(filePath, regex):
fileObj = open(filePath, 'r')
for eachLine in fileObj:
if re.search(regex, eachLine):
return eachLine.rstrip('\n')
if __name__ == '__main__':
path = raw_input('Input the path of dir: ')
dictFileStatus = {}
regex1 = 'status:'
regex2 = 'publish_date:'
fileList = listFiles(path)
for fileObj in fileList:
if findString(fileObj, regex1):
dictFileStatus[fileObj] = [findString(fileObj, regex1)]
else:
dictFileStatus[fileObj] = ['null']
if findString(fileObj, regex2):
dictFileStatus[fileObj].append(findString(fileObj, regex2))
else:
dictFileStatus[fileObj].append('null')
for key, value in dictFileStatus.items():
print key + ';' + value[0] + ';' + value[1]