惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
I
InfoQ
B
Blog RSS Feed
D
Docker
GbyAI
GbyAI
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
F
Fortinet All Blogs
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
M
MIT News - Artificial intelligence
C
Check Point Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
博客园 - Franky
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
Last Week in AI
Last Week in AI
L
LangChain Blog

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
GitHub - ghetea-patrick/filorithm: A fluent Python eDSL f...
patrick-ghet · 2026-05-22 · via Hacker News: Show HN

Filorithm is an expressive Python embedded Domain Specific Language (eDSL) designed for high-level file and folder manipulation. By utilizing operator overloading and chainable filtering interfaces, Filorithm abstracts the verbose complexities of standard libraries like os, shutil, and pathlib into clean, intuitive pipeline operations.

Abstract & Architecture

Filorithm operates on the concept of wrapping directory contents into managed collection objects (Files and Folders). Instead of executing procedural function calls, workflows are declared using fluent filter interfaces and completed using standard operators that mimic terminal actions.

The framework is split into distinct components:

  1. storage.py: The underlying engine handling safe path validation, file copy/move operations, and strict error handling.
  2. files.py / folders.py: The user-facing API containing collection wrappers and the fluent filter classes (FilterFiles, FilterFolders).
  3. file_types.py: Constant tuples grouping common extensions (e.g., CODE_INTERPRETED, DATA, IMAGES) for rapid batch processing.

Syntax Rules & Operators

Filorithm overrides standard Python operators to execute file system tasks directly on collection objects or evaluated filters:

  • >> (Right-shift): Moves items in the collection to a destination directory.
  • @ (Matmul): Copies items in the collection to a destination directory.
  • ~ (Invert / Unary tilde): Deletes all items in the collection permanently.

Pipeline Rules:

  1. Instantiating Files("dir") or Folders("dir") gathers all immediate items inside that directory.
  2. Invoking the .filter() method transitions the collection into an evaluation state.
  3. Filtering methods can be chained infinitely (e.g., .bigger_than().with_extensions()).
  4. The pipeline MUST be closed with .collect() before an operator (>>, @, ~) can be applied to the filtered subset.
  5. To directly inspect or iterate over the elements without executing a filesystem mutation (move, copy, or delete), access the raw contents via list iteration, index lookup, or by calling .collect().

API Reference & Filter Methods

Collection Initializers

  • Files(directory: str | Path, *, overwrite: bool = False)
  • Folders(directory: str | Path, *, overwrite: bool = False)

If overwrite=True, any existing file or folder at the target destination with a conflicting name will be removed before the copy or move operation executes.

Chainable Filter Pipeline

Calling .filter() exposes the following evaluation constraints:

  • Size Constraints:

    • .bigger_than(size: int, unit: SizeUnit)
    • .smaller_than(size: int, unit: SizeUnit)
    • .between_sizes(min_size: int, min_unit: SizeUnit, max_size: int, max_unit: SizeUnit)
    • Supported Units: "kb", "mb", "gb", "tb"
  • String Matching Constraints:

    • .name_startswith(prefix: str)
    • .name_endswith(suffix: str)
    • .name_contains(text: str)
    • .name_matches(regex: str | Pattern)
  • Metadata & Quantity Constraints:

    • .modified_after(dt: datetime)
    • .modified_before(dt: datetime)
    • .largest(count: int)
    • .smallest(count: int)
    • .top(count: int)
    • .last(count: int)
  • Extension Specifics (Files Only):

    • .with_extensions(extensions: Sequence[str])
    • .without_extensions(extensions: Sequence[str])

Examples

from datetime import datetime
from filorithm.files import Files
from filorithm.folders import Folders
from filorithm.file_types import CODE_INTERPRETED, IMAGES, DOCUMENTS

# ==============================================================================
# EXAMPLE 1: Basic File Migration
# ==============================================================================
# Instantly move all files out of a raw data staging folder directly into a 
# processing directory using the right-shift (>>) syntax wrapper.

Files("staging_area") >> "processing_vault"


# ==============================================================================
# EXAMPLE 2: Size Filtering and Copying Assets
# ==============================================================================
# Target a downloads folder, chain a filter to isolate only massive media files 
# exceeding 500 Megabytes, collect the result, and duplicate them using matmul (@).

Files("downloads").filter().bigger_than(500, "mb").collect() @ "external_media_drive"


# ==============================================================================
# EXAMPLE 3: Ecosystem-Driven Script and Document Sorting
# ==============================================================================
# Organize a cluttered workspace directory by routing interpreted scripts 
# (py, js, rb) to a dedicated scripts path, and documents (pdf, docx, txt) to docs.

# A. Pipeline for code scripts
Files("workspace").filter().with_extensions(CODE_INTERPRETED).collect() >> "development/scripts"

# B. Pipeline for documentation
Files("workspace").filter().with_extensions(DOCUMENTS).collect() >> "development/documentation"


# ==============================================================================
# EXAMPLE 4: In-Memory Inspection (Passive Elements Viewing)
# ==============================================================================
# Inspect metadata properties, parse index elements, or count specific assets 
# without mutating, moving, or modifying any actual items on the filesystem storage.
print("\nExecuting Example 4: Passive viewing and collection inspection...")

# Initialize target snapshot
asset_collection = Files("project_assets")

# A. String representation showing discovered files
print(f"Current collection array: {asset_collection}")

# B. Positional index access
if len(asset_collection) > 0:
    first_asset = asset_collection[0]
    print(f"Primary asset tracking path: {first_asset}")

# C. Native iteration loop
for file_item in asset_collection:
    print(f"Scanning asset metadata: {file_item.name} | Size: {file_item.stat().st_size} bytes")

# D. Compound filtered view count without execution
target_date = datetime(2026, 1, 1)
outdated_images = Files("gallery").filter().with_extensions(IMAGES).modified_before(target_date).collect()
print(f"Total legacy images matching parameters: {len(outdated_images)}")


# ==============================================================================
# EXAMPLE 5: Destructive Temporary Cache and Directory Purging
# ==============================================================================
# Safely wipe out local transient build artifact directories or old testing data 
# recursively using the unary invert (~) shortcut operator.

~Folders("local_test_environment/build_caches")