Skip to main content

zhige office的个人工具箱

Project description

ZhigeTools

English | 简体中文

Introduction

ZhigeTools is an open-source Python toolkit that provides a collection of utility functions for daily work. It is designed to simplify common tasks by offering easy-to-use wrappers.

Installation

pip install zhigetools

Features

  • Character Conversion Tools

    base_to_number

    • Converts a string to a number, supporting custom bases and custom symbols for the base.
    from zhige_tools.base_converter import base_to_number
    

    number_to_base

    • Converts a number to a string, supporting custom bases and custom symbols for the base.
    from zhige_tools.base_converter import number_to_base
    
  • INI Configuration File Tools

    • Read, write and validate INI configuration files with type checking
    from zhige_tools.ini_reader import read_ini_file, write_ini_file, initialize_ini_file
    
    # Define configuration rules
    rules = {
        'Database': {
            'host': str,
            'port': int,
            'debug': bool
        }
    }
    
    # Initialize with default values
    initialize_ini_file('config.ini', rules, default_values)
    
    # Read configuration
    config = read_ini_file('config.ini')
    
  • Snowflake ID Generator

    • Distributed unique ID generator based on Twitter's Snowflake algorithm
    • Support multiple machine IDs and clock drift correction
    from zhige_tools.snowflake import snowflake_handler
    
    # Initialize (can be used on multiple machines with different machine_ids)
    snowflake_handler.create_snowflake(machine_id=1)
    
    # Generate ID
    new_id = snowflake_handler.get_id(machine_id=1)
    
    # Parse ID
    parsed = snowflake_handler.parse_id(new_id, machine_id=1)
    print(parsed)  # {'timestamp': ..., 'datetime': '2024-02-10 10:30:00', 'machine_id': 1, 'sequence': 0}
    

Changelog

  • 2024.02.10 v0.1.3

    • Added Snowflake ID generator
    • Added INI configuration file tools
  • 2021.10.25 v0.1.1

    • Added function hints, updated README.md
  • 2021.10.25 v0.1.0

    • Initial release

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

zhige_tools-0.1.3.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

zhige_tools-0.1.3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file zhige_tools-0.1.3.tar.gz.

File metadata

  • Download URL: zhige_tools-0.1.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.4rc1

File hashes

Hashes for zhige_tools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1c3920b6c259bd77e048dd15cba2e57e528797ec5cbf22989b995419bb461042
MD5 0d62d9e2def5c148adb56ffc8c529171
BLAKE2b-256 79847b4e6f536b1b295bc9be5fb7fd93c02a39b3d295ab362b8622857e4def29

See more details on using hashes here.

File details

Details for the file zhige_tools-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: zhige_tools-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.4rc1

File hashes

Hashes for zhige_tools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 28db7e1e27d8b63e6cdc0bfb9f23be90cb53bc43ddd23d2c2cd1633a39caea96
MD5 ce4ae7f876340a643d27329fe0c2dc73
BLAKE2b-256 603086e7ea3811cf592f22ba5ace84587942d5ee79c15f979f84a74eca3f50bf

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