Skip to content

Commit eee7f85

Browse files
committed
Added the process of rustfmt
1 parent d8a8147 commit eee7f85

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

expand.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import sys
44
import getopt
5+
import tempfile
6+
import subprocess
57

68
usage = '''Usage:expand.py [options] <output modules>
79
Output Modules:
@@ -92,6 +94,14 @@ def output_file(filename):
9294
if not i.startswith('internal'):
9395
output_data.append('use {}::*;'.format(i))
9496

95-
print(output_header)
96-
for i in output_data:
97-
print(i)
97+
# rustfmt
98+
with tempfile.TemporaryDirectory() as temp_dir:
99+
temp_file = temp_dir + '/output.rs'
100+
with open(temp_file, 'w') as f:
101+
print(output_header, file=f)
102+
for i in output_data:
103+
print(i, file=f)
104+
output_data = subprocess.run(["rustfmt", temp_file])
105+
with open(temp_file, 'r') as f:
106+
for line in f:
107+
print(line, end="")

0 commit comments

Comments
 (0)