From 32e5ad50fed05066a3bbad1b7ad13bfb139f456e Mon Sep 17 00:00:00 2001 From: ryanking13 Date: Mon, 1 Jan 2024 19:44:02 +0900 Subject: [PATCH 1/3] Fix requirements --- CHANGELOG.md | 2 + SRT/cli/__init__.py | 0 SRT/cli/reserve.py | 182 ------------------------------------------ docs/contribution.md | 3 +- pyproject.toml | 8 +- requirements.txt | 11 --- requirements/test.txt | 2 - 7 files changed, 7 insertions(+), 201 deletions(-) delete mode 100644 SRT/cli/__init__.py delete mode 100644 SRT/cli/reserve.py delete mode 100644 requirements.txt delete mode 100644 requirements/test.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index ce7ad9a..b4619ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased +- CLI 스크립트 삭제 + ## v2.3.0 (2023/09/26) - 카드 결제 기능 추가 diff --git a/SRT/cli/__init__.py b/SRT/cli/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/SRT/cli/reserve.py b/SRT/cli/reserve.py deleted file mode 100644 index 1614354..0000000 --- a/SRT/cli/reserve.py +++ /dev/null @@ -1,182 +0,0 @@ -import os -from datetime import datetime, timedelta - -from PyInquirer import prompt - -from SRT import SRT - -VERBOSE = os.environ.get("DEBUG") is not None - -SRT_STATIONS = ( - "수서", - "동탄", - "평택지제", - "곡성", - "공주", - "광주송정", - "구례구", - "김천(구미)", - "나주", - "남원", - "대전", - "동대구", - "마산", - "목포", - "밀양", - "부산", - "서대구", - "순천", - "신경주", - "여수EXPO", - "여천", - "오송", - "울산(통도사)", - "익산", - "전주", - "정읍", - "진영", - "진주", - "창원", - "창원중앙", - "천안아산", - "포항", -) - -not_empty = lambda s: len(s) > 0 - - -def hi(): - print( - """ -░██████╗██████╗░████████╗ -██╔════╝██╔══██╗╚══██╔══╝ -╚█████╗░██████╔╝░░░██║░░░ -░╚═══██╗██╔══██╗░░░██║░░░ -██████╔╝██║░░██║░░░██║░░░ -╚═════╝░╚═╝░░╚═╝░░░╚═╝░░░ -""" - ) - - -def login(): - questions = [ - { - "type": "input", - "name": "username", - "message": "SRT ID (username, e-mail, phone):", - "validate": not_empty, - }, - { - "type": "password", - "name": "password", - "message": "SRT Password:", - "validate": not_empty, - }, - ] - - inputs = prompt(questions) - return SRT(inputs["username"], inputs["password"], verbose=VERBOSE) - - -def select_station(): - questions = [ - { - "type": "list", - "name": "dep", - "message": "출발역:", - "choices": SRT_STATIONS, - }, - { - "type": "list", - "name": "arr", - "message": "도착역:", - "choices": SRT_STATIONS, - }, - ] - - stations = prompt(questions) - return stations["dep"], stations["arr"] - - -def select_date(): - next_cnt = 0 - num_days = 10 - to_prev = "이전 날짜로" - to_next = "다음 날짜로" - - while True: - not_first = next_cnt > 0 - - start_date = datetime.now() + timedelta(days=next_cnt * num_days) - dates = [ - (start_date + timedelta(days=i)).strftime("%Y%m%d") for i in range(num_days) - ] - - if not_first: - dates = [to_prev] + dates - - dates += [to_next] - - questions = [ - { - "type": "list", - "name": "date", - "message": "출발 날짜:", - "choices": dates, - } - ] - - date = prompt(questions)["date"] - - if date == to_prev: - next_cnt -= 1 - continue - elif date == to_next: - next_cnt += 1 - continue - else: - return date - - -def search_train(client, dep, arr, date): - trains = client.search_train(dep, arr, date, "000000") - trains = [ - { - "name": repr(train), - "value": train, - } - for train in trains - ] - questions = [ - { - "type": "list", - "name": "train", - "message": "열차 선택:", - "choices": trains, - }, - ] - - train = prompt(questions)["train"] - return train - - -def reserve(client, train): - return client.reserve(train) - - -def main(): - hi() - - srt = login() - station_dep, station_arr = select_station() - date_dep = select_date() - - train = search_train(srt, station_dep, station_arr, date_dep) - reservation = reserve(srt, train) - - print("예약 완료! 홈페이지에서 결제를 완료하세요.") - print(reservation) - - -if __name__ == "__main__": - main() diff --git a/docs/contribution.md b/docs/contribution.md index c9d012c..3b96026 100644 --- a/docs/contribution.md +++ b/docs/contribution.md @@ -17,8 +17,7 @@ export SRT_PASSWORD= # set SRT_USERNAME= # set SRT_PASSWORD= -pip install -r requirements/test.txt -pip install -r requirements.txt +pip install -e ".[test]" black SRT pytest SRT -v -x diff --git a/pyproject.toml b/pyproject.toml index 21bae13..8013721 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ readme = "README.md" requires-python = ">= 3.10" dependencies = [ "requests", - "PyInquirer", ] dynamic = [ "version", @@ -24,19 +23,20 @@ Homepage = "https://github.com/ryanking13/SRT" "Bug Tracker" = "https://github.com/ryanking13/SRT/issues" Changelog = "https://github.com/ryanking13/SRT/blob/master/CHANGELOG.md" -[project.scripts] -srt-reserve = "SRT.cli.reserve:main" - [project.optional-dependencies] test = [ "pytest", "pytest-httpserver", + "black", ] [tool.hatch.version] source = "vcs" +[tool.hatch.build.targets.wheel] +packages = ["SRT"] + [tool.ruff] select = [ "E", # pycodestyles diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e66e28a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -certifi==2021.5.30 -chardet==3.0.4 -idna==2.10 -prompt-toolkit==1.0.14 -Pygments==2.9.0 -PyInquirer==1.0.3 -regex==2021.10.23 -requests==2.26.0 -six==1.16.0 -urllib3==1.26.8 -wcwidth==0.2.5 diff --git a/requirements/test.txt b/requirements/test.txt deleted file mode 100644 index 9c90795..0000000 --- a/requirements/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest==6.2.4 -black==21.9b0 From 4aec05e8a00242045ce41e2ae2f6852d96421c96 Mon Sep 17 00:00:00 2001 From: ryanking13 Date: Mon, 1 Jan 2024 19:47:11 +0900 Subject: [PATCH 2/3] Fix requirements for doc --- requirements/docs.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/docs.txt b/requirements/docs.txt index a5bb937..b265550 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -24,3 +24,4 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 urllib3==1.26.15 +shpinx-rtd-theme From a8428fa7e3596f104dfe2605d2a0405eb1f72584 Mon Sep 17 00:00:00 2001 From: ryanking13 Date: Mon, 1 Jan 2024 19:52:58 +0900 Subject: [PATCH 3/3] Typo --- requirements/docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/docs.txt b/requirements/docs.txt index b265550..deace6c 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -24,4 +24,4 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 urllib3==1.26.15 -shpinx-rtd-theme +sphinx-rtd-theme