File tree 1 file changed +26
-26
lines changed
1 file changed +26
-26
lines changed Original file line number Diff line number Diff line change 4
4
5
5
def main ():
6
6
if len (sys .argv ) != 2 :
7
- print (' Usage: txt-to-toml.py [src.txt]' )
7
+ print (" Usage: txt-to-toml.py [src.txt]" )
8
8
return 1
9
9
10
10
filename = sys .argv [1 ]
11
11
12
- indent = ' '
12
+ indent = " "
13
13
in_workload = False
14
14
first_test = False
15
15
keys_before_test = False
16
16
17
17
for line in open (filename ):
18
- k = ''
19
- v = ''
18
+ k = ""
19
+ v = ""
20
20
21
- if line .strip ().startswith (';' ):
22
- print ( (indent if in_workload else '' ) + line .strip ().replace (';' , '#' ) )
23
- continue
21
+ if line .strip ().startswith (";" ):
22
+ print ((indent if in_workload else "" ) + line .strip ().replace (";" , "#" ) )
23
+ continue
24
24
25
- if '=' in line :
26
- (k , v ) = line .strip ().split ('=' )
25
+ if "=" in line :
26
+ (k , v ) = line .strip ().split ("=" )
27
27
(k , v ) = (k .strip (), v .strip ())
28
28
29
- if k == ' testTitle' :
29
+ if k == " testTitle" :
30
30
first_test = True
31
- if in_workload :
32
- print ('' )
31
+ if in_workload :
32
+ print ("" )
33
33
in_workload = False
34
34
if keys_before_test :
35
- print ('' )
35
+ print ("" )
36
36
keys_before_test = False
37
- print (' [[test]]' )
37
+ print (" [[test]]" )
38
38
39
- if k == ' testName' :
39
+ if k == " testName" :
40
40
in_workload = True
41
- print ('' )
42
- print (indent + ' [[test.workload]]' )
41
+ print ("" )
42
+ print (indent + " [[test.workload]]" )
43
43
44
44
if not first_test :
45
45
keys_before_test = True
46
46
47
- if v .startswith ('.' ):
48
- v = '0' + v
47
+ if v .startswith ("." ):
48
+ v = "0" + v
49
49
50
- if any (c .isalpha () or c in ['/' , '!' ] for c in v ):
51
- if v != ' true' and v != ' false' :
50
+ if any (c .isalpha () or c in ["/" , "!" ] for c in v ):
51
+ if v != " true" and v != " false" :
52
52
v = "'" + v + "'"
53
53
54
- if k == ' buggify' :
55
- print (' buggify = ' + (' true' if v == "'on'" else ' false' ))
56
- elif k :
57
- print ( (indent if in_workload else '' ) + k + ' = ' + v )
54
+ if k == " buggify" :
55
+ print (" buggify = " + (" true" if v == "'on'" else " false" ))
56
+ elif k :
57
+ print ((indent if in_workload else "" ) + k + " = " + v )
58
58
59
59
return 0
60
60
61
61
62
- if __name__ == ' __main__' :
62
+ if __name__ == " __main__" :
63
63
sys .exit (main ())
You can’t perform that action at this time.
0 commit comments