Skip to main content

This package implements tools to build python package and tools.

Project description

PythonToolsKit logo

PythonToolsKit

Description

This package implements useful tools and functions for producing python packages or tools implemented in python.

Features implemented:

  • Timeout:
    • Timeout decorator using MultiThreading
    • Timeout decorator using MultiProcessing
    • Timeout decorator using signal (UNIX only)
  • Terminal: ANSI features for terminal (color, position of the cursor, style...)
  • StringF:
    • Format the strings length
    • Make a table from Sequence of strings
    • Make a table of Attribute/Value from python object
  • PrintF:
    • Print states of tasks/programs
    • Print info, check OK/NOK, error... with prefix and color management
  • Process: generator to read process output lines in real time
  • Logs
    • Default logger builder
    • Decorator trace function (log the beginning and end of function execution)
    • Colored logger (StreamHandler only)
    • CSV formatter (logs in CSV format)
    • Handler for compressed log file rotation and store indefinitely
  • GetPass: a getpass function showing "*"
  • Encodings:
    • Generator to obtain probable encodings
    • Function to try to decode the data with probable encodings
    • Fast Base64 functions (without types/regex checks)
  • DictObject:
    • Dynamic object (build from dict)
    • JsonDeserializer
    • CsvDeserializer
  • Report:
    • Report as text/markdown
    • Report as CSV
    • Report as JSON
    • Report as HTML
    • Statistics
    • Sort and filter elements in the reports
    • The frequency and percentage of filtered elements
  • urlopen:
    • New urlopen based on urllib.request with a easiest way to manage HTTP error code (using decorator)
  • Dict:
    • Clean dict (for example, after loading the API response, you want to keep only certain informations)
    • Operator (some basic functions callable from operator)
  • List:
    • Operator (some basic functions callable from operator)
  • Tuple:
    • Operator (some basic functions callable from operator)
  • Function:
    • Operator (some basic functions callable from operator)
  • Arguments:
    • Password and password prompt
    • Input file and stdin
    • Output file and stdout
    • Verbose mode
    • Debug mode
  • Thread:
    • Join all
    • Class SimpleThread
    • Thread decorator
  • Import:
    • import from path/filename
  • GetFile:
    • Research an existant file from current directory and lib directory
    • Open an existant file from current directory or lib directory
  • ScapyTools:
    • Command line arguments for scapy (ArgumentParser with an optional argument "interface" by default and iface research)
  • GetType
    • Type string value (None, bool, int, float, IP)
    • Numbers (int, float) and IP/network generator from string
  • Random: Get random strings (random length, generator, check for strong password, secure, urlsafe, ...)
  • Json:
    • Load invalid JSON
    • Correct invalid JSON
  • WindowsTerminal:
    • Activate/desactivate temporary/persistent virtual terminal (colors, font, ...) on Windows
    • Set temporary/persistent terminal transparency on Windows
  • Colors:
    • Build 8bits-color byte
    • Get 3 bytes color from HTML/CSS colors (#HEX, rgb function and rgba function)
    • Check and safe methods are available for all these features

Requirements

This package require:

  • python3
  • python3 Standard Library

Installation

pip install PythonToolsKit

Usages

Examples with responses (mode console) are available in HTML documentation.

Note for import: add PythonToolsKit.<module>

from PythonToolsKit.Timeout import *
import PythonToolsKit.Timeout

Unittests

For GetType and Json, Encodings, Colors and WindowsTerminal modules i use doctest (unittests in documentation) and coverage:

python3 GetType.py             # run doctest with verbose mode
python3 -m doctest GetType.py  # run doctest without verbose mode
coverage run GetType.py        # Calcul coverage
coverage report                # Report in console
coverage html                  # Report in HTML page
Module Coverage Statements missing
GetType.py 100% 130 000
Json.py 100% 46 000
Encodings.py 100% 54 000
WindowsTerminal.py 94% 96 006
Colors.py 100% 176 000

Links

Licence

Licensed under the GPL, version 3.

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

PythonToolsKit-1.0.6.tar.gz (53.6 kB view hashes)

Uploaded Source

Supported by

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