Run black code formatter on split.py
This commit is contained in:
parent
9bbb4741b4
commit
3f4e9056e9
24
split.py
24
split.py
@ -6,12 +6,16 @@ import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
border = '// ----------------------------------------------------------------------------'
|
||||
border = (
|
||||
"// ----------------------------------------------------------------------------"
|
||||
)
|
||||
|
||||
args_parser = argparse.ArgumentParser(description=__doc__)
|
||||
args_parser.add_argument(
|
||||
"-e", "--extension", help="extension of the implementation file (default: cc)",
|
||||
default="cc"
|
||||
"-e",
|
||||
"--extension",
|
||||
help="extension of the implementation file (default: cc)",
|
||||
default="cc",
|
||||
)
|
||||
args_parser.add_argument(
|
||||
"-o", "--out", help="where to write the files (default: out)", default="out"
|
||||
@ -19,9 +23,9 @@ args_parser.add_argument(
|
||||
args = args_parser.parse_args()
|
||||
|
||||
cur_dir = os.path.dirname(sys.argv[0])
|
||||
lib_name = 'httplib'
|
||||
header_name = '/' + lib_name + '.h'
|
||||
source_name = '/' + lib_name + '.' + args.extension
|
||||
lib_name = "httplib"
|
||||
header_name = "/" + lib_name + ".h"
|
||||
source_name = "/" + lib_name + "." + args.extension
|
||||
# get the input file
|
||||
in_file = cur_dir + header_name
|
||||
# get the output file
|
||||
@ -49,18 +53,18 @@ if do_split:
|
||||
|
||||
in_implementation = False
|
||||
cc_out = args.out + source_name
|
||||
with open(h_out, 'w') as fh, open(cc_out, 'w') as fc:
|
||||
with open(h_out, "w") as fh, open(cc_out, "w") as fc:
|
||||
fc.write('#include "httplib.h"\n')
|
||||
fc.write('namespace httplib {\n')
|
||||
fc.write("namespace httplib {\n")
|
||||
for line in lines:
|
||||
is_border_line = border in line
|
||||
if is_border_line:
|
||||
in_implementation = not in_implementation
|
||||
elif in_implementation:
|
||||
fc.write(line.replace('inline ', ''))
|
||||
fc.write(line.replace("inline ", ""))
|
||||
else:
|
||||
fh.write(line)
|
||||
fc.write('} // namespace httplib\n')
|
||||
fc.write("} // namespace httplib\n")
|
||||
|
||||
print("Wrote {} and {}".format(h_out, cc_out))
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user