From e4bb201181f9839f9b1a53ae079528234d7f1162 Mon Sep 17 00:00:00 2001 From: despiegk Date: Wed, 20 Aug 2025 04:15:43 +0200 Subject: [PATCH] ... --- README.md | 55 +- herolib.egg-info/PKG-INFO | 54 ++ herolib.egg-info/SOURCES.txt | 145 +-- herolib.egg-info/requires.txt | 1 + herolib.egg-info/top_level.txt | 2 +- {lib => herolib}/__init__.py | 0 herolib/__pycache__/__init__.cpython-313.pyc | Bin 0 -> 177 bytes {lib => herolib}/clients/__init__.py | 0 .../clients/assemblyai/__init__.py | 0 {lib => herolib}/clients/assemblyai/client.py | 0 {lib => herolib}/clients/readme.md | 0 {lib => herolib}/clients/stellar/__init__.py | 0 {lib => herolib}/clients/stellar/horizon.py | 0 {lib => herolib}/clients/stellar/model.py | 0 .../clients/stellar/model_accounts.v | 0 {lib => herolib}/clients/stellar/testnet.py | 0 {lib => herolib}/clients/telegram/__init__.py | 0 {lib => herolib}/clients/telegram/bot.py | 0 .../clients/telegram/bot_audio.py | 0 {lib => herolib}/clients/telegram/bot_text.py | 0 .../clients/telegram/errorqueue.py | 0 {lib => herolib}/clients/vimeo/__init__.py | 0 {lib => herolib}/clients/vimeo/client.py | 0 {lib => herolib}/clients/vimeo/model_video.py | 0 {lib => herolib}/clients/whisper/__init__.py | 0 {lib => herolib}/clients/whisper/convert.py | 0 {lib => herolib}/clients/whisper/whisper.py | 0 {lib => herolib}/clients/wireless/__init__.py | 0 .../clients/wireless/wigle_net.py | 0 {lib => herolib}/core/__init__.py | 0 .../core/__pycache__/__init__.cpython-313.pyc | Bin 0 -> 182 bytes {lib => herolib}/core/heroscript/__init__.py | 0 .../core/heroscript/examples/__init__.py | 0 .../heroscript/examples/heroscript_example.py | 0 .../examples/heroscript_example2.py | 0 .../core/heroscript/examples/wiki/__init__.py | 0 .../core/heroscript/examples/wiki/done.json | 0 .../heroscript/examples/wiki/sub/__init__.py | 0 .../examples/wiki/sub/test file 2.md | 0 .../core/heroscript/examples/wiki/testFile.md | 0 .../core/heroscript/heroaction.py | 0 .../core/heroscript/heroscripts.py | 0 {lib => herolib}/core/heroscript/mixin.py | 0 {lib => herolib}/core/heroscript/readme.md | 0 {lib => herolib}/core/heroscript/tools.py | 0 {lib => herolib}/core/logger/__init__.py | 0 {lib => herolib}/core/logger/factory.py | 4 +- {lib => herolib}/core/logger/log.py | 0 {lib => herolib}/core/logger/log_test.py | 0 {lib => herolib}/core/logger/model.py | 8 +- {lib => herolib}/core/logger/search.py | 6 +- .../core/loghandler}/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin 0 -> 193 bytes .../__pycache__/mylogging.cpython-313.pyc | Bin 0 -> 13463 bytes {lib => herolib}/core/loghandler/mylogging.py | 0 .../core/pathlib}/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin .../core/pathlib/__pycache__}/__init__.py | 0 .../__pycache__/pathlib.cpython-313.pyc | Bin {lib => herolib}/core/pathlib/pathlib.py | 0 .../core/texttools}/__init__.py | 0 {lib => herolib}/core/texttools/texttools.py | 0 .../texttools => herolib/crypt}/__init__.py | 0 {lib/crypt => herolib/crypt/box}/__init__.py | 0 {lib => herolib}/crypt/box/box.py | 0 {lib => herolib}/crypt/box/box_api.py | 0 {lib/crypt/box => herolib/data}/__init__.py | 0 .../data => herolib/data/ourtime}/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin .../data/ourtime/__pycache__}/__init__.py | 0 .../__pycache__/ourtime.cpython-313.pyc | Bin {lib => herolib}/data/ourtime/ourtime.py | 0 .../downloader}/__init__.py | 0 {lib => herolib}/downloader/scrape_dynamic | 0 {lib => herolib}/downloader/scrape_fast | 0 {lib => herolib}/downloader/scrape_scapegraph | 0 {lib/downloader => herolib/tools}/__init__.py | 0 {lib => herolib}/tools/extensions.py | 0 {lib => herolib}/tools/gitscanner.py | 0 {lib => herolib}/tools/logger.py | 0 {lib => herolib}/tools/md5.py | 0 {lib => herolib}/tools/ourtime.py | 0 {lib => herolib}/tools/pathtools.py | 0 {lib => herolib}/tools/texttools.py | 0 {lib/tools => herolib/web}/__init__.py | 0 {lib/web => herolib/web/doctools}/__init__.py | 0 .../web/doctools/html_replacer.py | 0 {lib => herolib}/web/doctools/md_replacer.py | 0 {lib => herolib}/web/doctools/processor.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin 185 -> 0 bytes .../__pycache__/factory.cpython-313.pyc | Bin 561 -> 0 bytes .../logger/__pycache__/model.cpython-313.pyc | Bin 2061 -> 0 bytes lib/core/logger/instructions.md | 822 ------------------ lib/web/doctools/__init__.py | 0 pyproject.toml | 4 +- 95 files changed, 194 insertions(+), 907 deletions(-) create mode 100644 herolib.egg-info/requires.txt rename {lib => herolib}/__init__.py (100%) create mode 100644 herolib/__pycache__/__init__.cpython-313.pyc rename {lib => herolib}/clients/__init__.py (100%) rename {lib => herolib}/clients/assemblyai/__init__.py (100%) rename {lib => herolib}/clients/assemblyai/client.py (100%) rename {lib => herolib}/clients/readme.md (100%) rename {lib => herolib}/clients/stellar/__init__.py (100%) rename {lib => herolib}/clients/stellar/horizon.py (100%) rename {lib => herolib}/clients/stellar/model.py (100%) rename {lib => herolib}/clients/stellar/model_accounts.v (100%) rename {lib => herolib}/clients/stellar/testnet.py (100%) rename {lib => herolib}/clients/telegram/__init__.py (100%) rename {lib => herolib}/clients/telegram/bot.py (100%) rename {lib => herolib}/clients/telegram/bot_audio.py (100%) rename {lib => herolib}/clients/telegram/bot_text.py (100%) rename {lib => herolib}/clients/telegram/errorqueue.py (100%) rename {lib => herolib}/clients/vimeo/__init__.py (100%) rename {lib => herolib}/clients/vimeo/client.py (100%) rename {lib => herolib}/clients/vimeo/model_video.py (100%) rename {lib => herolib}/clients/whisper/__init__.py (100%) rename {lib => herolib}/clients/whisper/convert.py (100%) rename {lib => herolib}/clients/whisper/whisper.py (100%) rename {lib => herolib}/clients/wireless/__init__.py (100%) rename {lib => herolib}/clients/wireless/wigle_net.py (100%) rename {lib => herolib}/core/__init__.py (100%) create mode 100644 herolib/core/__pycache__/__init__.cpython-313.pyc rename {lib => herolib}/core/heroscript/__init__.py (100%) rename {lib => herolib}/core/heroscript/examples/__init__.py (100%) rename {lib => herolib}/core/heroscript/examples/heroscript_example.py (100%) rename {lib => herolib}/core/heroscript/examples/heroscript_example2.py (100%) rename {lib => herolib}/core/heroscript/examples/wiki/__init__.py (100%) rename {lib => herolib}/core/heroscript/examples/wiki/done.json (100%) rename {lib => herolib}/core/heroscript/examples/wiki/sub/__init__.py (100%) rename {lib => herolib}/core/heroscript/examples/wiki/sub/test file 2.md (100%) rename {lib => herolib}/core/heroscript/examples/wiki/testFile.md (100%) rename {lib => herolib}/core/heroscript/heroaction.py (100%) rename {lib => herolib}/core/heroscript/heroscripts.py (100%) rename {lib => herolib}/core/heroscript/mixin.py (100%) rename {lib => herolib}/core/heroscript/readme.md (100%) rename {lib => herolib}/core/heroscript/tools.py (100%) rename {lib => herolib}/core/logger/__init__.py (100%) rename {lib => herolib}/core/logger/factory.py (56%) rename {lib => herolib}/core/logger/log.py (100%) rename {lib => herolib}/core/logger/log_test.py (100%) rename {lib => herolib}/core/logger/model.py (89%) rename {lib => herolib}/core/logger/search.py (95%) rename {lib/core/logger/__pycache__ => herolib/core/loghandler}/__init__.py (100%) create mode 100644 herolib/core/loghandler/__pycache__/__init__.cpython-313.pyc create mode 100644 herolib/core/loghandler/__pycache__/mylogging.cpython-313.pyc rename {lib => herolib}/core/loghandler/mylogging.py (100%) rename {lib/core/loghandler => herolib/core/pathlib}/__init__.py (100%) rename {lib => herolib}/core/pathlib/__pycache__/__init__.cpython-313.pyc (100%) rename {lib/core/pathlib => herolib/core/pathlib/__pycache__}/__init__.py (100%) rename {lib => herolib}/core/pathlib/__pycache__/pathlib.cpython-313.pyc (100%) rename {lib => herolib}/core/pathlib/pathlib.py (100%) rename {lib/core/pathlib/__pycache__ => herolib/core/texttools}/__init__.py (100%) rename {lib => herolib}/core/texttools/texttools.py (100%) rename {lib/core/texttools => herolib/crypt}/__init__.py (100%) rename {lib/crypt => herolib/crypt/box}/__init__.py (100%) rename {lib => herolib}/crypt/box/box.py (100%) rename {lib => herolib}/crypt/box/box_api.py (100%) rename {lib/crypt/box => herolib/data}/__init__.py (100%) rename {lib/data => herolib/data/ourtime}/__init__.py (100%) rename {lib => herolib}/data/ourtime/__pycache__/__init__.cpython-313.pyc (100%) rename {lib/data/ourtime => herolib/data/ourtime/__pycache__}/__init__.py (100%) rename {lib => herolib}/data/ourtime/__pycache__/ourtime.cpython-313.pyc (100%) rename {lib => herolib}/data/ourtime/ourtime.py (100%) rename {lib/data/ourtime/__pycache__ => herolib/downloader}/__init__.py (100%) rename {lib => herolib}/downloader/scrape_dynamic (100%) rename {lib => herolib}/downloader/scrape_fast (100%) rename {lib => herolib}/downloader/scrape_scapegraph (100%) rename {lib/downloader => herolib/tools}/__init__.py (100%) rename {lib => herolib}/tools/extensions.py (100%) rename {lib => herolib}/tools/gitscanner.py (100%) rename {lib => herolib}/tools/logger.py (100%) rename {lib => herolib}/tools/md5.py (100%) rename {lib => herolib}/tools/ourtime.py (100%) rename {lib => herolib}/tools/pathtools.py (100%) rename {lib => herolib}/tools/texttools.py (100%) rename {lib/tools => herolib/web}/__init__.py (100%) rename {lib/web => herolib/web/doctools}/__init__.py (100%) rename {lib => herolib}/web/doctools/html_replacer.py (100%) rename {lib => herolib}/web/doctools/md_replacer.py (100%) rename {lib => herolib}/web/doctools/processor.py (100%) delete mode 100644 lib/core/logger/__pycache__/__init__.cpython-313.pyc delete mode 100644 lib/core/logger/__pycache__/factory.cpython-313.pyc delete mode 100644 lib/core/logger/__pycache__/model.cpython-313.pyc delete mode 100644 lib/core/logger/instructions.md delete mode 100644 lib/web/doctools/__init__.py diff --git a/README.md b/README.md index 83df8d1..2cb9a56 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,57 @@ # herolib_python see also ~/code/git.ourworld.tf/tfgrid_research/tfdev -has some usefull stuff as well \ No newline at end of file +has some usefull stuff as well + +## Installation + +You can install `herolib` directly from the Git repository using `uv pip` (or `pip`): + +```bash +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git +``` + +To install in editable mode for development: + +```bash +uv pip install -e git+https://git.ourworld.tf/herocode/herolib_python.git#egg=herolib +``` + +## Usage + +Once installed, you can import modules from the `herolib` package: + +```python +import herolib.core.loghandler.mylogging +# Or import specific functions/classes +from herolib.core.loghandler.mylogging import MyLogger +``` + +## Version Control + +This library follows standard Git version control practices. Releases can be managed by tagging specific commits in the Git repository. Users installing directly from the Git URL can specify a particular branch, tag, or commit hash to get a specific version. For example: + +```bash +# Install from a specific branch +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git@main + +# Install from a specific tag (e.g., v0.1.0) +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git@v0.1.0 + +# Install from a specific commit hash +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git@ +``` + +## Adding as a Dependency in `pyproject.toml` + +To include `herolib` as a dependency in another Python project that uses `pyproject.toml`, you can add it to the `dependencies` section of your project's `pyproject.toml` file. This is particularly useful for development or when you need to pin to a specific version or branch. + +Example `pyproject.toml` for another project: + +```toml +[project] +name = "my-other-project" +version = "0.1.0" +dependencies = [ + "herolib @ git+https://git.ourworld.tf/herocode/herolib_python.git", +] \ No newline at end of file diff --git a/herolib.egg-info/PKG-INFO b/herolib.egg-info/PKG-INFO index c679a03..4c640c5 100644 --- a/herolib.egg-info/PKG-INFO +++ b/herolib.egg-info/PKG-INFO @@ -5,8 +5,62 @@ Summary: A Python library for HeroCode Author-email: Kilo Code Requires-Python: >=3.8 Description-Content-Type: text/markdown +Requires-Dist: peewee # herolib_python see also ~/code/git.ourworld.tf/tfgrid_research/tfdev has some usefull stuff as well + +## Installation + +You can install `herolib` directly from the Git repository using `uv pip` (or `pip`): + +```bash +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git +``` + +To install in editable mode for development: + +```bash +uv pip install -e git+https://git.ourworld.tf/herocode/herolib_python.git#egg=herolib +``` + +## Usage + +Once installed, you can import modules from the `herolib` package: + +```python +import herolib.core.loghandler.mylogging +# Or import specific functions/classes +from herolib.core.loghandler.mylogging import MyLogger +``` + +## Version Control + +This library follows standard Git version control practices. Releases can be managed by tagging specific commits in the Git repository. Users installing directly from the Git URL can specify a particular branch, tag, or commit hash to get a specific version. For example: + +```bash +# Install from a specific branch +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git@main + +# Install from a specific tag (e.g., v0.1.0) +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git@v0.1.0 + +# Install from a specific commit hash +uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git@ +``` + +## Adding as a Dependency in `pyproject.toml` + +To include `herolib` as a dependency in another Python project that uses `pyproject.toml`, you can add it to the `dependencies` section of your project's `pyproject.toml` file. This is particularly useful for development or when you need to pin to a specific version or branch. + +Example `pyproject.toml` for another project: + +```toml +[project] +name = "my-other-project" +version = "0.1.0" +dependencies = [ + "herolib @ git+https://git.ourworld.tf/herocode/herolib_python.git", +] diff --git a/herolib.egg-info/SOURCES.txt b/herolib.egg-info/SOURCES.txt index 56326b2..77ae16c 100644 --- a/herolib.egg-info/SOURCES.txt +++ b/herolib.egg-info/SOURCES.txt @@ -1,78 +1,79 @@ README.md pyproject.toml +herolib/__init__.py herolib.egg-info/PKG-INFO herolib.egg-info/SOURCES.txt herolib.egg-info/dependency_links.txt +herolib.egg-info/requires.txt herolib.egg-info/top_level.txt -lib/__init__.py -lib/clients/__init__.py -lib/clients/assemblyai/__init__.py -lib/clients/assemblyai/client.py -lib/clients/stellar/__init__.py -lib/clients/stellar/horizon.py -lib/clients/stellar/model.py -lib/clients/stellar/testnet.py -lib/clients/telegram/__init__.py -lib/clients/telegram/bot.py -lib/clients/telegram/bot_audio.py -lib/clients/telegram/bot_text.py -lib/clients/telegram/errorqueue.py -lib/clients/vimeo/__init__.py -lib/clients/vimeo/client.py -lib/clients/vimeo/model_video.py -lib/clients/whisper/__init__.py -lib/clients/whisper/convert.py -lib/clients/whisper/whisper.py -lib/clients/wireless/__init__.py -lib/clients/wireless/wigle_net.py -lib/core/__init__.py -lib/core/heroscript/__init__.py -lib/core/heroscript/heroaction.py -lib/core/heroscript/heroscripts.py -lib/core/heroscript/mixin.py -lib/core/heroscript/tools.py -lib/core/heroscript/examples/__init__.py -lib/core/heroscript/examples/heroscript_example.py -lib/core/heroscript/examples/heroscript_example2.py -lib/core/heroscript/examples/wiki/__init__.py -lib/core/heroscript/examples/wiki/sub/__init__.py -lib/core/logger/__init__.py -lib/core/logger/factory.py -lib/core/logger/log.py -lib/core/logger/log_test.py -lib/core/logger/model.py -lib/core/logger/search.py -lib/core/loghandler/__init__.py -lib/core/loghandler/mylogging.py -lib/core/pathlib/__init__.py -lib/core/pathlib/pathlib.py -lib/core/texttools/__init__.py -lib/core/texttools/texttools.py -lib/crypt/__init__.py -lib/crypt/box/__init__.py -lib/crypt/box/box.py -lib/crypt/box/box_api.py -lib/data/__init__.py -lib/data/ourtime/__init__.py -lib/data/ourtime/ourtime.py -lib/downloader/__init__.py -lib/downloader/scrape_dynamic/dynamic_crawl.py -lib/downloader/scrape_scapegraph/main.py -lib/downloader/scrape_scapegraph/scrape.py -lib/downloader/scrape_scapegraph/scrape_md.py -lib/downloader/scrape_scapegraph/scrape_search.py -lib/downloader/scrape_scapegraph/scrape_with_local_llm.py -lib/downloader/scrape_scapegraph/scrape_with_local_llm_search.py -lib/tools/__init__.py -lib/tools/extensions.py -lib/tools/gitscanner.py -lib/tools/logger.py -lib/tools/md5.py -lib/tools/ourtime.py -lib/tools/pathtools.py -lib/tools/texttools.py -lib/web/__init__.py -lib/web/doctools/__init__.py -lib/web/doctools/html_replacer.py -lib/web/doctools/md_replacer.py -lib/web/doctools/processor.py \ No newline at end of file +herolib/clients/__init__.py +herolib/clients/assemblyai/__init__.py +herolib/clients/assemblyai/client.py +herolib/clients/stellar/__init__.py +herolib/clients/stellar/horizon.py +herolib/clients/stellar/model.py +herolib/clients/stellar/testnet.py +herolib/clients/telegram/__init__.py +herolib/clients/telegram/bot.py +herolib/clients/telegram/bot_audio.py +herolib/clients/telegram/bot_text.py +herolib/clients/telegram/errorqueue.py +herolib/clients/vimeo/__init__.py +herolib/clients/vimeo/client.py +herolib/clients/vimeo/model_video.py +herolib/clients/whisper/__init__.py +herolib/clients/whisper/convert.py +herolib/clients/whisper/whisper.py +herolib/clients/wireless/__init__.py +herolib/clients/wireless/wigle_net.py +herolib/core/__init__.py +herolib/core/heroscript/__init__.py +herolib/core/heroscript/heroaction.py +herolib/core/heroscript/heroscripts.py +herolib/core/heroscript/mixin.py +herolib/core/heroscript/tools.py +herolib/core/heroscript/examples/__init__.py +herolib/core/heroscript/examples/heroscript_example.py +herolib/core/heroscript/examples/heroscript_example2.py +herolib/core/heroscript/examples/wiki/__init__.py +herolib/core/heroscript/examples/wiki/sub/__init__.py +herolib/core/logger/__init__.py +herolib/core/logger/factory.py +herolib/core/logger/log.py +herolib/core/logger/log_test.py +herolib/core/logger/model.py +herolib/core/logger/search.py +herolib/core/loghandler/__init__.py +herolib/core/loghandler/mylogging.py +herolib/core/pathlib/__init__.py +herolib/core/pathlib/pathlib.py +herolib/core/texttools/__init__.py +herolib/core/texttools/texttools.py +herolib/crypt/__init__.py +herolib/crypt/box/__init__.py +herolib/crypt/box/box.py +herolib/crypt/box/box_api.py +herolib/data/__init__.py +herolib/data/ourtime/__init__.py +herolib/data/ourtime/ourtime.py +herolib/downloader/__init__.py +herolib/downloader/scrape_dynamic/dynamic_crawl.py +herolib/downloader/scrape_scapegraph/main.py +herolib/downloader/scrape_scapegraph/scrape.py +herolib/downloader/scrape_scapegraph/scrape_md.py +herolib/downloader/scrape_scapegraph/scrape_search.py +herolib/downloader/scrape_scapegraph/scrape_with_local_llm.py +herolib/downloader/scrape_scapegraph/scrape_with_local_llm_search.py +herolib/tools/__init__.py +herolib/tools/extensions.py +herolib/tools/gitscanner.py +herolib/tools/logger.py +herolib/tools/md5.py +herolib/tools/ourtime.py +herolib/tools/pathtools.py +herolib/tools/texttools.py +herolib/web/__init__.py +herolib/web/doctools/__init__.py +herolib/web/doctools/html_replacer.py +herolib/web/doctools/md_replacer.py +herolib/web/doctools/processor.py \ No newline at end of file diff --git a/herolib.egg-info/requires.txt b/herolib.egg-info/requires.txt new file mode 100644 index 0000000..52b81ee --- /dev/null +++ b/herolib.egg-info/requires.txt @@ -0,0 +1 @@ +peewee diff --git a/herolib.egg-info/top_level.txt b/herolib.egg-info/top_level.txt index a65b417..4292726 100644 --- a/herolib.egg-info/top_level.txt +++ b/herolib.egg-info/top_level.txt @@ -1 +1 @@ -lib +herolib diff --git a/lib/__init__.py b/herolib/__init__.py similarity index 100% rename from lib/__init__.py rename to herolib/__init__.py diff --git a/herolib/__pycache__/__init__.cpython-313.pyc b/herolib/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf0a760e11e7a1b11c8a08a6a4d5d7eab276943f GIT binary patch literal 177 zcmey&%ge<81YufBGeGoX5CH>>P{wB#AY&>+I)f&o-%5reCLr%KNa|LAerR!OQL%nX zYH>kkYI?SQa(+sxetKq!UVdp&d45q&ie5>Yenx6hK3D?8$jMBKFQ_cZ$j<|d1G)O~ q@tJv>P{wB#AY&>+I)f&o-%5reCLr%KNa|LoerR!OQL%nX zYH>kkYI?SQa(+sxetKq!UVdp&d45q&ie5>Yenx6hK3D?8$jMBKFQ_cZ$j<|d1Gzv= uMXCDn@tJv Logger: p = get_dir(path=path, create=True) diff --git a/lib/core/logger/log.py b/herolib/core/logger/log.py similarity index 100% rename from lib/core/logger/log.py rename to herolib/core/logger/log.py diff --git a/lib/core/logger/log_test.py b/herolib/core/logger/log_test.py similarity index 100% rename from lib/core/logger/log_test.py rename to herolib/core/logger/log_test.py diff --git a/lib/core/logger/model.py b/herolib/core/logger/model.py similarity index 89% rename from lib/core/logger/model.py rename to herolib/core/logger/model.py index 3467811..7ec6a8a 100644 --- a/lib/core/logger/model.py +++ b/herolib/core/logger/model.py @@ -1,7 +1,7 @@ from enum import Enum from typing import Optional -from lib.data.ourtime.ourtime import OurTime -from lib.core.pathlib.pathlib import Path +from herolib.data.ourtime.ourtime import OurTime +from herolib.core.pathlib.pathlib import Path class LogType(Enum): STDOUT = "stdout" @@ -15,8 +15,8 @@ class LogItemArgs: self.logtype = logtype import os -from lib.core.texttools.texttools import name_fix, expand, dedent -from lib.data.ourtime.ourtime import OurTime, now as ourtime_now +from herolib.core.texttools.texttools import name_fix, expand, dedent +from herolib.data.ourtime.ourtime import OurTime, now as ourtime_now class Logger: def __init__(self, path: Path, lastlog_time: int = 0): diff --git a/lib/core/logger/search.py b/herolib/core/logger/search.py similarity index 95% rename from lib/core/logger/search.py rename to herolib/core/logger/search.py index a497236..4ac3e81 100644 --- a/lib/core/logger/search.py +++ b/herolib/core/logger/search.py @@ -1,8 +1,8 @@ import os from typing import Optional, List -from lib.core.texttools.texttools import name_fix -from lib.data.ourtime.ourtime import OurTime, new as ourtime_new -from lib.core.logger.model import Logger, LogItem, LogType +from herolib.core.texttools.texttools import name_fix +from herolib.data.ourtime.ourtime import OurTime, new as ourtime_new +from herolib.core.logger.model import Logger, LogItem, LogType class SearchArgs: def __init__(self, timestamp_from: Optional[OurTime] = None, diff --git a/lib/core/logger/__pycache__/__init__.py b/herolib/core/loghandler/__init__.py similarity index 100% rename from lib/core/logger/__pycache__/__init__.py rename to herolib/core/loghandler/__init__.py diff --git a/herolib/core/loghandler/__pycache__/__init__.cpython-313.pyc b/herolib/core/loghandler/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3a6de511989ad1565ae4932ed690575dfc0824a1 GIT binary patch literal 193 zcmey&%ge<81YufBGeGoX5CH>>P{wB#AY&>+I)f&o-%5reCLr%KNa|LCerR!OQL%nX zYH>kkYI?SQa(+sxetKq!UVdp&d45q&ie5>Yenx6hK3D?8$jMBKFQ_cZ$j<|d1Gzv= zMXCBZ`RN&nc_}%mMf&manR%Hd@$q^EmA5!-a`RJ4b5iY!Sb-LT98?Tqd}L;1WGrF^ FvH&ZVG-m(+ literal 0 HcmV?d00001 diff --git a/herolib/core/loghandler/__pycache__/mylogging.cpython-313.pyc b/herolib/core/loghandler/__pycache__/mylogging.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4a28de8d88461c4b5cd0f1ae0695cda2e6b64259 GIT binary patch literal 13463 zcmeHNeQaCTb-(0${QeLnQ6H3KiTbik+oJ5)jx5C=ab(GsY|AO1nK+SBj-s9c z)WTvbwf35QW$J{P*taQ@R#Sp*k48z;ywB-Xt+vg?y?KIu53C;p&4+$6eM~hjh9ZK_hi_@hgtkeOe`B|l< zLO~g!E>>3vba7rp;a}3r_g3hjfl!)GxzedJHMQF+l$Vjm z`NuVMldz5TuIR1YFhcHrn^OI%gzZA5Iv(^?=dJ41_3C>odJVg^xDNd9)(h@bFLxzT zenMl;-W4!TC0l=WI+bfgvrv;7v0A8wl~+OQjkEGX9k!u0LVa)LZmqDHvE=RVJB7oF zXJLdu>G3Xq+ApTNbz7i90~;E zaT@L$jf+wsKymz4_!BwUp-g-%q&6C4Ug`y(Q48XkkpU^qJH9T}5(d?boHhto<1Am1R%h2`gr zv;xu;z>~;&D#qc6L+Xw}850;pjn!WRd6DcOQH`JYux3N>rBEunxR4xuh>)nZ2Std5 z(^~b+qnsZ&;yx%19w4L#SHyy!>oKZnwe6NvLC^y&8RBDs&#Jb|#5KgvsW|J)%ap4r zL95oDE@*(l6Ywafclxy~eVPypaTC9$j(E87`nFi~Ns-1=Ocsv9Ax1-@J05fQgE*ml z(J`+_EAuFIvI&?l9*{&aI&P`&Z>%47*B@=IKjAUTy1+1OzN{Yzi;;dwHVi@z7(q6N zC3R4l3rFJ=$oU|yMhWyv`0L% zWDcI6B12Fwl5!+CgfbXDBXy_**;}dw@(psG-~6doqpP?@fUM}vI_Io&HZ;F$c4)5h zQvz9~KXzRQ7J4Yau=+fZ+o7vh2g;N|m!JdX3XlbPy}%0w$QgT0HDnL#4y!V=wno9! zqM;Vn&Is+ypp-c<8=xiRtWal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pF z4DQp%897RIgPPA?N)RT!Uj=#pAG-~QQ~&?~ diff --git a/lib/core/logger/__pycache__/model.cpython-313.pyc b/lib/core/logger/__pycache__/model.cpython-313.pyc deleted file mode 100644 index 94e3cf7815828317032e78b40ee18ce7143e9b9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2061 zcmaJ?&u<$=6rTOPcI+gOq)pnYF)gSpLN*Fo7zek$=`eXW_IT7``$Mm6pML= zqh3Wz@o`{ZJjnax#{~Sbh@A%h(*o3X|AeSajyk=_N-I`evusMr-eM zd6abg7=3G}2eqgj(DXMxKWJtLWT=cD26xaoVGRa~%RqG%&|DRCR|CVC zSUc=Pu_R;{-N-Ida zQ4oG#X(p|p5=Ok7^x($?;#QgOR}KP5NrF&;C_>ZN$pTa4A;i$}f3SjbM5>ZuOY0kB4Ji{LhbV+cJB z;{BPhT$)k}B^t1T9&sOaB94SEzw$BVadZyX3~nGiW&O2#$MgNA8^?AAH}C#ZkoCnR zrq9oEx{Gf)c_^ZRd4dIkMFgRx95Uu~icw1N2Eh^mk(d!j8N$smP=V7j!V$Yvbz}Y6 zrxy&(^QJT}zL4g3`;Twye}4JhkfvlL+lqFX>VYv8gLiOdrUxunMgFyhv4Nd1V%>BN zutL+Zg^7j29z1^yUle*5wJ8d*kJ3m&kEm`=IKl-JmNTUyvlz?>T#}r=k34jHCX{imAlIAs*VDbm}6f> z56Fu`i#q&zQXb&jKtM%Esq=^w)o`BGE*P2@OG7f!&j_H!Qv{H5X$*+c83IP-M;RI@ zLlebk5)ELv7TBTf!bKz;qEwMVaNO|k>)c$Q;iv|ORP8Es`0 zEskV0;YjxLeac#1PH&=Db#hk{A%*c4EtS{YwGye&5&|klN_!u%3zEq52bnfBX@0w( zNyL)k$d0GCs!l=Z0saL6b(k>m)`~hIkT%6C-n`|O&waY4sk_Hksy3UZi@8iXptU0_ zn|c$alurNv diff --git a/lib/core/logger/instructions.md b/lib/core/logger/instructions.md deleted file mode 100644 index 1af395d..0000000 --- a/lib/core/logger/instructions.md +++ /dev/null @@ -1,822 +0,0 @@ - -/Users/despiegk/code/github/freeflowuniverse/herolib -├── aiprompts -│ └── herolib_core -│ ├── core_ourtime.md -│ ├── core_paths.md -│ └── core_text.md -└── lib - └── core - └── logger - ├── factory.v - ├── log_test.v - ├── log.v - ├── model.v - ├── readme.md - └── search.v - - - - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger/factory.v -```v -module logger - -import freeflowuniverse.herolib.core.pathlib - -pub fn new(path string) !Logger { - mut p := pathlib.get_dir(path: path, create: true)! - return Logger{ - path: p - lastlog_time: 0 - } -} - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger/log_test.v -```v -module logger - -import os -import freeflowuniverse.herolib.data.ourtime -import freeflowuniverse.herolib.core.pathlib - -fn testsuite_begin() { - if os.exists('/tmp/testlogs') { - os.rmdir_all('/tmp/testlogs')! - } -} - -fn test_logger() { - mut logger := new('/tmp/testlogs')! - - // Test stdout logging - logger.log(LogItemArgs{ - cat: 'test-app' - log: 'This is a test message\nWith a second line\nAnd a third line' - logtype: .stdout - timestamp: ourtime.new('2022-12-05 20:14:35')! - })! - - // Test error logging - logger.log(LogItemArgs{ - cat: 'error-test' - log: 'This is an error\nWith details' - logtype: .error - timestamp: ourtime.new('2022-12-05 20:14:35')! - })! - - logger.log(LogItemArgs{ - cat: 'test-app' - log: 'This is a test message\nWith a second line\nAnd a third line' - logtype: .stdout - timestamp: ourtime.new('2022-12-05 20:14:36')! - })! - - logger.log(LogItemArgs{ - cat: 'error-test' - log: ' - This is an error - - With details - ' - logtype: .error - timestamp: ourtime.new('2022-12-05 20:14:36')! - })! - - logger.log(LogItemArgs{ - cat: 'error-test' - log: ' - aaa - - bbb - ' - logtype: .error - timestamp: ourtime.new('2022-12-05 22:14:36')! - })! - - logger.log(LogItemArgs{ - cat: 'error-test' - log: ' - aaa2 - - bbb2 - ' - logtype: .error - timestamp: ourtime.new('2022-12-05 22:14:36')! - })! - - // Verify log directory exists - assert os.exists('/tmp/testlogs'), 'Log directory should exist' - - // Get log file - files := os.ls('/tmp/testlogs')! - assert files.len == 2 - - mut file := pathlib.get_file( - path: '/tmp/testlogs/${files[0]}' - create: false - )! - - content := file.read()!.trim_space() - - items_stdout := logger.search( - timestamp_from: ourtime.new('2022-11-1 20:14:35')! - timestamp_to: ourtime.new('2025-11-1 20:14:35')! - logtype: .stdout - )! - assert items_stdout.len == 2 - - items_error := logger.search( - timestamp_from: ourtime.new('2022-11-1 20:14:35')! - timestamp_to: ourtime.new('2025-11-1 20:14:35')! - logtype: .error - )! - assert items_error.len == 4 -} - -fn testsuite_end() { - // if os.exists('/tmp/testlogs') { - // os.rmdir_all('/tmp/testlogs')! - // } -} - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger/log.v -```v -module logger - -import os -import freeflowuniverse.herolib.core.texttools -import freeflowuniverse.herolib.data.ourtime - -@[params] -pub struct LogItemArgs { -pub mut: - timestamp ?ourtime.OurTime - cat string - log string - logtype LogType -} - -pub fn (mut l Logger) log(args_ LogItemArgs) ! { - mut args := args_ - - t := args.timestamp or { - t2 := ourtime.now() - t2 - } - - // Format category (max 10 chars, ascii only) - args.cat = texttools.name_fix(args.cat) - if args.cat.len > 10 { - return error('category cannot be longer than 10 chars') - } - args.cat = texttools.expand(args.cat, 10, ' ') - - args.log = texttools.dedent(args.log).trim_space() - - mut logfile_path := '${l.path.path}/${t.dayhour()}.log' - - // Create log file if it doesn't exist - if !os.exists(logfile_path) { - os.write_file(logfile_path, '')! - l.lastlog_time = 0 // make sure we put time again - } - - mut f := os.open_append(logfile_path)! - - mut content := '' - - // Add timestamp if we're in a new second - if t.unix() > l.lastlog_time { - content += '\n${t.time().format_ss()}\n' - l.lastlog_time = t.unix() - } - - // Format log lines - error_prefix := if args.logtype == .error { 'E' } else { ' ' } - lines := args.log.split('\n') - - for i, line in lines { - if i == 0 { - content += '${error_prefix} ${args.cat} - ${line}\n' - } else { - content += '${error_prefix} ${line}\n' - } - } - f.writeln(content.trim_space_right())! - f.close() -} - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger/model.v -```v -module logger - -import freeflowuniverse.herolib.data.ourtime -import freeflowuniverse.herolib.core.pathlib - -@[heap] -pub struct Logger { -pub mut: - path pathlib.Path - lastlog_time i64 // to see in log format, every second we put a time down, we need to know if we are in a new second (logs can come in much faster) -} - -pub struct LogItem { -pub mut: - timestamp ourtime.OurTime - cat string - log string - logtype LogType -} - -pub enum LogType { - stdout - error -} - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger/readme.md -```md -# Logger Module - -A simple logging system that provides structured logging with search capabilities. - -Logs are stored in hourly files with a consistent format that makes them both human-readable and machine-parseable. - -## Features - -- Structured logging with categories and error types -- Automatic timestamp management -- Multi-line message support -- Search functionality with filtering options -- Human-readable log format - -## Usage - -```v -import freeflowuniverse.herolib.core.logger -import freeflowuniverse.herolib.data.ourtime - -// Create a new logger -mut l := logger.new(path: '/var/logs')! - -// Log a message -l.log( - cat: 'system', - log: 'System started successfully', - logtype: .stdout -)! - -// Log an error -l.log( - cat: 'system', - log: 'Failed to connect\nRetrying in 5 seconds...', - logtype: .error -)! - -// Search logs -results := l.search( - timestamp_from: ourtime.now().warp("-24h"), // Last 24 hours - cat: 'system', // Filter by category - log: 'failed', // Search in message content - logtype: .error, // Only error messages - maxitems: 100 // Limit results -)! -``` - -## Log Format - -Each log file is named using the format `YYYY-MM-DD-HH.log` and contains entries in the following format: - -``` -21:23:42 - system - This is a normal log message - system - This is a multi-line message - second line with proper indentation - third line maintaining alignment -E error_cat - This is an error message -E second line of error -E third line of error -``` - -### Format Rules - -- Time stamps (HH:MM:SS) are written once per second when the log time changes -- Categories are: - - Limited to 10 characters maximum - - Padded with spaces to exactly 10 characters - - Any `-` in category names are converted to `_` -- Each line starts with either: - - ` ` (space) for normal logs (LogType.stdout) - - `E` for error logs (LogType.error) -- Multi-line messages maintain consistent indentation (14 spaces after the prefix) - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger/search.v -```v -module logger - -import os -import freeflowuniverse.herolib.core.texttools -import freeflowuniverse.herolib.data.ourtime - -@[params] -pub struct SearchArgs { -pub mut: - timestamp_from ?ourtime.OurTime - timestamp_to ?ourtime.OurTime - cat string // can be empty - log string // any content in here will be looked for - logtype LogType - maxitems int = 10000 -} - -pub fn (mut l Logger) search(args_ SearchArgs) ![]LogItem { - mut args := args_ - - // Format category (max 10 chars, ascii only) - args.cat = texttools.name_fix(args.cat) - if args.cat.len > 10 { - return error('category cannot be longer than 10 chars') - } - - mut timestamp_from := args.timestamp_from or { ourtime.OurTime{} } - mut timestamp_to := args.timestamp_to or { ourtime.OurTime{} } - - // Get time range - from_time := timestamp_from.unix() - to_time := timestamp_to.unix() - if from_time > to_time { - return error('from_time cannot be after to_time: ${from_time} < ${to_time}') - } - - mut result := []LogItem{} - - // Find log files in time range - mut files := os.ls(l.path.path)! - files.sort() - - for file in files { - if !file.ends_with('.log') { - continue - } - - // Parse dayhour from filename - dayhour := file[..file.len - 4] // remove .log - file_time := ourtime.new(dayhour)! - mut current_time := ourtime.OurTime{} - mut current_item := LogItem{} - mut collecting := false - - // Skip if file is outside time range - if file_time.unix() < from_time || file_time.unix() > to_time { - continue - } - - // Read and parse log file - content := os.read_file('${l.path.path}/${file}')! - lines := content.split('\n') - - for line in lines { - if result.len >= args.maxitems { - return result - } - - line_trim := line.trim_space() - if line_trim == '' { - continue - } - - // Check if this is a timestamp line - if !(line.starts_with(' ') || line.starts_with('E')) { - current_time = ourtime.new(line_trim)! - if collecting { - process(mut result, current_item, current_time, args, from_time, to_time)! - } - collecting = false - continue - } - - if collecting && line.len > 14 && line[13] == `-` { - process(mut result, current_item, current_time, args, from_time, to_time)! - collecting = false - } - - // Parse log line - is_error := line.starts_with('E') - if !collecting { - // Start new item - current_item = LogItem{ - timestamp: current_time - cat: line[2..12].trim_space() - log: line[15..].trim_space() - logtype: if is_error { .error } else { .stdout } - } - // println('new current item: ${current_item}') - collecting = true - } else { - // Continuation line - if line_trim.len < 16 { - current_item.log += '\n' - } else { - current_item.log += '\n' + line[15..] - } - } - } - - // Add last item if collecting - if collecting { - process(mut result, current_item, current_time, args, from_time, to_time)! - } - } - - return result -} - -fn process(mut result []LogItem, current_item LogItem, current_time ourtime.OurTime, args SearchArgs, from_time i64, to_time i64) ! { - // Add previous item if it matches filters - log_epoch := current_item.timestamp.unix() - if log_epoch < from_time || log_epoch > to_time { - return - } - if (args.cat == '' || current_item.cat.trim_space() == args.cat) - && (args.log == '' || current_item.log.contains(args.log)) - && args.logtype == current_item.logtype { - result << current_item - } -} - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/aiprompts/herolib_core/core_ourtime.md -```md -# OurTime Module - -The `OurTime` module in V provides flexible time handling, supporting relative and absolute time formats, Unix timestamps, and formatting utilities. - -## Key Features -- Create time objects from strings or current time -- Relative time expressions (e.g., `+1h`, `-2d`) -- Absolute time formats (e.g., `YYYY-MM-DD HH:mm:ss`) -- Unix timestamp conversion -- Time formatting and warping - -## Basic Usage - -```v -import freeflowuniverse.herolib.data.ourtime - -// Current time -mut t := ourtime.now() - -// From string -t2 := ourtime.new('2022-12-05 20:14:35')! - -// Get formatted string -println(t2.str()) // e.g., 2022-12-05 20:14 - -// Get Unix timestamp -println(t2.unix()) // e.g., 1670271275 -``` - -## Time Formats - -### Relative Time - -Use `s` (seconds), `h` (hours), `d` (days), `w` (weeks), `M` (months), `Q` (quarters), `Y` (years). - -```v -// Create with relative time -mut t := ourtime.new('+1w +2d -4h')! - -// Warp existing time -mut t2 := ourtime.now() -t2.warp('+1h')! -``` - -### Absolute Time - -Supports `YYYY-MM-DD HH:mm:ss`, `YYYY-MM-DD HH:mm`, `YYYY-MM-DD HH`, `YYYY-MM-DD`, `DD-MM-YYYY`. - -```v -t1 := ourtime.new('2022-12-05 20:14:35')! -t2 := ourtime.new('2022-12-05')! // Time defaults to 00:00:00 -``` - -## Methods Overview - -### Creation - -```v -now_time := ourtime.now() -from_string := ourtime.new('2023-01-15')! -from_epoch := ourtime.new_from_epoch(1673788800) -``` - -### Formatting - -```v -mut t := ourtime.now() -println(t.str()) // YYYY-MM-DD HH:mm -println(t.day()) // YYYY-MM-DD -println(t.key()) // YYYY_MM_DD_HH_mm_ss -println(t.md()) // Markdown format -``` - -### Operations - -```v -mut t := ourtime.now() -t.warp('+1h')! // Move 1 hour forward -unix_ts := t.unix() -is_empty := t.empty() -``` - -## Error Handling - -Time parsing methods return a `Result` type and should be handled with `!` or `or` blocks. - -```v -t_valid := ourtime.new('2023-01-01')! -t_invalid := ourtime.new('bad-date') or { - println('Error: ${err}') - ourtime.now() // Fallback -} - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/aiprompts/herolib_core/core_paths.md -```md -# Pathlib Usage Guide - -## Overview - -The pathlib module provides a comprehensive interface for handling file system operations. Key features include: - -- Robust path handling for files, directories, and symlinks -- Support for both absolute and relative paths -- Automatic home directory expansion (~) -- Recursive directory operations -- Path filtering and listing -- File and directory metadata access - -## Basic Usage - -### Importing pathlib -```v -import freeflowuniverse.herolib.core.pathlib -``` - -### Creating Path Objects -```v -// Create a Path object for a file -mut file_path := pathlib.get("path/to/file.txt") - -// Create a Path object for a directory -mut dir_path := pathlib.get("path/to/directory") -``` - -### Basic Path Operations -```v -// Get absolute path -abs_path := file_path.absolute() - -// Get real path (resolves symlinks) -real_path := file_path.realpath() - -// Check if path exists -if file_path.exists() { - // Path exists -} -``` - -## Path Properties and Methods - -### Path Types -```v -// Check if path is a file -if file_path.is_file() { - // Handle as file -} - -// Check if path is a directory -if dir_path.is_dir() { - // Handle as directory -} - -// Check if path is a symlink -if file_path.is_link() { - // Handle as symlink -} -``` - -### Path Normalization -```v -// Normalize path (remove extra slashes, resolve . and ..) -normalized_path := file_path.path_normalize() - -// Get path directory -dir_path := file_path.path_dir() - -// Get path name without extension -name_no_ext := file_path.name_no_ext() -``` - -## File and Directory Operations - -### File Operations -```v -// Write to file -file_path.write("Content to write")! - -// Read from file -content := file_path.read()! - -// Delete file -file_path.delete()! -``` - -### Directory Operations -```v -// Create directory -mut dir := pathlib.get_dir( - path: "path/to/new/dir" - create: true -)! - -// List directory contents -mut dir_list := dir.list()! - -// Delete directory -dir.delete()! -``` - -### Symlink Operations -```v -// Create symlink -file_path.link("path/to/symlink", delete_exists: true)! - -// Resolve symlink -real_path := file_path.realpath() -``` - -## Advanced Operations - -### Path Copying -```v -// Copy file to destination -file_path.copy(dest: "path/to/destination")! -``` - -### Recursive Operations -```v -// List directory recursively -mut recursive_list := dir.list(recursive: true)! - -// Delete directory recursively -dir.delete()! -``` - -### Path Filtering -```v -// List files matching pattern -mut filtered_list := dir.list( - regex: [r".*\.txt$"], - recursive: true -)! -``` - -## Best Practices - -### Error Handling -```v -if file_path.exists() { - // Safe to operate -} else { - // Handle missing file -} -``` - - -``` - -File: /Users/despiegk/code/github/freeflowuniverse/herolib/aiprompts/herolib_core/core_text.md -```md -# TextTools Module - -The `texttools` module provides a comprehensive set of utilities for text manipulation and processing. - -## Functions and Examples: - -```v -import freeflowuniverse.herolib.core.texttools - -assert hello_world == texttools.name_fix("Hello World!") - -``` -### Name/Path Processing -* `name_fix(name string) string`: Normalizes filenames and paths. -* `name_fix_keepspace(name string) !string`: Like name_fix but preserves spaces. -* `name_fix_no_ext(name_ string) string`: Removes file extension. -* `name_fix_snake_to_pascal(name string) string`: Converts snake_case to PascalCase. - ```v - name := texttools.name_fix_snake_to_pascal("hello_world") // Result: "HelloWorld" - ``` -* `snake_case(name string) string`: Converts PascalCase to snake_case. - ```v - name := texttools.snake_case("HelloWorld") // Result: "hello_world" - ``` -* `name_split(name string) !(string, string)`: Splits name into site and page components. - - -### Text Cleaning -* `name_clean(r string) string`: Normalizes names by removing special characters. - ```v - name := texttools.name_clean("Hello@World!") // Result: "HelloWorld" - ``` -* `ascii_clean(r string) string`: Removes all non-ASCII characters. -* `remove_empty_lines(text string) string`: Removes empty lines from text. - ```v - text := texttools.remove_empty_lines("line1\n\nline2\n\n\nline3") // Result: "line1\nline2\nline3" - ``` -* `remove_double_lines(text string) string`: Removes consecutive empty lines. -* `remove_empty_js_blocks(text string) string`: Removes empty code blocks (```...```). - -### Command Line Parsing -* `cmd_line_args_parser(text string) ![]string`: Parses command line arguments with support for quotes and escaping. - ```v - args := texttools.cmd_line_args_parser("'arg with spaces' --flag=value") // Result: ['arg with spaces', '--flag=value'] - ``` -* `text_remove_quotes(text string) string`: Removes quoted sections from text. -* `check_exists_outside_quotes(text string, items []string) bool`: Checks if items exist in text outside of quotes. - -### Text Expansion -* `expand(txt_ string, l int, expand_with string) string`: Expands text to a specified length with a given character. - -### Indentation -* `indent(text string, prefix string) string`: Adds indentation prefix to each line. - ```v - text := texttools.indent("line1\nline2", " ") // Result: " line1\n line2\n" - ``` -* `dedent(text string) string`: Removes common leading whitespace from every line. - ```v - text := texttools.dedent(" line1\n line2") // Result: "line1\nline2" - ``` - -### String Validation -* `is_int(text string) bool`: Checks if text contains only digits. -* `is_upper_text(text string) bool`: Checks if text contains only uppercase letters. - -### Multiline Processing -* `multiline_to_single(text string) !string`: Converts multiline text to a single line with proper escaping. - -### Text Splitting -* `split_smart(t string, delimiter_ string) []string`: Intelligent string splitting that respects quotes. - -### Tokenization -* `tokenize(text_ string) TokenizerResult`: Tokenizes text into meaningful parts. -* `text_token_replace(text string, tofind string, replacewith string) !string`: Replaces tokens in text. - -### Version Parsing -* `version(text_ string) int`: Converts version strings to comparable integers. - ```v - ver := texttools.version("v0.4.36") // Result: 4036 - ver = texttools.version("v1.4.36") // Result: 1004036 - ``` - -### Formatting -* `format_rfc1123(t time.Time) string`: Formats a time.Time object into RFC 1123 format. - - -### Array Operations -* `to_array(r string) []string`: Converts a comma or newline separated list to an array of strings. - ```v - text := "item1,item2,item3" - array := texttools.to_array(text) // Result: ['item1', 'item2', 'item3'] - ``` -* `to_array_int(r string) []int`: Converts a text list to an array of integers. -* `to_map(mapstring string, line string, delimiter_ string) map[string]string`: Intelligent mapping of a line to a map based on a template. - ```v - r := texttools.to_map("name,-,-,-,-,pid,-,-,-,-,path", - "root 304 0.0 0.0 408185328 1360 ?? S 16Dec23 0:34.06 /usr/sbin/distnoted") - // Result: {'name': 'root', 'pid': '1360', 'path': '/usr/sbin/distnoted'} - ``` - -``` - - -create a module in python in location lib/core/logger in herolib_python -which reimplements /Users/despiegk/code/github/freeflowuniverse/herolib/lib/core/logger -all features need to be reimplemented - - -write me an implementation plan for my coding agent - \ No newline at end of file diff --git a/lib/web/doctools/__init__.py b/lib/web/doctools/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyproject.toml b/pyproject.toml index 9445434..4e19fcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ authors = [ ] readme = "README.md" requires-python = ">=3.8" -dependencies = [] +dependencies = ["peewee"] [build-system] requires = ["setuptools>=61.0"] @@ -15,4 +15,4 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] where = ["."] -include = ["lib*"] \ No newline at end of file +include = ["herolib*"] \ No newline at end of file