18.0 vanilla

This commit is contained in:
Ernad Husremovic 2025-10-03 18:06:50 +02:00
parent d72e748793
commit 0a7ae8db93
337 changed files with 399651 additions and 232598 deletions

View file

@ -6,11 +6,8 @@ Some functions related to the os and os.path module
"""
import os
import re
import warnings
import zipfile
from os.path import join as opj
WINDOWS_RESERVED = re.compile(r'''
^
@ -51,21 +48,6 @@ def clean_filename(name, replacement=''):
return "Untitled"
return re.sub(r'[^\w_.()\[\] -]+', replacement, name).lstrip('.-') or "Untitled"
def listdir(dir, recursive=False):
"""Allow to recursively get the file listing following symlinks, returns
paths relative to the provided `dir` except completely broken if the symlink
it follows leaves `dir`...
"""
assert recursive, "use `os.listdir` or `pathlib.Path.iterdir`"
warnings.warn("Since 16.0, use os.walk or a recursive glob", DeprecationWarning, stacklevel=2)
dir = os.path.normpath(dir)
res = []
for root, _, files in os.walk(dir, followlinks=True):
r = os.path.relpath(root, dir)
yield from (opj(r, f) for f in files)
return res
def zip_dir(path, stream, include_dir=True, fnct_sort=None): # TODO add ignore list
"""
: param fnct_sort : Function to be passed to "key" parameter of built-in