From c26c0fd7ee0880af709c2465f5decb4e3c2e9687 Mon Sep 17 00:00:00 2001 From: keonly Date: Mon, 13 Nov 2023 09:23:50 +0000 Subject: [PATCH] Formatted with black --- API/__init__.py | 2 +- API/candidate.py | 6 +++++- API/elected.py | 4 +++- API/utils.py | 2 +- API/votecode.py | 4 +--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/API/__init__.py b/API/__init__.py index bea2ed8..9c71e90 100644 --- a/API/__init__.py +++ b/API/__init__.py @@ -26,4 +26,4 @@ "4": CouncilType.LOCAL_LEADER, "5": CouncilType.METROPOLITAN_COUNCIL, "6": CouncilType.LOCAL_COUNCIL, -} \ No newline at end of file +} diff --git a/API/candidate.py b/API/candidate.py index 0cc8ff1..8a0a019 100644 --- a/API/candidate.py +++ b/API/candidate.py @@ -11,7 +11,9 @@ BASE_URL = "http://apis.data.go.kr/9760000/PofelcddInfoInqireService/getPofelcddRegistSttusInfoInqire" -def fetch_data(sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000) -> List[dict]: +def fetch_data( + sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000 +) -> List[dict]: params = { "serviceKey": OpenDataPortalSecrets.service_key, "pageNo": str(page_no), @@ -37,6 +39,7 @@ def fetch_data(sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = return data_list + def fetch_all_data(sgIds: List[str], sgTypecodes: List[str]) -> List[dict]: data_list = [] for sgId in sgIds: @@ -45,6 +48,7 @@ def fetch_all_data(sgIds: List[str], sgTypecodes: List[str]) -> List[dict]: return data_list + if __name__ == "__main__": sgTypecode_input = input("원하는 sgTypecode 하나를 입력하세요:\n") sgIds_input = input("원하는 sgId를 입력하세요. 여러 개라면 ','로 구분하여 입력하세요:\n").split(",") diff --git a/API/elected.py b/API/elected.py index 6542986..cc1d918 100644 --- a/API/elected.py +++ b/API/elected.py @@ -11,7 +11,9 @@ BASE_URL = "http://apis.data.go.kr/9760000/WinnerInfoInqireService2/getWinnerInfoInqire" -def fetch_data(sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000) -> List[dict]: +def fetch_data( + sgId: str, sgTypecode: str, page_no: int = 1, num_of_rows: int = 10_000 +) -> List[dict]: params = { "serviceKey": OpenDataPortalSecrets.service_key, "pageNo": str(page_no), diff --git a/API/utils.py b/API/utils.py index 8e170bf..df3b3bf 100644 --- a/API/utils.py +++ b/API/utils.py @@ -26,4 +26,4 @@ def save_to_mongo(data: List[dict], sgTypecode: str) -> None: # TODO: 지역구별로 분리하여 업데이트하는 로직 추가 collection.insert_many(data) - print(f"데이터를 MongoDB의 '{collection_name}' 컬렉션에 저장하였습니다.") \ No newline at end of file + print(f"데이터를 MongoDB의 '{collection_name}' 컬렉션에 저장하였습니다.") diff --git a/API/votecode.py b/API/votecode.py index 88d07f7..374e761 100644 --- a/API/votecode.py +++ b/API/votecode.py @@ -14,9 +14,7 @@ if args.code: formatted_code = ", ".join([f"({k}) {v}" for k, v in SG_TYPECODE.items()]) print(formatted_code) -print( - "sgTypecode를 입력하면 해당 sgTypecode와 일치하는 sgId 값을 출력합니다. 여러 개를 입력하려면 ','로 구분해 주세요." - ) +print("sgTypecode를 입력하면 해당 sgTypecode와 일치하는 sgId 값을 출력합니다. 여러 개를 입력하려면 ','로 구분해 주세요.") url = "http://apis.data.go.kr/9760000/CommonCodeService/getCommonSgCodeList" params = {