morebuiltins.cmd.ui: the Host/Origin allowlist follows the bind address (loopback IPv4/IPv6 plus the bind host;[::1]:portbind strings parse), the new--web-allowed-hostssupplies extra hosts for remote access, a rejected request answers 403 and prints the live allowlist to stderr, output produced on a non-owner thread is written back to the real stdout instead of being dropped,SimpleHTTPRequestHandleris kept as an alias ofFuncWebHandler,TKUI.get_result()works without arguments, and an exception returns onlyrepr(err)to the browser while the traceback goes to the process stderr.morebuiltins.cmd.log_server:end_callbackjoins the consumer withCONSUMER_JOIN_TIMEOUTinstead of hangingclose(),default_handlernames its parameterrecordagain, and__del__tolerates a half-constructed instance.- [Compatibility Warnings] binding a non-loopback host now raises ValueError at construction (
--hostexits with a parser error): the socket protocol has no authentication and every frame is unpickled; run on 127.0.0.1/::1 and forward logs over a trusted channel.
- [Compatibility Warnings] binding a non-loopback host now raises ValueError at construction (
morebuiltins.cmd.systemd.timerandmorebuiltins.cmd.parse_deps: timer parameters given as a list are emitted one line per value instead of a Python repr; relative imports whose base directory escapesproject_dirare skipped.morebuiltins.zipapps:download_pythondownloads to a temp file and replaces the target only after the digest verifies, so a failed download keeps the previous good file; unversioned assets sort after versioned ones; the interactive and auto selection paths share one matcher; MD5 fingerprinting falls back to SHA-256 when the interpreter is in FIPS mode or lacksusedforsecurity;freezingcomputes the UTC offset from the target timestamp, so the DST of that moment applies.- [Compatibility Warnings] a failed or interrupted download keeps the previous tarball instead of deleting it.
morebuiltins.request: thereqandDomainParserdoctests run against a loopback echo server and a temporary public suffix list instead ofpostman-echo.com/publicsuffix.org, sotest.pyno longer needs outbound network.morebuiltins.shared_memory:PLock.close()logs the "holder pid changed before unlink" race at debug level instead of emitting aRuntimeWarning, andlogs.test_LogHelperclears staleapp_test.log*files before counting so an interrupted earlier run no longer fails the suite.- [Compatibility Warnings]
PLock.close()no longer emits theRuntimeWarningfor that race; rely on themorebuiltins.shared_memorydebug log instead.
- [Compatibility Warnings]
morebuiltins.date.Crontab: invalid/out-of-range fields raise ValueError; fields may be separated by any whitespace; day-of-month/day-of-week follow Vixie cron (ORed only when both restricted); ValueError is raised when no match is found within max_tries instead of silently yielding nothing;countnow means the number of distinct callback values (dedup uses a private sentinel, so falsy andNonevalues are still deduplicated).morebuiltins.date.ScheduleTimer: fix step lookup for negated patterns; dedup never worked becauselast_itemwas never assigned; dedup sentinel broke with falsy callback values.morebuiltins.utils.is_running: fix UnicodeDecodeError on CJK Windows (tasklist output is locale-encoded, now read as bytes);is_running_linuxtreats EPERM as running instead of dead.morebuiltins.utils.base_decode: default alphabet now matchesbase_encode(uppercase before lowercase).- [Compatibility Warnings] decoding old mixed-case strings produced with the previous decode alphabet returns different values.
morebuiltins.utils.find_jsons: fix infinite loop when the first left bracket has no matched right bracket.morebuiltins.utils.base_encode: negative input raises ValueError (used to loop forever);get_hashraises ValueError fornoutside1..len(digest)(used to return an empty string silently).morebuiltins.utils.PathLock:timeoutcontention raises TimeoutError only with the newraise_on_timeout=True; the default keeps the historical behaviour (the body still runs, without the lock, and no lock is released on exit); a timed-out waiter no longer removes another holder's entry or releases another holder's lock; the path matching keeps blocking a parent request while a child path is locked; the docstring no longer claims a whole-hierarchy guarantee.- [Compatibility Warnings]
PathLockis not reentrant, and holding a parent lock does not block new child requests (only the reverse direction is guarded); passraise_on_timeout=Trueto get a TimeoutError instead of a block that runs unprotected.
- [Compatibility Warnings]
morebuiltins.utils.FileDict: json/pickle handlers write via a temp file plusos.replace, closing the window where a crash between unlink and rename lost the file.morebuiltins.utils.SimpleFilter: timer creation is under the lock; the pending timer is really cancelled on exit and is a daemon thread.morebuiltins.utilsdocstrings corrected:ptimereturn type,retrydefault 2 (andtries<1now raises ValueError),unique/slice_*yield description,i2bupper-bound table,gen_idmicrosecond/entropy notes,unix_rlimiterror message,ValidatorPEP 563 limitation; removed dead code inset_pid_file/switch_flush_printand thereturninsideget_paste's finally.morebuiltins.logs:gzip_logno longer loses both the original file and the compressed copy when rename fails;backupCount<=0keeps all backups (stdlib contract) instead of deleting them; rollover/compress failures are logged instead of swallowed;do_compress_asyncre-entry guard reads the right attribute; listener restore removes the tracked QueueHandler by identity;bind_handler(filename=None)detaches handlers without closing them and keeps their cache entries, soclose_all_handlerscan still reclaim the file handles; binding a second handler for the same file only closes handlers this class created, a user-attachedFileHandleris left in place with a warning;__del__tolerates half-constructed instances;stop()unregisters its atexit hook;comress_chunk_sizerenamed tocompress_chunk_sizewith the old name kept as a property alias.- [Compatibility Warnings]
backupCount<=0now keeps every rotated file (previously the extras were removed); detaching a logger no longer drops its handlers fromFILENAME_HANDLER_MAP, soclose_all_handlerscloses handlers that are already detached; a secondFileHandleron the same path that LogHelper did not create is no longer closed, only warned about. morebuiltins.funcs.NamedLock: cache creation is race-free;clear_unlockedno longer drops a Semaphore that still holds permits; docstring warns that a timed-out acquire leaves the block unprotected.- [Compatibility Warnings] the private
_SYNC_CACHE/_ASYNC_CACHEvalues are now(lock, initial_value)tuples instead of bare locks, so direct readers must unpack. morebuiltins.funcs.func_cmd: required parameters are only rejected when actually missing from the command line (previously every call with a required parameter raised);auto_default=Truestill fills''/0and is documented.morebuiltins.funcs.debounce:mode="trailing"gives a real trailing debounce (window resets per call, only the last call's arguments run) and wrappers keep metadata viafunctools.wraps; the defaultmode="leading"keeps the previous behaviour (the first call runs immediately, calls inside the window return None), so existing callers do not change.- [Compatibility Warnings]
mode="trailing"does not run the decorated function immediately on first call; sync calls return None and the result of the final run is discarded; exceptions raised by the debounced function do not reach the caller (they surface via the thread/task exception handlers); a call whose window has not elapsed by loop close or interpreter exit is dropped. Callers must flush themselves before shutdown (no built-in flush API).
- [Compatibility Warnings]
morebuiltins.funcs:__all__includescountdown/LineTime/LineProfiler/line_profiler;lru_cache_ttlkeys on real arguments (kwargs order insensitive) andmaxsize<=0no longer raises KeyError.- [Compatibility Warnings]
lru_cache_ttlcache keys are the argument tuple instead of the previous hash int, so code that inspects<func>.cachekeys must change;maxsize<=0returns the function unchanged, so.cache/.ttl_cleanare not set even withcontrols=True.
- [Compatibility Warnings]
morebuiltins.cmd.log_server:level_specssurvives a dump/from_dict round trip (customLevel Nvalues were left as strings and broke reload);wait_close_syncno longer blocks forever; the queue consumer stops before files are closed; opened log files are LRU-capped (MAX_OPENED_FILES) to bound handles;--idle-close-timedefaults to 60 like the class and has help text; unknown--log-streamvalues warn instead of silently muting;__all__exportsget_logger/create_handler; docstring demo matches real output.morebuiltins.cmd.log_server: client log names are validated (the resolved path must stay insidelog_dir; absolute paths and..escapes are rejected, sub-directories are still allowed), client formatter payloads use a restricted unpickler (logging's builtin styles andstring.Templateare allowed), an invalid settings record or a single unformattable record no longer shuts the server down; queue-full no longer raises out ofclose().- [Compatibility Warnings] client formatter classes other than logging's builtin ones are rejected on the base64 settings path; log names escaping
log_dirare rejected. morebuiltins.cmd.ui: bool answers fromTKit.askare honoured (they were always False); each POST uses its own queue so a broken connection cannot leak output into the next request; worker output and window title are marshalled to the Tk main thread; POST validates Host/Origin, Content-Length and body size;EOFErrorexits cleanly; handler renamed toFuncWebHandler.morebuiltins.ipc: sync handler replies are sent back (the executor future was not awaited); half-closed connections no longer busy-spin (readexactly);close()always runs the end callback and shuts the executor down; active writers are closed on Python 3.12-style teardown sowait_closedcannot deadlock; unsupported UDS on win32 raises NotImplementedError;inspect.iscoroutinefunctionreplaces the deprecated asyncio one.- [Compatibility Warnings]
port=0now means "let the OS pick a TCP port" instead of falling into the UDS branch.
- [Compatibility Warnings]
morebuiltins.sqlite: docstring encoder sample passes callables;count/items/keys/values/popitemacceptliteral=Trueto match the prefix literally (%/_escaped), while the default keeps the historical LIKE wildcard behaviour;recreate_tablehonourskey_type/value_type; table/column identifiers are backtick-escaped;close()tolerates a failed constructor;copy/update/itemsdocstrings match real behaviour.- [Compatibility Warnings] prefix matching still treats
%/_as LIKE wildcards by default (the 1.4.0 draft escaped them unconditionally and changedcount(prefix="a_b")from 2 rows to 1); passliteral=Truefor a literal prefix.
- [Compatibility Warnings] prefix matching still treats
morebuiltins.shared_memory:kill_with_namevalidates the pid range and probes liveness before signalling (a zero/garbage prefix could kill the caller's process group on POSIX);close()re-checks ownership before unlinking;SharedBytes.close()survives an external unlink; size boundary off-by-one fixed; docstrings describe crash leftovers andforcesemantics honestly.- [Compatibility Warnings] operations that detect a stale or foreign owner now emit a
RuntimeWarninginstead of proceeding silently.
- [Compatibility Warnings] operations that detect a stale or foreign owner now emit a
morebuiltins.tk:TextWindowsurvives the user closing the window (TclError no longer replaces the body's exception);max()on string-only rows works;tk.Tk()failures no longer raise UnboundLocalError; the patchedprintforwards to the original whenfileis given.morebuiltins.request:verify/contextare honoured on thebuild_opener_handlers/proxypaths (verify=Falseonly applies when the caller did not pass its owncontext);custom_dnschains installs and gainsrestore_dns();DomainParserdoes no network IO in its constructor and downloads the PSL lazily with an atomic cache write; foreignHTTPResponseobjects raise AttributeError instead of returningb"";paramsdrops None values and still accepts key/value sequences;dataempty values fall through tojson=/form=;RequestErrorsincludes read timeouts (3.8/3.9 included);update_urlreplaces every duplicate key; Date header is locale-independent.morebuiltins.emails: a failed login quits the SMTP session before re-raising; an unreadable body file raises instead of sending the path as the body; attachment paths are stripped; zero-byte attachments are still sent; body files default to utf-8.- [Compatibility Warnings] a GBK body file that used to be read with the locale encoding now needs an explicit
encoding;prepare_attach("")returns None instead of raising.
- [Compatibility Warnings] a GBK body file that used to be read with the locale encoding now needs an explicit
morebuiltins.snippets.sql:delete(limit=...)uses arowid IN (SELECT rowid ... ORDER BY rowid LIMIT n)form that runs on stock CPython builds (it needs a real rowid:WITHOUT ROWIDtables and tables with a plainrowidcolumn are not supported);clear_free_pagesvacuums non-incremental databases instead of doing nothing;create_tablerejectsautoincrementon composite/non-integer primary keys;upsertdropsOR REPLACEso a UNIQUE conflict raises IntegrityError instead of silently deleting the conflicting row.- [Compatibility Warnings]
upserton a non-target UNIQUE column now raises IntegrityError;clear_free_pagesreturns(freelist_before, freelist_after)and commits + VACUUMs non-incremental databases.
- [Compatibility Warnings]
morebuiltins.zipapps: layer archives honourcompressed(it was inverted);--dump-config/--load-configkeeprm_patterns; freezing decodes witherrors="ignore"and computes the timezone offset at call time;._pthhandling matches mid-fileimport siteand CRLF; pip probing uses subprocess;activate_zipappsuses the importlib spec API and registers the module insys.modules;download_pythonfixes-i -k(empty filter exits cleanly), version ordering (3.13.0vs3.12.10), failure exit codes, progress division by zero, tar extraction filter, temp-file collisions, and verifies the asset'sdigestfield (the releases do not publish.sha256sidecars).- [Compatibility Warnings]
--unziprefuses to overwrite an existing target dir without--force; download failures exit non-zero; a digest mismatch aborts (skipped only when the release provides no digest).
- [Compatibility Warnings]
morebuiltins.cmd.systemd: systemctl return codes propagate (exit code reflects failure);-Service__X=A=Bkeeps the full value;-RequiredBy/-Also/-Aliasare emitted; custom sections merge into existing ones; unit files are written as utf-8; missing-ExecStartprints help instead of a traceback;-Environmentis repeatable on timers.- [Compatibility Warnings] commands no longer prefix
sudo(dry-run now matches what is executed).
- [Compatibility Warnings] commands no longer prefix
morebuiltins.cmd.parse_deps:import xhonoursignore_stdslikefrom x import y;from . import siblingis resolved when the sibling module exists.morebuiltins.cmd.proxy_checker:-iwithout-owrites to stdout as documented;-ctakes precedence over-i;-uis actually used to build the probe request;-rhelp states it applies to the last loop only.- [Compatibility Warnings]
-unow sends an origin-form request line (GET /path) instead of an absolute-form one.
- [Compatibility Warnings]
publish.pyrefuses to publish unless--yesis passed, the git tree is clean, CHANGELOG has the version section and the version is not already on PyPI;--dry-runruns the checks without uploading.- [Compatibility Warnings]
python publish.pyno longer publishes; it prints usage and exits with code 2.
- [Compatibility Warnings]
- Published by accident from an inconsistent working tree (some modules fixed, some still pre-fix). Superseded by 1.4.0;
publish.pynow refuses this class of mistake.
- add AUTO_CAST to
morebuiltins.utils.Validatorfor automatic type conversion - add --dry-run/--test to cmd.systemd
- fix
morebuiltins.utils.Validatorwhile type is Union / Optional
- add
morebuiltins.funcs.async_callto automatically call a function asynchronously, whether it's sync or async. - add
morebuiltins.funcs.countdownto print a countdown timer inline in the console. - update
morebuiltins.utils.code_inlineusing zlib instead of gzip. - add
morebuiltins.utils.Validatorstring alias for bool typeValidatornow supports string values like "true", "false", "1", "0", "yes", "no", "on", "off" for boolean fields.
- fix writer.wait_closed() ConnectionResetError in ipc.py, proxy_checker.py, log_server.py
- add
morebuiltins.funcs.debouncedecorator to debounce function calls. - add
separg tomorebuiltins.utils.gen_idto customize the separator between date and time. - add
LoggerStreamtomorebuiltins.logsto redirect sys.stdout/sys.stderr with prefix.- Use
sys.stdout = LoggerStream()to redirect all stdout to LoggerStream, which sends logs to the logging system / file / custom writer. LoggerStream.replace_print_ctx: A context manager to temporarily replace the print function within a block of code.- add time prefix to each print line.
- Use
- add
nofmtextra field support tomorebuiltins.cmd.log_serverto skip formatting for high-frequency/thinking logs. - add
scriptsentry topyproject.tomlformorebuiltinscommand line tool.- now you can run
uvx morebuiltins morebuiltins.cmd.log_serverto start log server with uvx.
- now you can run
- fix
morebuiltins.utils.gen_idwrong length issue. - fix
morebuiltins.funcs.LineProfilerto handle nested function calls correctly. - update
morebuiltins.cmd.log_serverto support close idle file handlers after 300 seconds. - add
get_loggertomorebuiltins.cmd.log_serverto get a singleton logger withSocketHandlerto send logs toLogServer. - [Compatibility Warnings] Refactor of
morebuiltins.cmd.log_server:- use
LogSettingstruct instead of untyped dict, client send dict withLogSettingstructure. - add
level_specsfilter to specify log levels of files, like[logging.ERROR, logging.CRITICAL]. - add cache file for log settings, readable by both server and human.
- THIS IS A BREAKING CHANGE, old clients may not work with new server.
- use
- add
morebuiltins.logs.LogHelper.handle_crashto log uncaught exceptions. - fix
morebuiltins.logs.LogHelper.bind_handlerto avoid adding duplicate queue handlers. - update default format of
morebuiltins.logs.LogHelperto"%(asctime)s | %(levelname)-5s | %(filename)+8s:%(lineno)+3s - %(message)s".
- fix typing-hint for
morebuiltins.funcs.threadsdecorator, now it returnsCallable[..., Future]. - add force kill methods to
morebuiltins.shared_memory.PLock:- add
force_signumtomorebuiltins.shared_memory.PLock, to specify the signal number to force kill the process if it exists. - add
is_freetomorebuiltins.shared_memory.PLock, to check if the lock is free. - add
kill_with_nametomorebuiltins.shared_memory.PLock, to kill the process with the given name and signal number.
- add
- add
morebuiltins.logs.LogHelperto quickly bind a logging handler to a logger, with a StreamHandler or SizedTimedRotatingFileHandler. - Compatibility Warnings:
- move
async_logger,AsyncQueueListener,LogHelper,RotatingFileWriter, andSizedTimedRotatingFileHandlerfrommorebuiltins.funcstomorebuiltins.logs.
- move
- add
ContextFilterfor logging, to add context variables to log records. - add
queuearg tomorebuiltins.logs.LogHelper.bind_handler, to enable async logging withAsyncQueueListener. (like loguru's queue=True)
- add
check_recursiontomorebuiltins.funcs, to check if a function is recursive. - add
SharedBytestomorebuiltins.shared_memory, a shared memory for bytes, similar tomultiprocessing.shared_memory.SharedMemorywith a header for size. - add
line_profilerdecorator tomorebuiltins.funcs, to profile function execution time line by line.
- Compatibility Warning. rename
morebuiltins.functoolstomorebuiltins.funcsto avoid conflict withfunctoolsin python standard library. - add
key_typearg tosqlite.KV, to supportintkey. - add
utils.cut_fileto cut file witha+bmode to limit the file size - add recheck for
utils.set_pid_file - add
shared_memory.PLockfor singleton process withmultiprocessing.shared_memory, support linux and windows. - add
--StandardOutputand--StandardErrortomorebuiltins.cmd.systemd.service, and update--Environmentto list type. - add
is_port_freetomorebuiltins.ipc.
- add
sqlite.KV: A key-value store using sqlite3, lightweightsqlitedict.
- Change the default alphabet in
utils.base_encodeto "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", which follows the order of ASCII characters. - add
utils.SnowFlakefor id generator
- add
utils.get_sizeto get size of objects recursively. - add
base_encode, base_decode, gen_id, timetitoutils - add alias for AsyncQueueListener:
functools.async_logger
- add
snippets.sql.SqliteSQLas Sqlite SQL generator - add
cmd.parse_depsto parse dependencies of a project directory, and find circular dependencies. - add
cmd.os.linux.systemd.serviceandcmd.os.linux.systemd.timer - add
functools.to_thread, same asasyncio.to_threadin python 3.9+. - add
functools.AsyncQueueListenerfor asyncio non-block logging. - fix systemd.timer typing hint error
- add
utils.i2bandutils.b2i, integer and fixed-length byte strings conversion. - add
--compresstocmd.log_server - add
snippets.event.EventTemplate
- fix
utils.code_inlinegzip compressmtimeto 1, to ensure the same compressed data - fix
utils.FileDict.save - add
ipc.QueueManagerbased on BaseManager, add JSON listener - add
compress,ensure_dirarg tofuntools.SizedTimedRotatingFileHandler - add
compressarg tofuntools.RotatingFileWriter - update
utils.format_errordefault filter skip from "site-packages" to "-packages"
- add filename_filter to utils.format_error
- add
functools.get_functionto find function from entrypoint- set the type default to str while strict=False and no default/annotation
- add
defaultbutton_texttoTKit.ask_text - add
morebuiltins.cmd.uiwith--cli/--gui,--web- try
python -m morebuiltins.cmd.ui -e re:findall --cli - try
python -m morebuiltins.cmd.ui -e re:findall --gui1 - try
python -m morebuiltins.cmd.ui -e re:findall --gui2 - try
python -m morebuiltins.cmd.ui -e test_func_web --web --web-open --web-timeout=30
- try
- add default doc for
morebuiltins.cmd.ui--gui morebuiltins.functools.FuncSchemachangedparsewill see arg type asstrwhile strict=False and no default/annotation- add
to_stringto FuncSchema
- add
utils.get_hash_int
- modify default args for
cmd.proxy_checker
- add
morebuiltins.cmd.proxy_checker--max-result for quick return - fix
morebultins.cmd.log_serverlost log in high frequency writing
- add
cmd.proxy_checkerpython -m morebuiltins.cmd.proxy_checker -cto check proxy, input from clipboard and output to clipboard
- add utils.Clipboard as same api as pyperclip
- add
cmd.log_server - add start_callback end_callback to
ipc.SocketServer- ipc: self.handler(self, item) -> self.handler(item)
- add
RotatingFileWriter.flush, and default flush=False - fix
StreamWriter.__del__fails if event loop is already closed
- update 2024.08.07 zipapps https://github.com/ClericPy/zipapps/releases/tag/2024.08.07
- add
functools.RotatingFileWriter- prepare for
log_serverwithasyncio+ipc.SocketLogHandlerEncoder
- prepare for
- fix default_dict type-hint
- fix read num zero div
- add build_opener_handlers+proxy to request.req
- add
utils.PathLock
- add
functools.file_import
- fix
utils.Validatortyping-hint class
- add
add py.typed - update
utils.Validatordefault toSTRICT=True
- fix
functools.func_cmdmulti-line docstring - add
utils.FileDict
- add
functools.get_type_default - add
functools.func_cmd - add
emails.SimpleEmail
- update
utils.unix_rlimitdefault to None - add
utils.weight_dict - add
utils.SimpleFilter
functools.FuncSchema.parsedefault strict=True
- add
tk.TextWindow - add
utils.unix_rlimit - release as the first stable version
- add
tk.TKit.ask_text - focus_force for
tk.TKit
- update default format of
utils.format_error - add
functools.SizedTimedRotatingFileHandler - add
utils.switch_flush_print - add
tk.TKit
- add
utils.is_running_linux,utils.is_running_win32 - add
functools.InlinePB - add
date.ScheduleTimer,date.Crontab
- add
utils.xor_encode_decode - add
utils.is_running,utils.lock_pid_file - add
request.make_response - add
utils.get_paste(tk),utils.set_clip(win32) - add
utils.custom_dns - update
utils.format_errorsupport slice index