Skip to main content

A comprehensive Python utility library for data processing, file handling, database management, and automation tasks

Project description

qufe

A comprehensive Python utility library for data processing, file handling, database management, and automation tasks.

Features

Core Utilities (base)

  • Timestamp handling: Convert timestamps to datetime objects with timezone support
  • Code comparison: Compare code snippets with multiple diff formats (simple, unified, ndiff)
  • Dynamic module import: Import Python modules dynamically from file paths
  • List flattening: Flatten nested lists with configurable depth
  • Dictionary utilities: Flatten three-level nested dictionaries with suffix support

Database Management (dbhandler)

  • PostgreSQL integration: Easy PostgreSQL database connections and queries using SQLAlchemy
  • Database exploration: List databases and tables with metadata
  • Connection management: Automatic connection pooling and cleanup

Text Processing (texthandler, excludebracket)

  • Bracket content removal: Remove content within brackets with validation
  • DokuWiki formatting: Convert lists to DokuWiki table format
  • String search utilities: Find all occurrences of substrings with context
  • Dictionary printing: Pretty-print nested dictionaries with indentation
  • Column formatting: Display lists in multiple columns with alignment

File Operations (filehandler)

  • Directory traversal: Get file lists and directory trees with Unicode normalization
  • Pattern matching: Find latest files based on datetime patterns
  • Pickle operations: Save and load Python objects to/from pickle files
  • Path utilities: Create unique filenames and sanitize file names
  • Content extraction: Extract text content from directory structures

Data Analysis (pdhandler)

  • DataFrame utilities: Convert lists to tuples in pandas DataFrames
  • Column analysis: Compare column names across multiple DataFrames
  • Missing data detection: Find rows and columns with NA or empty values
  • Data validation: Comprehensive data quality checks

Automation & Screen Interaction (interactionhandler)

  • Screen capture: Take screenshots of full screen or specific regions
  • Image processing: Color detection, image comparison, and difference highlighting
  • Mouse automation: Random clicking within regions for automation
  • Progress tracking: Real-time progress updates in Jupyter notebooks
  • Color analysis: Extract and analyze color codes from screen regions

Web Browser Automation (wbhandler)

  • SeleniumBase integration: Enhanced browser automation with custom timeouts
  • Network monitoring: Capture fetch/XHR requests with JavaScript injection
  • Element discovery: Interactive element finding with common attribute detection
  • URL parsing: Extract parameters and values from URLs
  • Multi-browser support: Chrome and Firefox browser implementations

Installation

pip install qufe

Quick Start

Basic Usage

from qufe import base, texthandler, filehandler

# Timestamp handling
ts = base.TS('Asia/Seoul')
formatted_time = ts.get_ts_formatted(1640995200)

# File operations
fh = filehandler.FileHandler()
files = fh.get_tree('/path/to/directory')

# Text processing
texthandler.print_dict({'key': ['value1', 'value2']})

Database Operations

from qufe.dbhandler import PostGreSQLHandler

# Connect to PostgreSQL
db = PostGreSQLHandler('my_database')
databases = db.get_db_list()
tables = db.get_table_list()

Screen Automation

from qufe.interactionhandler import get_sc, display_img

# Capture screen
screenshot = get_sc(100, 100, 800, 600)
display_img(screenshot, is_bgra=True)

Web Browser Automation

from qufe.wbhandler import FireFox

# Start browser session
browser = FireFox()
browser.sb.open('https://example.com')
browser.inject_capture_with_js()
logs = browser.get_capture()
browser.quit_driver()

Requirements

  • Python 3.8+
  • pandas >= 1.3.0
  • numpy >= 1.20.0
  • sqlalchemy >= 1.4.0
  • seleniumbase >= 4.0.0
  • opencv-python >= 4.5.0
  • matplotlib >= 3.3.0
  • pyautogui >= 0.9.50
  • mss >= 6.0.0

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security & Ethics

Database Configuration

For security, database credentials should be provided via environment variables:

export POSTGRES_USER=your_username
export POSTGRES_PASSWORD=your_password
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_DB=your_database

Automation Guidelines

When using screen capture and browser automation features:

  • Respect website terms of service and robots.txt
  • Be mindful of rate limiting and server load
  • Only automate interactions you're authorized to perform
  • Consider privacy implications of screen capture functionality

Web Scraping Ethics

  • Always check and comply with robots.txt
  • Respect rate limits and implement delays
  • Review website terms of service before scraping
  • Be considerate of server resources

Support

If you encounter any problems, please file an issue along with a detailed description.

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

qufe-0.1.2.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

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

qufe-0.1.2-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file qufe-0.1.2.tar.gz.

File metadata

  • Download URL: qufe-0.1.2.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for qufe-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4e4ffa520778fb586f3a0a67231070b5e3c0d5c47fcb4a017cebcf40850c66d1
MD5 9dcdfa8c88ce39aa6f06e4c6535feac0
BLAKE2b-256 122dd865363addd4a12579484ba14ec34c36ca1a59edf23987b5ed2b09b52f34

See more details on using hashes here.

File details

Details for the file qufe-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: qufe-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for qufe-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3432f2eef311a74ca5762ecfcc04e14cd0a11c679418a167f4e77872f13b7b84
MD5 68bb8ea59a3fe34f21539b1819b52935
BLAKE2b-256 4cf8afd62fed863733bb144f070ab644436248e7be2453c260981f7e09c08dda

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