From 8970bde1f806d2b4fad6a28dd1b7940dbbfe140e Mon Sep 17 00:00:00 2001 From: Jim137 Date: Mon, 26 Feb 2024 23:10:42 +0800 Subject: [PATCH 1/5] Fix output path in log_paifu function --- paifulogger/log.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paifulogger/log.py b/paifulogger/log.py index fdae4a5..fcbd4cf 100644 --- a/paifulogger/log.py +++ b/paifulogger/log.py @@ -75,7 +75,7 @@ def _get_output(output: str = "./") -> str: """ if output: - _output = output + _output = os.path.abspath(output) else: _output = os.path.abspath("./") return _output @@ -84,7 +84,7 @@ def _get_output(output: str = "./") -> str: def _get_urls( url: list[str] | None = None, local_lang: local_str = local_str("en", os.path.dirname(os.path.abspath(__file__))), - output: str = "./", + output: str = os.path.abspath("./"), remake: bool = False, ) -> list[str]: """ @@ -206,7 +206,7 @@ def log_paifu( *, log_formats: list[Callable] = [log_into_csv], local_lang: local_str = local_str("en", os.path.dirname(os.path.abspath(__file__))), - output: str = "./", + output: str = os.path.abspath("./"), remake: bool = False, ignore_duplicated: bool = False, mjai: bool = False, From ee0dd1bac8dd1842fadd6527f9863ad4651dda05 Mon Sep 17 00:00:00 2001 From: Jim137 Date: Mon, 26 Feb 2024 23:19:03 +0800 Subject: [PATCH 2/5] Refactor log_paifu function to use retCode instead of success --- paifulogger/log.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/paifulogger/log.py b/paifulogger/log.py index fcbd4cf..949e408 100644 --- a/paifulogger/log.py +++ b/paifulogger/log.py @@ -234,7 +234,7 @@ def log_paifu( int """ - success = [] + retCode = [] for url in urls: if not re.match(url_reg, url): print(local_lang.hint_url, url) @@ -252,17 +252,17 @@ def log_paifu( pass else: url_log(url, local_lang, output) - success.append(0) + retCode.append(0) except urllib.error.URLError: print(local_lang.hint_url, url) - success.append(1) + retCode.append(1) except OSError: print(local_lang.hint_url, url) - success.append(1) + retCode.append(1) except ValueError: print(local_lang.hint_tw, url) - success.append(1) - return max(success) + retCode.append(1) + return max(retCode) def log(args: argparse.Namespace) -> int: From b449eb221d43704c66e147ff529de090f4522676 Mon Sep 17 00:00:00 2001 From: Jim137 Date: Thu, 29 Feb 2024 16:14:50 +0800 Subject: [PATCH 3/5] remove https warning --- paifulogger/log.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/paifulogger/log.py b/paifulogger/log.py index 949e408..352e3bc 100644 --- a/paifulogger/log.py +++ b/paifulogger/log.py @@ -115,17 +115,8 @@ def _get_urls( urlstore = store["url"]["url"].values for _url in urlstore: - # Special case: if the url does not start with "https://", add it. - # It will be deprecated in the future. if not re.match(url_reg, _url): urls.append("https://" + _url) - warnings.warn( - """The url_log.h5 you used is deprecated. - You have to manually copy all urls and delete url_log.h5, then run and paste the urls to the program. - The new url_log.h5 will be automatically created. - """, - DeprecationWarning, - ) continue urls.append(_url) From 0cf759ee5e079340bf12f3270148560498a38e28 Mon Sep 17 00:00:00 2001 From: Jim137 Date: Thu, 29 Feb 2024 16:21:55 +0800 Subject: [PATCH 4/5] log_paifu catch all kind of url input --- paifulogger/log.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/paifulogger/log.py b/paifulogger/log.py index 352e3bc..22f0307 100644 --- a/paifulogger/log.py +++ b/paifulogger/log.py @@ -193,8 +193,7 @@ def _get_log_func(formats: list[str], all_formats: bool = False) -> list[Callabl def log_paifu( - urls: list[str], - *, + *urls: list[str] | str, log_formats: list[Callable] = [log_into_csv], local_lang: local_str = local_str("en", os.path.dirname(os.path.abspath(__file__))), output: str = os.path.abspath("./"), @@ -226,7 +225,13 @@ def log_paifu( """ retCode = [] + _urls: list[str] = [] for url in urls: + if isinstance(url, list): + _urls.extend(url) + else: + _urls.append(url) + for url in _urls: if not re.match(url_reg, url): print(local_lang.hint_url, url) continue From b76f8e0165c53c32d729484eb8c356302ee19870 Mon Sep 17 00:00:00 2001 From: Jim137 Date: Thu, 29 Feb 2024 16:24:56 +0800 Subject: [PATCH 5/5] v0.3.8.2 --- paifulogger/__init__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paifulogger/__init__.py b/paifulogger/__init__.py index 210ea1c..833ff04 100644 --- a/paifulogger/__init__.py +++ b/paifulogger/__init__.py @@ -1 +1 @@ -__version__ = "0.3.8.1" +__version__ = "0.3.8.2" diff --git a/pyproject.toml b/pyproject.toml index 86ecdd6..f87eb68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "PaifuLogger" -version = "0.3.8.1" +version = "0.3.8.2" description = "Logging tenhou paifu into excel or html file with some key information." readme = "README.md" authors = [{ name = "Jim137", email = "jim@mail.jim137.eu.org" }]