chrisbase
Advanced tools
+1
-1
| MIT License | ||
| Copyright (c) 2023 Jihee Ryu | ||
| Copyright (c) 2024 Jihee Ryu | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
+17
-15
| Metadata-Version: 2.1 | ||
| Name: chrisbase | ||
| Version: 0.5.3 | ||
| Summary: A base tool for python programming. | ||
| Version: 0.5.4 | ||
| Summary: Base library for python coding | ||
| Home-page: https://github.com/chrisjihee/chrisbase | ||
@@ -17,6 +17,7 @@ Author: Jihee Ryu | ||
| License-File: LICENSE | ||
| Requires-Dist: typer[all] | ||
| Requires-Dist: tqdm | ||
| Requires-Dist: typer | ||
| Requires-Dist: numpy | ||
| Requires-Dist: scipy | ||
| Requires-Dist: httpx | ||
| Requires-Dist: pandas | ||
@@ -27,2 +28,4 @@ Requires-Dist: pymongo | ||
| Requires-Dist: ipynbname | ||
| Requires-Dist: ipaddress | ||
| Requires-Dist: netifaces | ||
| Requires-Dist: matplotlib | ||
@@ -36,21 +39,20 @@ Requires-Dist: sqlalchemy | ||
| Requires-Dist: seqeval | ||
| Requires-Dist: httpx | ||
| Requires-Dist: ipaddress | ||
| Requires-Dist: netifaces | ||
| # chrisbase | ||
| A base tool for python programming | ||
| Base library for python coding | ||
| ## Installation | ||
| ```bash | ||
| pip install chrisbase | ||
| ``` | ||
| * Install through pip | ||
| ```bash | ||
| pip install chrisbase | ||
| ``` | ||
| ```bash | ||
| git clone https://github.com/chrisjihee/chrisbase | ||
| cd chrisbase | ||
| pip install . | ||
| ``` | ||
| * Install through git | ||
| ```bash | ||
| rm -rf chrisbase* | ||
| git clone git@github.com:chrisjihee/chrisbase.git | ||
| pip install -U -e chrisbase* | ||
| ``` | ||
@@ -57,0 +59,0 @@ ## Reference |
+11
-9
| # chrisbase | ||
| A base tool for python programming | ||
| Base library for python coding | ||
| ## Installation | ||
| ```bash | ||
| pip install chrisbase | ||
| ``` | ||
| * Install through pip | ||
| ```bash | ||
| pip install chrisbase | ||
| ``` | ||
| ```bash | ||
| git clone https://github.com/chrisjihee/chrisbase | ||
| cd chrisbase | ||
| pip install . | ||
| ``` | ||
| * Install through git | ||
| ```bash | ||
| rm -rf chrisbase* | ||
| git clone git@github.com:chrisjihee/chrisbase.git | ||
| pip install -U -e chrisbase* | ||
| ``` | ||
@@ -17,0 +19,0 @@ ## Reference |
+6
-6
| [metadata] | ||
| name = chrisbase | ||
| version = 0.5.3 | ||
| version = 0.5.4 | ||
| author = Jihee Ryu | ||
| author_email = chrisjihee@naver.com | ||
| url = https://github.com/chrisjihee/chrisbase | ||
| description = A base tool for python programming. | ||
| description = Base library for python coding | ||
| long_description = file: README.md | ||
@@ -26,6 +26,7 @@ long_description_content_type = text/markdown | ||
| install_requires = | ||
| typer[all] | ||
| tqdm | ||
| typer | ||
| numpy | ||
| scipy | ||
| httpx | ||
| pandas | ||
@@ -36,2 +37,4 @@ pymongo | ||
| ipynbname | ||
| ipaddress | ||
| netifaces | ||
| matplotlib | ||
@@ -45,5 +48,2 @@ sqlalchemy | ||
| seqeval | ||
| httpx | ||
| ipaddress | ||
| netifaces | ||
@@ -50,0 +50,0 @@ [options.packages.find] |
| Metadata-Version: 2.1 | ||
| Name: chrisbase | ||
| Version: 0.5.3 | ||
| Summary: A base tool for python programming. | ||
| Version: 0.5.4 | ||
| Summary: Base library for python coding | ||
| Home-page: https://github.com/chrisjihee/chrisbase | ||
@@ -17,6 +17,7 @@ Author: Jihee Ryu | ||
| License-File: LICENSE | ||
| Requires-Dist: typer[all] | ||
| Requires-Dist: tqdm | ||
| Requires-Dist: typer | ||
| Requires-Dist: numpy | ||
| Requires-Dist: scipy | ||
| Requires-Dist: httpx | ||
| Requires-Dist: pandas | ||
@@ -27,2 +28,4 @@ Requires-Dist: pymongo | ||
| Requires-Dist: ipynbname | ||
| Requires-Dist: ipaddress | ||
| Requires-Dist: netifaces | ||
| Requires-Dist: matplotlib | ||
@@ -36,21 +39,20 @@ Requires-Dist: sqlalchemy | ||
| Requires-Dist: seqeval | ||
| Requires-Dist: httpx | ||
| Requires-Dist: ipaddress | ||
| Requires-Dist: netifaces | ||
| # chrisbase | ||
| A base tool for python programming | ||
| Base library for python coding | ||
| ## Installation | ||
| ```bash | ||
| pip install chrisbase | ||
| ``` | ||
| * Install through pip | ||
| ```bash | ||
| pip install chrisbase | ||
| ``` | ||
| ```bash | ||
| git clone https://github.com/chrisjihee/chrisbase | ||
| cd chrisbase | ||
| pip install . | ||
| ``` | ||
| * Install through git | ||
| ```bash | ||
| rm -rf chrisbase* | ||
| git clone git@github.com:chrisjihee/chrisbase.git | ||
| pip install -U -e chrisbase* | ||
| ``` | ||
@@ -57,0 +59,0 @@ ## Reference |
@@ -1,5 +0,6 @@ | ||
| typer[all] | ||
| tqdm | ||
| typer | ||
| numpy | ||
| scipy | ||
| httpx | ||
| pandas | ||
@@ -10,2 +11,4 @@ pymongo | ||
| ipynbname | ||
| ipaddress | ||
| netifaces | ||
| matplotlib | ||
@@ -19,4 +22,1 @@ sqlalchemy | ||
| seqeval | ||
| httpx | ||
| ipaddress | ||
| netifaces |
@@ -382,3 +382,3 @@ import json | ||
| inter: int = field(default=10000) | ||
| # total: int = field(default=-1) | ||
| data: Iterable | None = field(default=None) | ||
| file: FileOption | None = field(default=None) | ||
@@ -427,4 +427,5 @@ table: TableOption | None = field(default=None) | ||
| def ready_inputs(self, inputs: Iterable, total: int) -> "InputOption.SingleItems | InputOption.BatchItems": | ||
| inputs = map(self.safe_dict, inputs) | ||
| def ready_inputs(self, inputs: Iterable, total: int, str_to_dict: bool = False) -> "InputOption.SingleItems | InputOption.BatchItems": | ||
| if str_to_dict: | ||
| inputs = map(self.safe_dict, inputs) | ||
| if self.start > 0: | ||
@@ -470,2 +471,4 @@ inputs = islice(inputs, self.start, total) | ||
| max_workers: int = field(default=1) | ||
| calling_sec: float = field(default=0.001) | ||
| waiting_sec: float = field(default=300.0) | ||
| debugging: bool = field(default=False) | ||
@@ -472,0 +475,0 @@ msg_level: int = field(default=logging.INFO) |
+30
-12
@@ -53,5 +53,5 @@ import bz2 | ||
| DEBUG_16: str = ' ┇ '.join(['%(pathname)60s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)16s', '%(message)s']) | ||
| DEBUG_20: str = ' ┇ '.join(['%(pathname)60s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)20s', '%(message)s']) | ||
| DEBUG_24: str = ' ┇ '.join(['%(pathname)60s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)24s', '%(message)s']) | ||
| DEBUG_28: str = ' ┇ '.join(['%(pathname)60s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)28s', '%(message)s']) | ||
| DEBUG_20: str = ' ┇ '.join(['%(pathname)70s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)20s', '%(message)s']) | ||
| DEBUG_24: str = ' ┇ '.join(['%(pathname)70s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)24s', '%(message)s']) | ||
| DEBUG_28: str = ' ┇ '.join(['%(pathname)70s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)28s', '%(message)s']) | ||
| DEBUG_32: str = ' ┇ '.join(['%(pathname)90s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)32s', '%(message)s']) | ||
@@ -243,3 +243,5 @@ DEBUG_36: str = ' ┇ '.join(['%(pathname)90s:%(lineno)-5d', '%(asctime)s', '%(levelname)-8s', '%(name)36s', '%(message)s']) | ||
| def read_or(path): | ||
| def read_or(path: str | Path): | ||
| if not path: | ||
| return None | ||
| path = Path(path) | ||
@@ -249,8 +251,20 @@ return path.read_text() if path.is_file() else None | ||
| def exists_or(path): | ||
| def write_or(path: str | Path, data: str): | ||
| if not path: | ||
| return None | ||
| path = Path(path) | ||
| path.write_text(data) | ||
| return file_size(path) | ||
| def exists_or(path: str | Path): | ||
| if not path: | ||
| return None | ||
| path = Path(path) | ||
| return path if path.exists() else None | ||
| def first_path_or(path): | ||
| def first_path_or(path: str | Path): | ||
| if not path: | ||
| return None | ||
| try: | ||
@@ -263,2 +277,4 @@ return next(iter(paths(path))) | ||
| def first_or(xs): | ||
| if not xs: | ||
| return None | ||
| try: | ||
@@ -452,3 +468,3 @@ return next(iter(xs)) | ||
| def save_json(obj: dict, path: str | Path, **kwargs): | ||
| def save_json(obj: dict | list, path: str | Path, **kwargs): | ||
| file = make_parent_dir(Path(path)) | ||
@@ -594,8 +610,10 @@ with file.open("w") as f: | ||
| def get_hostaddr(default="127.0.0.1") -> str: | ||
| with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as st: | ||
| st.connect(("8.8.8.8", 80)) | ||
| r = first_or(st.getsockname()) | ||
| return r if r else default | ||
| try: | ||
| with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as st: | ||
| st.connect(("8.8.8.8", 80)) | ||
| r = first_or(st.getsockname()) | ||
| return r if r else default | ||
| except OSError: | ||
| return default | ||
| def yield_local_addrs(): | ||
@@ -602,0 +620,0 @@ for inf in netifaces.interfaces(): |
@@ -8,2 +8,3 @@ from __future__ import annotations | ||
| import re | ||
| from concurrent.futures import Future | ||
| from concurrent.futures import ProcessPoolExecutor | ||
@@ -13,2 +14,3 @@ from dataclasses import asdict | ||
| from operator import itemgetter, attrgetter | ||
| from typing import Iterable, Tuple | ||
@@ -112,7 +114,12 @@ import matplotlib.pyplot as plt | ||
| def mask_str(x, mask='*', start=0, end=0): | ||
| if end == 0: | ||
| if start < 0: | ||
| start = max(len(x) + start, 0) | ||
| if end < 0: | ||
| end = max(len(x) + end, 0) | ||
| if end == 0 or end > len(x): | ||
| end = len(x) | ||
| elif end < 0: | ||
| end = max(len(x) + end, 0) | ||
| return x[:start] + mask * max(end - start, 0) + x[end:] | ||
| if start >= end: | ||
| return x | ||
| else: | ||
| return x[:start] + mask * (end - start) + x[end:] | ||
@@ -268,1 +275,18 @@ | ||
| proc.terminate() | ||
| def wait_future_jobs(jobs: Iterable[Tuple[int, Future]], pool: ProcessPoolExecutor, interval: int = 1, timeout=None, debugging: bool = False): # TODO: Remove someday | ||
| for i, job in jobs: | ||
| if debugging: | ||
| job.result(timeout=timeout) | ||
| else: | ||
| try: | ||
| job.result(timeout=timeout) | ||
| except Exception as e: | ||
| logger.warning(f"{type(e)} on job[{i}]({job})") | ||
| if isinstance(jobs, tqdm_std.tqdm): | ||
| if i > 0 and i % interval == 0: | ||
| logger.info(jobs) | ||
| if isinstance(jobs, tqdm_std.tqdm): | ||
| logger.info(jobs) | ||
| terminate_processes(pool) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
67295
2.51%1452
2.98%