Skip to content

FileSystemPro 3.0.0.0

Latest

Choose a tag to compare

@hbisneto hbisneto released this 12 Nov 03:31
4bdfd0b

FileSystemPro 3.0.0.0 represents a comprehensive evolution of the library, fusing enhanced file and directory manipulation with advanced monitoring, compression unification, and a pioneering Device suite for hardware telemetry—all while introducing fluent console styling, dynamic configuration, and metadata-rich utilities. This release amplifies cross-platform resilience with timestamp precision, batch integrity checks, event-driven watching, and optional psutil diagnostics, empowering developers to craft scalable automations, CLI masterpieces, and resource-savvy applications. Layered configs, async updates, and backward-compatible APIs ensure seamless upgrades, delivering a lightweight yet potent toolkit under MIT terms for unrestricted deployment on Windows, macOS, and Linux.

Console

  • Revolutionary Console class enables chainable formatting: console.red().underline().light_green_bg()("Alert!") applies colors (standard/light foregrounds/backgrounds like black(), light_blue_bg()), styles (bright(), dim()), and new effects (underline(), strikethrough()) with auto-reset on invocation to eliminate bleed.

  • Global console singleton for zero-boilerplate use, alongside explicit resets (reset_underline(), reset_strikethrough()) for granular control in complex outputs.

  • ANSI expansions in ansi.py add codes for underlines (4) and strikethroughs (9, resets 24/29); Win32 tweaks in winterm.py leverage COMMON_LVB_UNDERSCORE/STRIKEOUT for legacy console fidelity.

  • Stream wrapping (init() with autoreset) now handles extended styles efficiently, with optimizations to curb flicker in high-throughput logging.

Core Configuration & Updates

  • Multi-tier config orchestration: Defaults merge with .env (CWD/home, JSON toggles), env vars, and config.json via load_config(); save_config() persists runtime mods like cache limits instantly.

  • Logging overhaul: Auto-init on import with levels (DEBUG/INFO/WARNING/ERROR) via set_logging_level(), supplanting prints for traceable production flows.

  • Performance knobs: set_performance_cache_size(1024) tunes memory for ops; get_config() yields immutable copies for safe reads.

  • Toggle system: toggle_feature('experimental_features') flips nested flags, expandable via .env for low-risk testing.

  • Async updater: check_updates_async() threads GitHub queries with callbacks, digit-based version diffs, and console alerts (e.g., blue notices, green tags); configurable update_checker_enabled with timeouts/logs.

File

  • I/O suite: Text/binary append()/read()/write() with lines/all-at-once modes, encoding/buffers; new append_all_bytes(), write_all_bytes()/text(), read_all_bytes()/text() for bulk streams.

  • Integrity arsenal: calculate_checksum()/check_integrity() batch to batch_check_integrity() dirs (logs/results dicts); find_duplicates() hashes paths, generate_integrity_report() JSON-exports summaries; SHA-256 save/load utils.

  • Metadata extractors: get_extension(), get_filename(), get_size() (raw/formatted "1.5 MB"), mode perms; recursive enumerate_files() yields sizes/timestamps, list() arrays paths.

  • CRUD depth: copy()/move() singles/lists with overwrites/metadata preserve; rename()/delete() pre-checks/logs booleans; symlink creation, exists() symlink-aware.

  • Timestamps: Local/UTC get/set_creation/access/last_write_time() (datetime/str "YYYY-MM-DD HH:MM:SS"); auto-conversions, utime() Unix fallbacks, access-time neutral writes.

  • Splitting: split_file()/reassemble_file() chunk-configurable (1 MB default), auto-deletes parts; recursive batch scans with progress.

Directory

  • Path builders: combine()/join() multi-segments with absolute validation/separators; extractors get_parent()/name(), resolve() dereferences symlinks.

  • Lifecycle: Recursive create() metadata-returns; create_temp_subdirectory() auto-clean; create_symbolic_link(); delete() recursive/prompted logs.

  • Scans: Glob get_files/directories/entries() ("TopDirectoryOnly"/"AllDirectories"), iterators; list() extensible metadata.

  • Checks: Dir-specific exists(); recursive get_size() (bytes/"2.5 GB") with progress.

  • Timestamps: Full get/set_*_time() local/UTC (datetime/str), timezone-aware, utime() approximations, error-raised formats/perms.

  • Relocation: move() move_root/overwrite/content modes, metadata returns; rename() checks/booleans, shutil cross-device.

  • Viz & context: get_tree() strings (├──, ignores .git/pycache/node_modules); global current_directory get/set() auto-tracks.

Watcher

  • Watcher multi-root initialization with max_depth, filters (ignore_patterns=['.git'], file_extensions=['.py']); poll() threads delays.

  • Events: register_handler('updated', fn) for 'created/updated/removed'/'all', Queue-pushed async.

  • Detection: Filtered os.walk() diffs mod times/sizes, timestamped; change_history (history_size) enables get_stats() counts.

  • Standalone: get_changes() notifiers/logs, extensible sans class.

  • Queue robustness: Empty safe-polls, no-lost changes; filtered walks/pruning for performance.

Wrapper

  • get_object() dicts: Absolute paths, formatted timestamps ("YYYY/MM/DD HH:MM:SS:ff" access/created/modified), flags (exists/is_dir/file/link), names/exts, recursive sizes.

  • Auto file/dir handling, exceptions (FileNotFound/Permission); single-pass I/O min.

  • has_extension() string booleans, edge-documented (dotfiles/no-ext).

  • Helpers: os.stat/utime cross-operating system, raw-to-string timestamps (no -1 placeholders).

  • Size progression: Formatted from bytes to TB ("1.2 KB"), walk-recursive directories.

Compression

  • Tar: create_tar() lists/paths, compression='gz'/'bz2'/none recursive rel-paths; extract_tar() full/list prefix-matches, implicit destination/metadata.

  • Tar read: read_tar() "r:*" auto-detect lists.

  • Zip: create_zip() multi/arcname hierarchies, metadata returns; extract_zip() granular/full/single, KeyError miss/Runtime corrupt.

  • Zip read: read_zip() system-filter (show_compression_system_files=False hides __MACOSX/.DS_Store/Thumbs.db).

  • Errors: Raise FileNotFound/Permission/KeyError/Runtime over strings; Wrapper yields post-operations.

  • Single-mod merge: No submods, legacy aliases; prefix-match/filter tweaks, tar/zip parity.

Device

  • Hub: device imports cpu/disks/memory/network; lazy psutil, device.cpu.cpu_percent() hierarchical.

  • CPU: cpu_percent() floats (percpu), cpu_times() states (user/idle/etc.), cpu_count() logical/physical.

  • Disks: get_disk_partitions() tuples/filters (fstype/device/etc.); storage_metrics() 5-tuples, disk_info() indexed dicts; disk_io_counters() I/O namedtuples; boot boot_time() str, get_boot_drive_name() labels, get_filesystem_type() root.

  • Memory: virtual_memory() full (total/used/active/etc. bytes), getters (percent_virtual_memory()); swap_memory() (used/sin/sout), dedicated functions.

  • Network: WiFi/Ethernet get_wifi_interface/ip/mac/speed_mbps/sent/recv_bytes; totals get_total_sent_received_bytes(); get_active_tcp_connections() PID/IP:port lists; get_all_interfaces() NIC (Network Interface Card) dictionaries (IP/MAC/up/speed/bytes).

  • Guards: __require_psutil__() ImportError on-call; fallbacks (unsupported OS), no-privilege low-latency.

This release also includes other features and improvements:

  • Docstring renaissance: Params/returns/raises/examples per-function, module overviews/imports/snippets/.env templates for onboarding.

  • Platform harmony: Pathlib timestamp conversions, Win32 extends, logging/Core ties, no-elevated permissions.

  • Optimizations: Buffered/lazy (reads/enum/queues/pruning), thread-safe async, JSON reports; backward signatures/overloads.

  • Updates: Auto-import triggers, GitHub timeouts/callbacks/colors; consolidated modules (Compression/Watcher), all exports.

  • Version 3.0.0.0 uniform, major evolutions (chaining/metadata/batching/Device) with compatibility; MIT free, optional psutil.

Some features need permissions (writes/I/O) or vary by OS/FS (timestamps on FAT, swap macOS, fields virtualized environments).