|
6 | 6 | import os |
7 | 7 | import sys |
8 | 8 |
|
9 | | -border = '// ----------------------------------------------------------------------------' |
| 9 | +border = ( |
| 10 | + "// ----------------------------------------------------------------------------" |
| 11 | +) |
10 | 12 |
|
11 | 13 | args_parser = argparse.ArgumentParser(description=__doc__) |
12 | 14 | args_parser.add_argument( |
13 | | - "-e", "--extension", help="extension of the implementation file (default: cc)", |
14 | | - default="cc" |
| 15 | + "-e", |
| 16 | + "--extension", |
| 17 | + help="extension of the implementation file (default: cc)", |
| 18 | + default="cc", |
15 | 19 | ) |
16 | 20 | args_parser.add_argument( |
17 | 21 | "-o", "--out", help="where to write the files (default: out)", default="out" |
18 | 22 | ) |
19 | 23 | args = args_parser.parse_args() |
20 | 24 |
|
21 | 25 | cur_dir = os.path.dirname(sys.argv[0]) |
22 | | -lib_name = 'httplib' |
23 | | -header_name = '/' + lib_name + '.h' |
24 | | -source_name = '/' + lib_name + '.' + args.extension |
| 26 | +lib_name = "httplib" |
| 27 | +header_name = "/" + lib_name + ".h" |
| 28 | +source_name = "/" + lib_name + "." + args.extension |
25 | 29 | # get the input file |
26 | 30 | in_file = cur_dir + header_name |
27 | 31 | # get the output file |
|
49 | 53 |
|
50 | 54 | in_implementation = False |
51 | 55 | cc_out = args.out + source_name |
52 | | - with open(h_out, 'w') as fh, open(cc_out, 'w') as fc: |
| 56 | + with open(h_out, "w") as fh, open(cc_out, "w") as fc: |
53 | 57 | fc.write('#include "httplib.h"\n') |
54 | | - fc.write('namespace httplib {\n') |
| 58 | + fc.write("namespace httplib {\n") |
55 | 59 | for line in lines: |
56 | 60 | is_border_line = border in line |
57 | 61 | if is_border_line: |
58 | 62 | in_implementation = not in_implementation |
59 | 63 | elif in_implementation: |
60 | | - fc.write(line.replace('inline ', '')) |
| 64 | + fc.write(line.replace("inline ", "")) |
61 | 65 | else: |
62 | 66 | fh.write(line) |
63 | | - fc.write('} // namespace httplib\n') |
| 67 | + fc.write("} // namespace httplib\n") |
64 | 68 |
|
65 | 69 | print("Wrote {} and {}".format(h_out, cc_out)) |
66 | 70 | else: |
|
0 commit comments