diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0548bab..e070bd6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,8 @@ --- name: Tests on: - push: - branches: ['*'] pull_request: + push: branches: [main] jobs: build: diff --git a/pyproject.toml b/pyproject.toml index e19c6bb..10ebbb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,8 +41,8 @@ utilo_tidy = "utilo.xyz.tidy:main" dev = [ "PyYAML>=6.0.3,<7.0.0", "pytest-timeout>=2.4.0,<3.0.0", - "utilotest>=1.0.5,<2.0.0", - "iamraw>=4.94.1,<5.0.0", + "utilotest>=1.1.1,<2.0.0", + "iamraw>=4.95.0,<5.0.0", ] [project.urls] diff --git a/utilo/file/__init__.py b/utilo/file/__init__.py index 9e34c84..c0903db 100644 --- a/utilo/file/__init__.py +++ b/utilo/file/__init__.py @@ -479,13 +479,16 @@ def file_ext(path: str) -> str: return None -def files_sort(files: list) -> list: +def files_sort(files: list) -> list[str]: """Sort `files` path alphabetically. Sort file names by number if given. >>> files_sort(('/c/a', '/c/200.txt', '/c/2.txt', '/c/3', '/c/0.bmp')) ['/c/0.bmp', '/c/2.txt', '/c/3', '/c/200.txt', '/c/a'] + >>> import os + >>> files_sort(os.scandir('.')) + [...] """ - files = [utilo.forward_slash(item) for item in files] + files = [file_path(item) for item in files] def number_filename(item): # sort file names if they are numbers: 0,1,2,3,4,5,6,7,8,9,10 @@ -502,6 +505,13 @@ def number_filename(item): return files +def file_path(path): + if isinstance(path, os.DirEntry): + return file_path(str(path.path)) + path = utilo.forward_slash(path) + return path + + # Alphabetic with Nn and Tt to avoid \n\t in connex with file names POOL = 'ABCDEFGHIJKLMOPQRSUVYXYZabcdefghijklmtpqrsuvyxyz123456789'