1
1
import os
2
2
import json
3
-
3
+
4
+
4
5
def get_files ():
5
6
recordList = []
6
- for filepath ,dirnames ,filenames in os .walk (r'./quickstarts' ):
7
+ for filepath , dirnames , filenames in os .walk (r'./quickstarts' ):
7
8
for filename in filenames :
8
9
if filename != 'TestRecord.md' :
9
10
continue
@@ -16,33 +17,35 @@ def get_files():
16
17
version = ""
17
18
# print(testRecordPath)
18
19
19
- f = open (os .path .join (filepath ,filename ))
20
- line = f .readline ()
21
- while line :
22
- if line .startswith ("## " ):
20
+ f = open (os .path .join (filepath , filename ))
21
+ line = f .readline ()
22
+ while line :
23
+ if line .startswith ("## " ) and updateTime == "" :
23
24
updateTime = line .strip ("## " ).strip ("\n " )
24
- if line .startswith ("success" ):
25
+ if line .startswith ("success" ) and success == "" :
25
26
success = line .strip ("success: " ).strip ("\n " )
26
- if line .__contains__ ("+ provider" ) and line .__contains__ ("alicloud" ):
27
- version = line .strip ("+ provider " ).split (" " )[- 1 ].strip ("\n " )
27
+ if line .__contains__ ("+ provider" ) and line .__contains__ ("alicloud" ) and version == "" :
28
+ version = line .strip (
29
+ "+ provider " ).split (" " )[- 1 ].strip ("\n " )
28
30
break
29
- line = f .readline ()
30
-
31
+ line = f .readline ()
32
+
31
33
f .close ()
32
34
error = ""
33
- logPath = os .path .join (filepath ,'terraform.log' )
35
+ logPath = os .path .join (filepath , 'terraform.log' )
34
36
if success == "false" and os .path .exists (logPath ):
35
37
f = open (logPath )
36
38
error = f .read ()
37
39
f .close ()
38
-
39
- d = dict (subcategory = subcategory ,exampleName = exampleName ,updateTime = updateTime ,version = version ,success = success ,error = error )
40
+
41
+ d = dict (subcategory = subcategory , exampleName = exampleName ,
42
+ updateTime = updateTime , version = version , success = success , error = error )
40
43
recordList .append (d )
41
-
44
+
42
45
finalRecord = dict (data = recordList )
43
- with open ("./TestRecord.json" ,"w" ) as file :
44
- json .dump (finalRecord ,file )
46
+ with open ("./TestRecord.json" , "w" ) as file :
47
+ json .dump (finalRecord , file )
45
48
46
49
47
50
if __name__ == '__main__' :
48
- get_files ()
51
+ get_files ()
0 commit comments