Skip to content

Commit

Permalink
Formatted with black
Browse files Browse the repository at this point in the history
  • Loading branch information
keonly authored and github-actions[bot] committed Nov 28, 2023
1 parent 68738e0 commit 7d266a3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions API/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def fetch_all_data(
)
parser.add_argument("--output-path", help="API 요청 결과 저장 경로", default="output")



args = vars(parser.parse_args())
print(args)
sgIds = args.get("sgIds").split(",")
Expand All @@ -90,7 +88,9 @@ def fetch_all_data(
drop_columns = []
print(drop_columns)

data_list = fetch_all_data(sgIds, args.get("sgTypecodes"), drop_columns=drop_columns)
data_list = fetch_all_data(
sgIds, args.get("sgTypecodes"), drop_columns=drop_columns
)

for sgTypecode in args.get("sgTypecodes").split(","):
if sgTypecode not in SG_TYPECODE:
Expand All @@ -100,4 +100,4 @@ def fetch_all_data(
save_to_mongo(data_list, sgTypecode, CANDIDATE_TYPECODE_TYPE[sgTypecode])

if args.get("output_store"):
save_to_excel(data_list, sgTypecode, is_elected=False)
save_to_excel(data_list, sgTypecode, is_elected=False)
5 changes: 3 additions & 2 deletions API/elected.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ def fetch_all_data(
)
parser.add_argument("--output-path", help="API 요청 결과 저장 경로", default="output")


args = vars(parser.parse_args())
sgIds = args.get("sgIds").split(",")
if args.get("drop_columns"):
drop_columns = args.get("drop_columns").split(",")
else:
drop_columns = []

data_list = fetch_all_data(sgIds, args.get("sgTypecodes"), drop_columns=drop_columns)
data_list = fetch_all_data(
sgIds, args.get("sgTypecodes"), drop_columns=drop_columns
)

for sgTypecode in args.get("sgTypecodes").split(","):
if sgTypecode not in SG_TYPECODE:
Expand Down
6 changes: 4 additions & 2 deletions scrap/utils/data_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def export_results_to_txt(
f.write(f"| {cid} | {councilors}\n")


def import_results_from_json(input_path: str, council_type: str) -> Dict[str, ScrapResult]:
def import_results_from_json(
input_path: str, council_type: str
) -> Dict[str, ScrapResult]:
with open(input_path, "r", encoding="utf-8") as f:
results = json.load(f)

Expand All @@ -54,4 +56,4 @@ def import_results_from_json(input_path: str, council_type: str) -> Dict[str, Sc
for k, v in results.items()
}

return results
return results
6 changes: 4 additions & 2 deletions scrap/utils/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,13 @@ def main(args: Dict[str, str]) -> None:

where = args.get("where")
current_time = datetime.datetime.now().strftime("%Y%m%d_%H%M")

json_import_path = args.get("import_from_json")
if json_import_path:
if not args.get("update_mongo"):
raise ValueError("JSON 파일에서 가져온 결과를 MongoDB에 업데이트하려면 --update-mongo (-m) 옵션을 사용해야 합니다.")
raise ValueError(
"JSON 파일에서 가져온 결과를 MongoDB에 업데이트하려면 --update-mongo (-m) 옵션을 사용해야 합니다."
)

print("JSON 파일에서 결과를 가져옵니다. 다른 스크랩 관련 옵션은 무시됩니다.")
results = import_results_from_json(json_import_path, where)
Expand Down

0 comments on commit 7d266a3

Please sign in to comment.