Created
March 15, 2019 15:18
-
-
Save threecourse/67209fe5539dc09cc928440f5f2517a3 to your computer and use it in GitHub Desktop.
分かれたファイルを一つに統合するスクリプト(C#コード用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
if __name__ == "__main__": | |
import glob | |
files = glob.glob("src/*") | |
print(files) | |
ls_using = [] | |
ls_main = [] | |
for path in files: | |
with open(path, "r", encoding="utf-8") as f: | |
lines = f.readlines() | |
flag_using = False | |
flag_main = False | |
for i, line in enumerate(lines): | |
if "// CUT USING START" in line: | |
flag_using = True | |
print(line) | |
if "// CUT USING END" in line: | |
print(line) | |
flag_using = False | |
if "// CUT MAIN START" in line: | |
flag_main = True | |
print(line) | |
if "// CUT MAIN END" in line: | |
print(line) | |
flag_main = False | |
if flag_using: | |
ls_using.append(line) | |
if flag_main: | |
ls_main.append(line) | |
with open("integrated.tmp", "w", encoding="utf-8") as f: | |
f.writelines(ls_using) | |
f.write("namespace Marathon {") | |
f.writelines(ls_main) | |
f.write("}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment