Skip to main content

Thư viện hữu ích của Tuấn Anh.

Project description

Giới thiệu

tattools01 là 1 thư viện dùng để ghi tham số vào ổ cứng và một số tiện ích:

  • chuyển đổi markdown sang word: dùng lệnh md2w chạy nó trong cmd, với tham số, xem trong help
  • hướng dẫn tham số, dùng lệnh tact

Tinh năng

1. Mục đích chính

Tạo một base class TactParameters để quản lý parameters cho các module khác nhau, lưu trữ vào file YAML chung .

2. Cách hoạt động

Lần chạy đầu tiên (file YAML chưa tồn tại):

  • Lấy giá trị default từ code
  • Tạo file YAML với các giá trị default

Các lần chạy sau (file YAML đã tồn tại):

  • Đọc giá trị từ file YAML
  • Giá trị trong file YAML là ưu tiên cao nhất (user có thể sửa trực tiếp)
  • Nếu user xóa một key trong file → lấy giá trị default từ code
  • Nếu code thêm key mới → bổ sung vào file với giá trị default
  • Save lại file để đồng bộ

3. Các kiểu dữ liệu cần hỗ trợ

Kiểu Ví dụ Cách access
Scalar self.test1 = "123" obj.test1
List self.myList = [1, 2, 3] obj.myList[0]
Dict thường self.myDict = {"key": "value"} obj.myDict["key"]
Nested class self.Minio = clsMinio() obj.Minio.IP

4. Quy tắc merge (QUAN TRỌNG)

┌─────────────────────────────────────────────────────────────┐
│  Code default    +    File YAML    =    Kết quả cuối       │
├─────────────────────────────────────────────────────────────┤
│  có giá trị           có giá trị       → Dùng FILE         │
│  có giá trị           không có key     → Dùng DEFAULT      │
│  không có             có giá trị       → Dùng FILE         │
└─────────────────────────────────────────────────────────────┘

Deep merge cho nested object:

# Code default:
Minio:
  IP: "192.168.3.42:9000"
  access_key: "admin"
  secret_key: "Proton@2025"

# File YAML (user chỉ sửa IP, xóa secret_key):
Minio:
  IP: "10.0.0.1:9000"
  access_key: "admin"

# Kết quả:
Minio:
  IP: "10.0.0.1:9000"      ← từ file (user sửa)
  access_key: "admin"       ← từ file (giữ nguyên)
  secret_key: "Proton@2025" ← từ default (user xóa → khôi phục)

5. Giữ nguyên TYPE sau khi load

# Trước khi load:
self.myDict = {"key": "value"}      # dict
self.Minio = clsMinio()              # nested class

# Sau khi load từ file:
self.myDict["key"]                   # vẫn access bằng []
self.Minio.IP                        # vẫn access bằng .

6. Nhiều module dùng chung 1 file

# My_Project_Name.yml
Module 01:
    test1: "123"
    myDict: {key1: value1}

Module 02:
    test1: "456"
    test2: "New param"

chatbotAPI:
    Minio:
        IP: "192.168.3.42:9000"

.

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

tatools01-3.0.6.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

tatools01-3.0.6-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file tatools01-3.0.6.tar.gz.

File metadata

  • Download URL: tatools01-3.0.6.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for tatools01-3.0.6.tar.gz
Algorithm Hash digest
SHA256 7d7544dc6531746d068afc75962dafca5a55ec2e4fbe8c0126473dcdf8ab6572
MD5 10326229538bd031816864a18fe93c7f
BLAKE2b-256 15e98ae86c0a4f918b634a3b096e08baed1cc544ca483919685c39d41ea947fb

See more details on using hashes here.

File details

Details for the file tatools01-3.0.6-py3-none-any.whl.

File metadata

  • Download URL: tatools01-3.0.6-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for tatools01-3.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9941eaacff9b2747129953b8bed088204623d9cba5f27671f10c869ae188f841
MD5 0072cd8bec9c66ab6a0dbc919af73147
BLAKE2b-256 52d7573ac4cf33fd75ecd65035b43a13dcf247ae70d454fa7acd69911543d2c4

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