pylib-0xe


Namepylib-0xe JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryYet Another Python Library
upload_time2025-01-02 00:37:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12.3
licenseThe MIT License (MIT) Copyright © 2023 <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords library asynchrone database messaging reader writer data structures config reader json reader json writer json repository geometry math decorators
VCS
bugtrack_url
requirements annotated-types greenlet pika pydantic pydantic_core python-ulid SQLAlchemy typing_extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center" style="display: block; font-size: 2.5em; font-weight: bold; margin-block-start: 1em; margin-block-end: 1em;">
<a name="logo" href="#"><img align="center" src="https://github.com/shamir0xe/pylib/blob/main/assets/logos/pylib.png?raw=true" alt="pylib" style="width:100%;height:100%"/></a>
<br/><br/><strong>pylib</strong>
</h1>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
![Python](https://img.shields.io/badge/Python-3.12%2B-blue)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)

A python library that helps writing py projects much easier and faster.

## Table of contents

This library covers multiple aspects, including:

<!--toc:start-->

- [Table of contents](#table-of-contents)
- [Installation](#installation)
- [Documentation](#documentation)
  - [I. Config](#i-config)
    - [Usage Example](#usage-example)
    - [Default Values](#default-values)
    - [Reading Environment Configurations](#reading-environment-configurations)
  - [II. Database](#ii-database)
    - [Registering a Database Engine](#registering-a-database-engine)
    - [Using Database Sessions](#using-database-sessions)
    - [Using the Repository Facade](#using-the-repository-facade)
  - [III. Rabbit-MQ Messaging](#iii-rabbit-mq-messaging)
    - [Establishing an Async Connection](#establishing-an-async-connection)
    - [Server Side: Listening to a Queue](#server-side-listening-to-a-queue)
    - [Client Side: Sending Messages](#client-side-sending-messages)
  - [IV. Json](#iv-json)
  - [V. Buffer IO](#v-buffer-io)
  - [VI. Data Structures](#vi-data-structures)
  - [VII. File](#vii-file)
  - [VIII. Path](#viii-path)
  - [IX. Argument](#ix-argument)
  - [X. String](#x-string)
  - [XI. Math](#xi-math)

## Installation

You can simply install this library through pip, via following commad:

```shell
python3 -m pip install pylib-0xe
```

## Documentation

### I. Config

The [`Config`](config/config) facade simplifies reading hierarchical JSON config files. Here's how it works:

#### Usage Example
Assume you have several `.json` config files or folders with configurations under the `configs` directory. To access the `humans.male.height` attribute from `mammals.json`, use the following code:

```python
Config.read('mammals.humans.male.height')
```

#### Default Values
You can specify a default value if the attribute is not found:

```python
Config.read(..., default=180)
```

#### Reading Environment Configurations
The `read_env` property looks for an `env.json` file in the project's directory hierarchy. Once found, it searches for the specified pattern. For example, to access `db.postgres.password`, use:

```python
Config.read_env('db.postgres.password')
```

---

### II. Database

The `Database` facade provides convenient methods for interacting with databases using SQLAlchemy. Follow these steps to set it up:

#### Registering a Database Engine
First, register your database engine with the `EngineMediator`:

```python
from pylib_0xe.database.mediators.engine_mediator import EngineMediator
from pylib_0xe.database.engines.postgres_engine import PostgresEngine

# Register the Postgres engine
EngineMediator().register(DatabaseTypes.I, PostgresEngine().engine)
```

This associates `DatabaseTypes.I` with the SQLAlchemy engine.

> **Note:** Ensure your `env.json` contains the `db.postgres` configuration:

```json
{
  "db": {
    "postgres": {
      "host": "127.0.0.1",
      "port": 1234,
      "user": "",
      "password": "",
      "db": "",
      "test_db": ""
    }
  }
}
```

---

#### Using Database Sessions
You can inject database sessions into functions using the `@db_session` decorator:

```python
from typing import Optional
from sqlalchemy import Session
from pylib_0xe.decorators.db_session import db_session
from pylib_0xe.types.database_types import DatabaseTypes

@db_session(DatabaseTypes.I)
def fn(session: Optional[Session] = None):
    session.query(...)
```

---

#### Using the Repository Facade
Alternatively, use the [`Repository`](repositories/repository.py) facade for simplified CRUD operations:

```python
from pylib_0xe.repositories.repository import Repository
from src.models.user import User

# 'User' should be a SQLAlchemy model inheriting from DecoratedBase
# 'DecoratedBase' is located in pylib_0xe.database.decorated_base

user = Repository(User).read_by_id("123456")
```


### III. Rabbit-MQ Messaging

The `Messaging` facade simplifies creating robust RabbitMQ-based messaging projects. It consists of two main components:

1. **Server Side**
2. **Client Side**

> **Note:** Ensure the `message_broker` section is included in your `env.json` file for full functionality:
> ```json
> {
>   "message_broker": {
>     "host": "127.0.0.1:5672",
>     "url": "amqp://127.0.0.1:5672"
>   }
> }
> ```

Both server and client components support asynchronous and blocking connections. Below, we illustrate examples for the **asynchronous** connection.

---

#### Establishing an Async Connection
Use the `inject_async_connection` decorator to create and inject an async RabbitMQ connection:

```python
from pylib_0xe.decorators.inject_async_connection import inject_async_connection
from pylib_0xe.messaging.rpc.rpc_async_connection import RpcAsyncConnection

@inject_async_connection
def main(connection: Optional[RpcAsyncConnection] = None):
    pass
```

This decorator creates an async connection and injects it into the `main` function.

---

#### Server Side: Listening to a Queue
On the server side, create a RabbitMQ queue, listen to it, and invoke a callback function when a job is received:

```python
from pylib_0xe.messaging.rpc.rpc_async_server import RpcAsyncServer
from pylib_0xe.asynchrone.get_or_create_event_loop import GetOrCreateEventLoop

# Define the callback function
def resolver(*args, **kwargs):
    pass

@inject_async_connection
def main(connection: Optional[RpcAsyncConnection]):
    # Create the server instance
    RpcAsyncServer(
        routing_key="some-random-q",
        connection=connection,
        query_handler=resolver,
    )

    # Start the event loop
    GetOrCreateEventLoop().get_or_create().run_forever()
```

This setup ensures that the server listens for messages on the specified `routing_key` and processes them using the `resolver` function.

---

#### Client Side: Sending Messages
On the client side, send a message to a specific queue using the `ClientCaller` class:

```python
from pylib_0xe.messaging.client.client_caller import ClientCaller

async def fn():
    return await ClientCaller(
        client_name="some-random-q",
        rpc_connection=connection,
    ).call(input={"query": "generate", "payload": ...})
```

The `ClientCaller` sends a message to the `some-random-q` queue and waits for a response asynchronously.

### IV. Json

This facade class helps you operate `get` and `set` operations on a json file. Two main functions are:


1)  [`selector_get_value`](json/json_helper.py)
1)  [`selector_set_value`](json/json_helper.py)

It supports selecting by array indexes (__i) and wild-cards (*) for both `set` and `get` methods.
```json
{
  "a": {
    "b": {
      "c": {
        "f": "g"
      }
    },
    "d": [1, 2],
    "e": {},
    "f": [{"g": 123}, {"k": 3}]
  }
}
```

```python
json_file = File.read_json('file.json')
JsonHelper.selector_get_value(json_file, 'a.b.c.f') # g
JsonHelper.selector_get_value(json_file, 'a.d') # [1, 2]
JsonHelper.selector_set_value(json_file, 'a.f.*.r', 5) # "f": [{"g": 123, "r": 5}, {"k": 3, "r": 5}]
JsonHelper.selector_set_value(json_file, 'a.d.__2', 5) # "d": [1, 5],
```
### V. Buffer IO

This module provides several ways to read, write and edit buffers.
You can define `file`, `str` and `standard-input` buffers.

- [Buffer](buffer_io/buffer.py)
- [BufferReader](buffer_io/buffer_reader.py)
- [BufferWriter](buffer_io/buffer_writer.py)
- [StandardInputBuffer](buffer_io/standard_input_buffer.py)
- [StandardOutputBuffer](buffer_io/standard_output_buffer.py)
- [FileBuffer](buffer_io/file_buffer.py)
- [StringBuffer](buffer_io/string_buffer.py)

for example you can simply read a whole file like this:

```python
reader = BufferReader(FileBuffer(file_path, "r+"))
while not reader.end_of_buffer():
    line = reader.next_line()
```

or you can define a string as a buffer and treat it in the same way:

```python
reader = BufferReader(StringBuffer('some awesome text'))
while not reader.end_of_buffer():
    a, b, c = reader.next_int(), reader.next_string(), reader.next_char()
```

you can also read from `standard_input` and write to `standard_output`
in this way:

```python
reader = BufferReader(StandardInputBuffer())
writer = BufferWriter(StandardOutputBuffer())
while not reader.end_of_buffer():
    a, b, c = reader.next_int(), reader.next_string(), reader.next_char()
    writer.write_line(f"We have recieved these: ({a}, {b}, {c})")
```

### VI. Data Structures
### VII. File

- [File](file/file.py): A class that contains some useful
  functions to deal with files. Some of them are:
  - `read_json(file_path)`
  - `read_csv(file_path)`
  - `append_to_file(file_path, string)`
  - `get_all_files(directory_path, extension)`



### VIII. Path

- [PathHelper](path/path_helper.py):
  Provides absolute pathing for the project. Then you can
  use releative pathing after reaching the project root. As an example:

```python
path = PathHelper.from_root(__file__, 'assets', 'imgs', '1.png')
```

It will construct the path from the root of the project to the desired file,
for this specific example, the file should be accessible under this path:
`$project_root/assets/imgs/1.png`.
This function tries to go back from `__file__` directory to reach the `root`
directory. The default root directories are `src` and `root`. You can
specify the root directory name by passing the `root_name=YOUR_ROOT_DIR_NAME`
as a kwarg.
Then the above example could be rewritten as something like this:

```python
path = PathHelper.from_root(..., root_name="custom_name")
```

The best practice to use it with the custom root directory is to write a new PathHelper
class that extends `PathHelper` and apply your custom `root_name` to it. You can
also get rid of `__file__` argument in this way. It should be implemented
something like this:

```python
from pylib_0xe.path.path_helper import PathHelper as PH


class PathHelper(PH):
  @classmethod
  def root(cls, *path: str) -> str:
    return cls.from_root(__file__, *path, root_name="custom_name")
```

### IX. Argument

- [ArgumentParser](argument/argument_parser.py):
  Useful tool to reading arguments passed to a python program executed via command line interface (terminal).
  for example if you run your program as follow:

```terminal
python3 main.py --color green --size 2 --fast --O2
```

you can access the arguments through:

```python
ArgumentParser.get_value('color') -> green
ArgumentParser.get_value('size') -> 2
ArgumentParser.is_option('O2') -> true
```

### X. String

- [StringHelper](string/string_helper.py)
- [HashGenerator](string/hash_generator.py)
- [GenerateId](string/generate_id.py)



### XI. Math

- [Geometry](algorithms/math/geometry.py): A neat implemented 2d-geometry
  library. Some of the usefull functions that it provides are:
  - `translate(expression, *points)`: recieves arithmatic expression and
    the points afterwards. Returns the answer of the expression. example:
    `translate('* + *.', p1, p2, p3, scalar)` = `((p1 * p2) + p3) *. scalar`
  - `side_sign(p1, p2, p3)`: Returns in which side of the p1->p2 line, p3 is located.
  - `inside_polygon(points, p)`
  - `segment_intersection(l1, l2)`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pylib-0xe",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12.3",
    "maintainer_email": null,
    "keywords": "library, asynchrone, database, messaging, reader, writer, data structures, config reader, json reader, json writer, json, repository, geometry, math, decorators",
    "author": null,
    "author_email": "shamir0xe <shamir0xe@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a6/5d/704332dd3b3b62c029a25848f0cb8131b84e50156396b7f2870e8be09723/pylib_0xe-0.1.3.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\" style=\"display: block; font-size: 2.5em; font-weight: bold; margin-block-start: 1em; margin-block-end: 1em;\">\n<a name=\"logo\" href=\"#\"><img align=\"center\" src=\"https://github.com/shamir0xe/pylib/blob/main/assets/logos/pylib.png?raw=true\" alt=\"pylib\" style=\"width:100%;height:100%\"/></a>\n<br/><br/><strong>pylib</strong>\n</h1>\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n![Python](https://img.shields.io/badge/Python-3.12%2B-blue)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\nA python library that helps writing py projects much easier and faster.\n\n## Table of contents\n\nThis library covers multiple aspects, including:\n\n<!--toc:start-->\n\n- [Table of contents](#table-of-contents)\n- [Installation](#installation)\n- [Documentation](#documentation)\n  - [I. Config](#i-config)\n    - [Usage Example](#usage-example)\n    - [Default Values](#default-values)\n    - [Reading Environment Configurations](#reading-environment-configurations)\n  - [II. Database](#ii-database)\n    - [Registering a Database Engine](#registering-a-database-engine)\n    - [Using Database Sessions](#using-database-sessions)\n    - [Using the Repository Facade](#using-the-repository-facade)\n  - [III. Rabbit-MQ Messaging](#iii-rabbit-mq-messaging)\n    - [Establishing an Async Connection](#establishing-an-async-connection)\n    - [Server Side: Listening to a Queue](#server-side-listening-to-a-queue)\n    - [Client Side: Sending Messages](#client-side-sending-messages)\n  - [IV. Json](#iv-json)\n  - [V. Buffer IO](#v-buffer-io)\n  - [VI. Data Structures](#vi-data-structures)\n  - [VII. File](#vii-file)\n  - [VIII. Path](#viii-path)\n  - [IX. Argument](#ix-argument)\n  - [X. String](#x-string)\n  - [XI. Math](#xi-math)\n\n## Installation\n\nYou can simply install this library through pip, via following commad:\n\n```shell\npython3 -m pip install pylib-0xe\n```\n\n## Documentation\n\n### I. Config\n\nThe [`Config`](config/config) facade simplifies reading hierarchical JSON config files. Here's how it works:\n\n#### Usage Example\nAssume you have several `.json` config files or folders with configurations under the `configs` directory. To access the `humans.male.height` attribute from `mammals.json`, use the following code:\n\n```python\nConfig.read('mammals.humans.male.height')\n```\n\n#### Default Values\nYou can specify a default value if the attribute is not found:\n\n```python\nConfig.read(..., default=180)\n```\n\n#### Reading Environment Configurations\nThe `read_env` property looks for an `env.json` file in the project's directory hierarchy. Once found, it searches for the specified pattern. For example, to access `db.postgres.password`, use:\n\n```python\nConfig.read_env('db.postgres.password')\n```\n\n---\n\n### II. Database\n\nThe `Database` facade provides convenient methods for interacting with databases using SQLAlchemy. Follow these steps to set it up:\n\n#### Registering a Database Engine\nFirst, register your database engine with the `EngineMediator`:\n\n```python\nfrom pylib_0xe.database.mediators.engine_mediator import EngineMediator\nfrom pylib_0xe.database.engines.postgres_engine import PostgresEngine\n\n# Register the Postgres engine\nEngineMediator().register(DatabaseTypes.I, PostgresEngine().engine)\n```\n\nThis associates `DatabaseTypes.I` with the SQLAlchemy engine.\n\n> **Note:** Ensure your `env.json` contains the `db.postgres` configuration:\n\n```json\n{\n  \"db\": {\n    \"postgres\": {\n      \"host\": \"127.0.0.1\",\n      \"port\": 1234,\n      \"user\": \"\",\n      \"password\": \"\",\n      \"db\": \"\",\n      \"test_db\": \"\"\n    }\n  }\n}\n```\n\n---\n\n#### Using Database Sessions\nYou can inject database sessions into functions using the `@db_session` decorator:\n\n```python\nfrom typing import Optional\nfrom sqlalchemy import Session\nfrom pylib_0xe.decorators.db_session import db_session\nfrom pylib_0xe.types.database_types import DatabaseTypes\n\n@db_session(DatabaseTypes.I)\ndef fn(session: Optional[Session] = None):\n    session.query(...)\n```\n\n---\n\n#### Using the Repository Facade\nAlternatively, use the [`Repository`](repositories/repository.py) facade for simplified CRUD operations:\n\n```python\nfrom pylib_0xe.repositories.repository import Repository\nfrom src.models.user import User\n\n# 'User' should be a SQLAlchemy model inheriting from DecoratedBase\n# 'DecoratedBase' is located in pylib_0xe.database.decorated_base\n\nuser = Repository(User).read_by_id(\"123456\")\n```\n\n\n### III. Rabbit-MQ Messaging\n\nThe `Messaging` facade simplifies creating robust RabbitMQ-based messaging projects. It consists of two main components:\n\n1. **Server Side**\n2. **Client Side**\n\n> **Note:** Ensure the `message_broker` section is included in your `env.json` file for full functionality:\n> ```json\n> {\n>   \"message_broker\": {\n>     \"host\": \"127.0.0.1:5672\",\n>     \"url\": \"amqp://127.0.0.1:5672\"\n>   }\n> }\n> ```\n\nBoth server and client components support asynchronous and blocking connections. Below, we illustrate examples for the **asynchronous** connection.\n\n---\n\n#### Establishing an Async Connection\nUse the `inject_async_connection` decorator to create and inject an async RabbitMQ connection:\n\n```python\nfrom pylib_0xe.decorators.inject_async_connection import inject_async_connection\nfrom pylib_0xe.messaging.rpc.rpc_async_connection import RpcAsyncConnection\n\n@inject_async_connection\ndef main(connection: Optional[RpcAsyncConnection] = None):\n    pass\n```\n\nThis decorator creates an async connection and injects it into the `main` function.\n\n---\n\n#### Server Side: Listening to a Queue\nOn the server side, create a RabbitMQ queue, listen to it, and invoke a callback function when a job is received:\n\n```python\nfrom pylib_0xe.messaging.rpc.rpc_async_server import RpcAsyncServer\nfrom pylib_0xe.asynchrone.get_or_create_event_loop import GetOrCreateEventLoop\n\n# Define the callback function\ndef resolver(*args, **kwargs):\n    pass\n\n@inject_async_connection\ndef main(connection: Optional[RpcAsyncConnection]):\n    # Create the server instance\n    RpcAsyncServer(\n        routing_key=\"some-random-q\",\n        connection=connection,\n        query_handler=resolver,\n    )\n\n    # Start the event loop\n    GetOrCreateEventLoop().get_or_create().run_forever()\n```\n\nThis setup ensures that the server listens for messages on the specified `routing_key` and processes them using the `resolver` function.\n\n---\n\n#### Client Side: Sending Messages\nOn the client side, send a message to a specific queue using the `ClientCaller` class:\n\n```python\nfrom pylib_0xe.messaging.client.client_caller import ClientCaller\n\nasync def fn():\n    return await ClientCaller(\n        client_name=\"some-random-q\",\n        rpc_connection=connection,\n    ).call(input={\"query\": \"generate\", \"payload\": ...})\n```\n\nThe `ClientCaller` sends a message to the `some-random-q` queue and waits for a response asynchronously.\n\n### IV. Json\n\nThis facade class helps you operate `get` and `set` operations on a json file. Two main functions are:\n\n\n1)  [`selector_get_value`](json/json_helper.py)\n1)  [`selector_set_value`](json/json_helper.py)\n\nIt supports selecting by array indexes (__i) and wild-cards (*) for both `set` and `get` methods.\n```json\n{\n  \"a\": {\n    \"b\": {\n      \"c\": {\n        \"f\": \"g\"\n      }\n    },\n    \"d\": [1, 2],\n    \"e\": {},\n    \"f\": [{\"g\": 123}, {\"k\": 3}]\n  }\n}\n```\n\n```python\njson_file = File.read_json('file.json')\nJsonHelper.selector_get_value(json_file, 'a.b.c.f') # g\nJsonHelper.selector_get_value(json_file, 'a.d') # [1, 2]\nJsonHelper.selector_set_value(json_file, 'a.f.*.r', 5) # \"f\": [{\"g\": 123, \"r\": 5}, {\"k\": 3, \"r\": 5}]\nJsonHelper.selector_set_value(json_file, 'a.d.__2', 5) # \"d\": [1, 5],\n```\n### V. Buffer IO\n\nThis module provides several ways to read, write and edit buffers.\nYou can define `file`, `str` and `standard-input` buffers.\n\n- [Buffer](buffer_io/buffer.py)\n- [BufferReader](buffer_io/buffer_reader.py)\n- [BufferWriter](buffer_io/buffer_writer.py)\n- [StandardInputBuffer](buffer_io/standard_input_buffer.py)\n- [StandardOutputBuffer](buffer_io/standard_output_buffer.py)\n- [FileBuffer](buffer_io/file_buffer.py)\n- [StringBuffer](buffer_io/string_buffer.py)\n\nfor example you can simply read a whole file like this:\n\n```python\nreader = BufferReader(FileBuffer(file_path, \"r+\"))\nwhile not reader.end_of_buffer():\n    line = reader.next_line()\n```\n\nor you can define a string as a buffer and treat it in the same way:\n\n```python\nreader = BufferReader(StringBuffer('some awesome text'))\nwhile not reader.end_of_buffer():\n    a, b, c = reader.next_int(), reader.next_string(), reader.next_char()\n```\n\nyou can also read from `standard_input` and write to `standard_output`\nin this way:\n\n```python\nreader = BufferReader(StandardInputBuffer())\nwriter = BufferWriter(StandardOutputBuffer())\nwhile not reader.end_of_buffer():\n    a, b, c = reader.next_int(), reader.next_string(), reader.next_char()\n    writer.write_line(f\"We have recieved these: ({a}, {b}, {c})\")\n```\n\n### VI. Data Structures\n### VII. File\n\n- [File](file/file.py): A class that contains some useful\n  functions to deal with files. Some of them are:\n  - `read_json(file_path)`\n  - `read_csv(file_path)`\n  - `append_to_file(file_path, string)`\n  - `get_all_files(directory_path, extension)`\n\n\n\n### VIII. Path\n\n- [PathHelper](path/path_helper.py):\n  Provides absolute pathing for the project. Then you can\n  use releative pathing after reaching the project root. As an example:\n\n```python\npath = PathHelper.from_root(__file__, 'assets', 'imgs', '1.png')\n```\n\nIt will construct the path from the root of the project to the desired file,\nfor this specific example, the file should be accessible under this path:\n`$project_root/assets/imgs/1.png`.\nThis function tries to go back from `__file__` directory to reach the `root`\ndirectory. The default root directories are `src` and `root`. You can\nspecify the root directory name by passing the `root_name=YOUR_ROOT_DIR_NAME`\nas a kwarg.\nThen the above example could be rewritten as something like this:\n\n```python\npath = PathHelper.from_root(..., root_name=\"custom_name\")\n```\n\nThe best practice to use it with the custom root directory is to write a new PathHelper\nclass that extends `PathHelper` and apply your custom `root_name` to it. You can\nalso get rid of `__file__` argument in this way. It should be implemented\nsomething like this:\n\n```python\nfrom pylib_0xe.path.path_helper import PathHelper as PH\n\n\nclass PathHelper(PH):\n  @classmethod\n  def root(cls, *path: str) -> str:\n    return cls.from_root(__file__, *path, root_name=\"custom_name\")\n```\n\n### IX. Argument\n\n- [ArgumentParser](argument/argument_parser.py):\n  Useful tool to reading arguments passed to a python program executed via command line interface (terminal).\n  for example if you run your program as follow:\n\n```terminal\npython3 main.py --color green --size 2 --fast --O2\n```\n\nyou can access the arguments through:\n\n```python\nArgumentParser.get_value('color') -> green\nArgumentParser.get_value('size') -> 2\nArgumentParser.is_option('O2') -> true\n```\n\n### X. String\n\n- [StringHelper](string/string_helper.py)\n- [HashGenerator](string/hash_generator.py)\n- [GenerateId](string/generate_id.py)\n\n\n\n### XI. Math\n\n- [Geometry](algorithms/math/geometry.py): A neat implemented 2d-geometry\n  library. Some of the usefull functions that it provides are:\n  - `translate(expression, *points)`: recieves arithmatic expression and\n    the points afterwards. Returns the answer of the expression. example:\n    `translate('* + *.', p1, p2, p3, scalar)` = `((p1 * p2) + p3) *. scalar`\n  - `side_sign(p1, p2, p3)`: Returns in which side of the p1->p2 line, p3 is located.\n  - `inside_polygon(points, p)`\n  - `segment_intersection(l1, l2)`\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT) Copyright \u00a9 2023 <copyright holders>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Yet Another Python Library",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/shamir0xe/pylib"
    },
    "split_keywords": [
        "library",
        " asynchrone",
        " database",
        " messaging",
        " reader",
        " writer",
        " data structures",
        " config reader",
        " json reader",
        " json writer",
        " json",
        " repository",
        " geometry",
        " math",
        " decorators"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64ca7a9f0ba47fe5a0d96cd665acaafc6ce36549d576346d3f489f075c6f8aa2",
                "md5": "a07de70733100929fba48ad7b83af43a",
                "sha256": "6ed6c362a2a769ef9ef8dd2378a25a8a5b3db9573aa37762d8eef255d9e6be3d"
            },
            "downloads": -1,
            "filename": "pylib_0xe-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a07de70733100929fba48ad7b83af43a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12.3",
            "size": 63531,
            "upload_time": "2025-01-02T00:37:04",
            "upload_time_iso_8601": "2025-01-02T00:37:04.766526Z",
            "url": "https://files.pythonhosted.org/packages/64/ca/7a9f0ba47fe5a0d96cd665acaafc6ce36549d576346d3f489f075c6f8aa2/pylib_0xe-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a65d704332dd3b3b62c029a25848f0cb8131b84e50156396b7f2870e8be09723",
                "md5": "340500fd27a9fc5d5ee71e81d82f82ae",
                "sha256": "84d0e92d1cf0751731c824f5865ce4152d4be59934d3341d875cbf9dacd91f9e"
            },
            "downloads": -1,
            "filename": "pylib_0xe-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "340500fd27a9fc5d5ee71e81d82f82ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12.3",
            "size": 44794,
            "upload_time": "2025-01-02T00:37:14",
            "upload_time_iso_8601": "2025-01-02T00:37:14.505591Z",
            "url": "https://files.pythonhosted.org/packages/a6/5d/704332dd3b3b62c029a25848f0cb8131b84e50156396b7f2870e8be09723/pylib_0xe-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-02 00:37:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shamir0xe",
    "github_project": "pylib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "annotated-types",
            "specs": [
                [
                    "==",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "greenlet",
            "specs": [
                [
                    "==",
                    "3.1.1"
                ]
            ]
        },
        {
            "name": "pika",
            "specs": [
                [
                    "==",
                    "1.3.2"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.10.3"
                ]
            ]
        },
        {
            "name": "pydantic_core",
            "specs": [
                [
                    "==",
                    "2.27.1"
                ]
            ]
        },
        {
            "name": "python-ulid",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "SQLAlchemy",
            "specs": [
                [
                    "==",
                    "2.0.36"
                ]
            ]
        },
        {
            "name": "typing_extensions",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        }
    ],
    "lcname": "pylib-0xe"
}
        
Elapsed time: 0.63280s