Skip to main content

Some useful tools for Python development by MinWei

Project description

minwei_tools

This tools contain 3 major function

  1. Dotter : Display animated text on screen during long missions
  2. re_result : A Rust-like approach to error handling
  3. server : A file transfer server
  4. us_doc : A uv doc generator

Install

pip install minwei_tools

Usage

  • File Transfer server

    python -m minwei_tools.server -p {port} -h {host}
    

    alt text

  • Dotter

    An example of dotter, DotStyle have many style can use.

    from minwei_tools import Dotter
    from minwei_tools import DotStyle
    from time import sleep
    
    rand_style = DotStyle.random()
    
    with Dotter(message="[*] Normal speed", cycle=rand_style, delay=0.25, show_timer=0) as d:
        d.insert_message("This is a test message 1")
        sleep(1)
        d.insert_message("This is a test message 2")
        sleep(1)
        d.insert_message("This is a test message 3")
        sleep(1)
        d.update_message("[*] Fast spin", delay=0.05)
        sleep(1)
        d.insert_message("This is a test message 4")
        sleep(1)
        d.insert_message("This is a test message 5")
        sleep(1)        
        d.insert_message("This is a test message 6")
        d.update_message("[*] Slow spin", delay=1)
        for i in range(7, 80):
            d.insert_message(f"This is another message {i}", max_str = 10, prefix = "*")
            sleep(0.05)
        d.update_message("[*] Longer msg", delay=0.5)
        for i in range(80, 250):
            d.insert_message(f"This is another message {i}", max_str = 20, prefix = f"🚀{cm.Style.RESET_ALL}{cm.Style.BRIGHT}")
            sleep(0.01)       
        d.update_message("[*] Short msg", delay=0.5)
            
        for i in range(250, 500):
            d.insert_message(f"This is another message {i}", max_str = 3, prefix = f"{cm.Style.RESET_ALL}{cm.Style.BRIGHT}🚀{cm.Style.RESET_ALL}{cm.Style.DIM}")
            sleep(0.01)                           
    

    alt text

    Also support an async dotter

    from time import sleep
    import asyncio
    
    from minwei_tools import AsyncDotter
    
    async def main():
        async with AsyncDotter("Thinking", show_timer=True, delay=0.1):
            await asyncio.sleep(120)
    
    asyncio.run(main())
    
  • rs_result

    from minwei_tools.rs_result import Result, Ok, Err
    
    def devide(a: int, b: int) -> Result[int, str]:
        if b == 0:
            return Err("Division by zero error")
        return Ok(a // b)
    
    """
    >>> result : Result[int, str] = devide(10, 0)
    >>> result.is_ok()
    False
    >>> result.is_err()
    >>> result : Result[int, str] = devide(10, 2)
    >>> result.is_ok()
    True
    >>> result.unwrap()
    5
    """
    
    result : Result[int, str] = devide(10, 0)
    match result:
        case Ok(value):
            print(f"Result: {value}")
        case Err(value):
            print(f"Error: {value}")
            
    result : Result[int, str] = devide(10, 2)
    match result:
        case Ok(value):
            print(f"Result: {value}")
        case Err(value):
            print(f"Error: {value}")
    
  • uv doc

    python -m minwei_tools.uv_doc -p {PROJECT_NAME}
    

    alt text

    -h, --help            show this help message and exit
    -p PROJECT_NAME, --project_name PROJECT_NAME
                            Name of the project. Defaults to the current directory name.
    -o OUTPUT, --output OUTPUT
                            Output file name. Defaults to README.md.
    -d DIRECTORY, --directory DIRECTORY
                            Directory to scan. Defaults to the current working directory.
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minwei_tools-0.1.17.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minwei_tools-0.1.17-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file minwei_tools-0.1.17.tar.gz.

File metadata

  • Download URL: minwei_tools-0.1.17.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for minwei_tools-0.1.17.tar.gz
Algorithm Hash digest
SHA256 7e1995ab730a08d30798ed7466a93a2cd14c34317e0348b8edfe2f98e2ed6346
MD5 df753d5c4601d8455e4a602a1517836f
BLAKE2b-256 a4f7b30fcc3b97ace564d0957131ddc582d5205507e7d907bf385a7c841fefb0

See more details on using hashes here.

File details

Details for the file minwei_tools-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: minwei_tools-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for minwei_tools-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 28b00221b7d0d797278a2d4ddec91e961444a72e3833aee6b3a6c729fd9f3092
MD5 af30c0fa73809d97f37095b90725c4c1
BLAKE2b-256 f3b386a885693589c01bb67a02486828bf9331c0e841e6f3f270aa31b4367887

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page