Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreasonable return #284

Open
Dumbliidore opened this issue Jun 19, 2024 · 0 comments
Open

Unreasonable return #284

Dumbliidore opened this issue Jun 19, 2024 · 0 comments
Labels

Comments

@Dumbliidore
Copy link

Description

The target folder is D:\\work\\monitorTest, there is a folder named D:\\work\\monitorTest\\newFolder, when I delete it, I want to the output to be
{(<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder')}, (<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder\\subFile1.xlsx')},(<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder\\subFile2.xlsx')}.
When I undo the delete file operation , I want to the output to be {(<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder'),(<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder'\\subFile1.xlsx'), (<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder\\subFile2.xlsx')

Example Code

from pathlib import Path

from watchfiles import Change, watch


def is_gdb(change: Change, path: str) -> bool:
    if Path(path).parent.suffix == ".gdb":
        return False

    return True


for changes in watch(r"D:\work\monitorTest", watch_filter=is_gdb):
    print(changes)
    print()

Watchfiles Output

when I delete the folder:
print `{(<Change.deleted: 3>, 'D:\\work\\monitorTest\\newFolder')}`

whent I undo the delete folder operation:
print `{(<Change.modified: 2>, 'D:\\work\\monitorTest\\newFolder\\subFile1.xlsx'), (<Change.modified: 2>, 'D:\\work\\monitorTest\\newFolder\\subFile2.xlsx'), (<Change.added: 1>, 'D:\\work\\monitorTest\\newFolder')}`

Operating System & Architecture

Windows-10-10.0.22631-SP0
10.0.22631

Environment

Windows11

Python & Watchfiles Version

python3.11 & watchfiles>=0.22.0

Rust & Cargo Version

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant