semvec/pypi-packages huggingface dataset:
qollib 0.1.3
Quality of Life tools library.
Requires Python: >=3.8

# QoLlib

A Quality of Life (QoL) library that accumulates useful tools, hacks and such.

# Usage Examples
All available methods are available from the code documentation. 
Below we only highlight specific use-cases that need a bit more attention. 

Please be also invited to have a look at the unit tests ( `/tests` folder) for further code examples.

## Processing
To run code (quasi-)parallel in multiple processes or threads the `threaded` and `simultaneous` methods 
from the `processing` package remove a lot of overhead. 

Given a method that we want to execute in parallel 
```python
def long_running_calculation(num: float) -> float:
    # omitted for readability 
    pass 
```

we can simply call:
```python
simultaneous(long_running_calculation, [42, 1337, 3.141, 5, 6, 123.456, 1e-6])
```

However, common use case is that the ordering of concurrently generated results is important. 
E.g., when processing individual rows in an image. A simple trick to achieve this is to return a `tuple` from the 
processing method.

```python
import numpy as np 

def rotate_row(data: tuple) -> tuple:
    """
    | 0          | 1             | 2
    | row number | rot mat       | row data
    dat = (row: int,     rot: np.array, stokes: np.array)
    :return: (row: int, rotated_row: np.array)
    """
    rotated = np.zeros_like(data[2]).T
    for col in range(data[2].shape[1]):
        rotated[col] = np.dot(data[1], data[2][:, col])
    return data[0], rotated
```

Once our result is in this form, we can re-establish the ordering after execution by transforming the 
result into a `dict`: 

```python
args = [(row, rot, frame[:, row]) for row in range(frame.shape[1])]
res = dict(simultaneous(rotate_row, args))
rotated = np.array([res[r] for r in range(frame.shape[1])])
```

Also, when working with classes, the executing method must be accessible from outside the instance scope. 
This is best achieved with using `@staticmethod`s. 

```python
class ExampleClass:
    # ... lots of implementation details parallelize  
    @staticmethod
    def parallelize(args):
        pass

simultaneous(ExampleClass.parallelize, args)
```

## Strings
When dealing with user input it is neat to allow users to specify shapes for numpy arrays as strings in 
the common numpy format, e.g., `[13:37, :, 42]`. To extract the `tuple` of `slices` to forward this to numpy 
we provide the `parse_shape(str)` method: 

```python
data = np.arrange(10, 10)
roi = parse_shape('[1,2:4]')
print(data[roi])
#=> [12, 13]
```
youtubi 1.2.3
Download youtube videos

# youtubi

Download youtube videos python library .

# Install  : 
```bash
pip install youtubi
```

## Example : 
### Download single video
```python 

from youtubi import Youtubi

y = Youtubi()
url = "https://youtu.be/oaxWxSdytTk?si=DNJOpBMtJyrmaMQR"
y.get_videos(url , folder = None , filename = None)

```
## Download list of videos of playlist 
copy outter html of page where plylist is shown in the page , then 
```python 
from youtubi import Youtubi 
y = Youtubi()
y.get_playlist(file = "playlist.html")

```

## Download channel videos

```python 
from youtubi import Youtubi
y = Youtubi()
y.get_channel(file = "channel.html")

```
holistics-dbt 0.0.2
Holistics DBT utilities
Requires Python: >=3.8

# Holistics DBT

Generate Holistics data models based on dbt `manifest.json` and `catalogs.json`.

**Supported databases:**
- BigQuery
- (more to come later)

## Install
- `pip install holistics-dbt`

## Usage
- Import the `AmlGen` and `Dbt` classes
- Provide the path to your `manifest.json` and `catalog.json` files
- Run the `AmlGen#gen_table_models` to generate the Holistics data models
- Call `to_s` on each model to get the AML text

```python
from holistics_dbt.aml_gen import AmlGen
from holistics_dbt.dbt import Dbt

dbt = Dbt(
  manifest_path='target/manifest.json',
  catalog_path='target/catalog.json'
)

aml_gen = AmlGen(dbt_artifact=dbt)

table_models = aml_gen.gen_table_models()

for table_model in table_models:
  print(table_model.to_s())
```

Output:
```
Model model_ecommerce_dbt_model_cities {
  type: 'table'
  label: ''
  description: ''
  owner: ''
  data_source_name: 'airy-berm-145910'
  table_name: '`ecommerce`.`model_cities`'

  dimension id {
    type: 'number'
    hidden: false
    definition: @sql {{ #SOURCE.id }};;
    label: 'id'
  }

  dimension name {
    type: 'text'
    hidden: false
    definition: @sql {{ #SOURCE.name }};;
    label: 'name'
  }
}
```

## Customization

The `gen_table_models` return a list of `AmlTableModel` objects which are just plain Python objects. You can see the class definition at [aml_table_model.py](https://github.com/holistics/holistics_dbt/blob/master/holistics_dbt/aml_table_model.py).

Feel free to modify the class to suit your needs, and then call `to_s` to get the AML codes.
promptflow-python-bundle 0.3.0
Allow you to create your own promptflow python base images
Requires Python: <4.0,>=3.8

# Promptflow python image bundle

This bundle package provides a way to use your own base images to build and run promptflow-python,
and build high-quality LLM apps with [prompt flow package](https://pypi.org/project/promptflow).

## Example usage:

```dockerfile
# Choose different python base image
FROM python:3.11

# Required: install runit and procps
RUN apt-get update && apt-get install -y runit procps \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install promptflow-python-bundle
RUN pip install -U promptflow-python-bundle

# Install promptflow to ensure forward compatibility. It will be phased out in the future.
RUN pip install promptflow

# Set port
ENV PORT 8000
EXPOSE $PORT

CMD ["pfapp"]
```

Currently, we only support `Ubuntu` and `Debian` based images, and have verified both [AzureML base images](https://github.com/Azure/AzureML-Containers)
and popular images like `ubuntu:22.04`, `debian:11`, `python:3.10`, `continuumio/miniconda3:23.3.1-0`, `nginx:stable`, etc.

If your base images doesn't have Python or Conda, you need to install it in you docker file as a prerequisite.
loongfei-utils 1.0.8
python工具包
Requires Python: >=3.6

## 工具介绍
```
封装该工具的主要目的是为了方便个人后续的开发过程。
```

## 版本说明
```text
1.0.7 : 修复因Python类变量与实例变量作用域范围引起的数据冲突的bug。
        更新时间：2024 06-24 15:08
1.0.6 : 针对抓取错误的链接，增加重试逻辑，可以指定重试的次数。  
        更新时间：2024 06-24 14:15
       
       
       
```


## 文件结构
```
python-utils/
│
└── loongfei_utils/
   ├── __init__.py        # 将文件夹变为Python包
   ├── M3u8Crawer.py      # 爬取m3u8形式的网上视频，可以控制线程数，需要解密的目前仅支持AES-128
   ├── MultiThreading.py  # 多线程工具类
   └── utils/             # 辅助工具类包
      ├── __init__.py     # 将文件夹变为Python包
      ├── LoggerUtils.py  # 初始化logger日志句柄，用于日志输出
      └── StrUtils.py     # 字符串工具类
      
```
## 工具使用方法
### 一、多线程工具类 MultiThreading
```
举例：
1、获取logger日志句柄
引入：
from loongfei_utils.utils import LoggerUtils
创建logger日志句柄
logger = LoggerUtils.config_only_kzt_logger("info")

2、准备要处理的数据
a = [1,2,3,4,5,6,7,8,9]
b = []

3、定义一个处理数据的方法，这个方法用来处理数据，处理完要返回True 或者 False，以便让多线程工具那些执行失败了
def edit_data(item):
    ac = True
    try:
        if item == 5:
            ac = False
        else:
            b.append(item*5)

    except BaseException as e:
        ac = False
    return ac

4、创建多线程工具类
"""
  多线程工具类ExecuteList，参数如下：
  func : 传入处理数据的方法
  need_execute_list : 需要被处理的数据
  thread_num: 要开启多少线程
  logger: 传入日志句柄，用于多线程日志输出
"""
execute_class = ExecuteList(edit_data,a,5,logger)
# 启动线程
execute_class.start_thread()
# 打印哪些数据处理失败
logger.info(execute_class.getting_error_list())
# 输出处理后b的结果
logger.info(b)

```
### 二、m3u8视频爬取工具类 M3u8Crawer
```
说明：
1、m3u8视频爬取工具类支持非加密类型ts视频的下载，同时也支持加密类型ts视频的下载（目前加密仅支持AES-128）；
2、指定要下载的m3u8文件地址，并指定保存路径，还需要指定保存后的中文名称；
3、本程序采用多线程下载，也需要指定开启的线程数；
4、需要指定下载完成后的视频名字，程序下载完成后会自动合并为指定名字的mp4文件并删除临时的ts文件；
5、需要安装 ffmpeg 工具，用于后期ts文件的合并；
6、程序可以自动判断是否需要解密ts文件。
注：该工具在不断完善中。。。

举例：
1、获取logger日志句柄
引入：
from loongfei_utils.utils import LoggerUtils
创建logger日志句柄，紧进行控制台输出
logger = LoggerUtils.config_only_kzt_logger("info")

2、下载视频
引入：
from loongfei_utils.M3u8Crawer import TSCrawlingToMp4

实例化下载类：
"""
  m3u8工具类TSCrawlingToMp4，参数如下：
  url : 视频对应的m3u8地址
  path : 本地保存地址
  zh_file_name: 视频的保存名字
  logger: 传入日志句柄，用于多线程日志输出
"""
move_crawling = TSCrawlingToMp4(url="https://v.cdnlz7.com/20240427/18107_f7400038/index.m3u8",
                     path="D:/Downloads/view/",
                     zh_file_name="奔跑吧第八季第1期",
                     logger=logger)
# 启动爬取，100为开启100个线程下载ts文件
move_crawling.do_crawling(100)

```
pyfastscreencap 1.0.1
A lightning fast Windows screen recorder that can record up to your monitors refresh rate by leveraging DXCam and ffmpeg
Requires Python: >=3.8

# pyfastscreencap

This is a screen recorder in Python that takes advantage of dxcam and ffmpeg to heavily speed up the screen recording process to reach much higher fps counts than you could otherwise reach.

## Install
`
pip install pyfastscreencap
`
## Example

```python
from pyfastscreencap_tezzary import pyfastscreencap as screencap
from time import sleep

recorder = screencap.Recorder("video.mp4", 0, 120, 50, True)

recorder.start_recording()

sleep(5)

frame_count = recorder.stop_recording()

print(f"Recorded {frame_count} frames")
```

## Limitations

- This screen recorder only works on Windows, this is due to one of its key dependencies [DXCam](https://github.com/ra1nty/DXcam) which only supports Windows due to its low level Windows API usage. This project highly depends on this library due to its blazingly fast screenshot capabilities and any alternatives found currently would seriously degrade performance.

- This screen recorder does not currently record audio but may be used in the future.