Skip to content

Commit

Permalink
Merge branch 'master' into fsevents-always-recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG authored Jul 28, 2024
2 parents b59d7b4 + 7503d34 commit de2712f
Show file tree
Hide file tree
Showing 45 changed files with 543 additions and 682 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ task:
- python3.8 -m pip install -U pip
- python3.8 -m pip install -r requirements-tests.txt
lint_script:
- python3.8 -m flake8 docs src tests tools
- python3.8 -m ruff src
tests_script:
- python3.8 -bb -m pytest tests
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# GitHub Actions
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
44 changes: 25 additions & 19 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
- master
pull_request:
branches:
- '**'
- "**"

workflow_dispatch:
inputs:
Expand All @@ -41,11 +41,11 @@ jobs:
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build dependencies
Expand All @@ -55,9 +55,11 @@ jobs:
env:
CIBW_SKIP: "cp36-*" # skip 3.6 wheels
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
- uses: actions/upload-artifact@v3
- name: Artifacts list
run: ls -l wheelhouse
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions
name: python-package-distributions-macos
path: ./wheelhouse/*.whl

pure-built-distributions:
Expand All @@ -66,11 +68,11 @@ jobs:
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build dependencies
Expand All @@ -81,9 +83,11 @@ jobs:
do
python setup.py bdist_wheel --plat-name $platform
done
- uses: actions/upload-artifact@v3
- name: Artifacts list
run: ls -l dist
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions
name: python-package-distributions-pure-wheels
path: ./dist/*.whl

source-distribution:
Expand All @@ -92,21 +96,22 @@ jobs:
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build source distribution
run: python setup.py sdist
- name: Artifacts list
run: ls -l dist
- name: Store the source distribution
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist
retention-days: 4
name: python-package-distributions-source
path: dist/*.tar.gz

publish:
needs:
Expand All @@ -117,16 +122,17 @@ jobs:
timeout-minutes: 5
steps:
- name: Download all the dists
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: python-package-distributions
pattern: python-package-distributions-*
merge-multiple: true
path: dist/
- name: What will we publish?
run: ls -l dist
- name: Publish
if: github.event.inputs.branch != ''
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
skip-existing: true
38 changes: 16 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- master
pull_request:
branches:
- '**'

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name != 'pull_request' && github.sha || '' }}
Expand All @@ -21,12 +19,12 @@ jobs:
fail-fast: false
matrix:
tox:
- name: Types
environment: types
timeout: 15
- name: Test
environment: py
timeout: 15
- name: mypy
environment: mypy
timeout: 15
os:
- name: Linux
matrix: linux
Expand All @@ -50,17 +48,8 @@ jobs:
- "pypy-3.9"
include:
- tox:
name: Flake8
environment: flake8
timeout: 5
python: "3.11"
os:
name: Linux
emoji: 🐧
runs-on: [ubuntu-latest]
- tox:
name: isort
environment: isort-ci
name: Linter
environment: lint
timeout: 5
python: "3.11"
os:
Expand All @@ -77,6 +66,12 @@ jobs:
emoji: 🐧
runs-on: [ubuntu-latest]
exclude:
- os:
matrix: macos
python: "pypy-3.8"
- os:
matrix: macos
python: "pypy-3.9"
- os:
matrix: windows
python: "pypy-3.8"
Expand All @@ -87,17 +82,16 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip

- name: Install test dependencies
run: |
python -m pip install tox
run: python -m pip install tox

- name: Run ${{ matrix.tox.name }} in tox
run: |
python -m tox -e ${{ matrix.tox.environment }}
run: python -m tox -e ${{ matrix.tox.environment }}
5 changes: 0 additions & 5 deletions .isort.cfg

This file was deleted.

38 changes: 18 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,26 @@ as command-line arguments and logs events generated:

.. code-block:: python
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
path = sys.argv[1] if len(sys.argv) > 1 else '.'
logging.info(f'start watching directory {path!r}')
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
finally:
observer.stop()
observer.join()
from watchdog.events import FileSystemEventHandler
class MyEventHandler(FileSystemEventHandler):
def on_any_event(self, event):
print(event)
event_handler = MyEventHandler()
observer = Observer()
observer.schedule(event_handler, '.', recursive=True)
observer.start()
try:
while True:
time.sleep(1)
finally:
observer.stop()
observer.join()
Shell Utilities
Expand Down
21 changes: 19 additions & 2 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,27 @@
Changelog
---------

3.0.1
4.0.2 (dev)
~~~~~~~~~~~

2024-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v4.0.1...HEAD>`__

- [core] Run ``ruff``, apply several fixes (`#1033 <https://github.com/gorakhargosh/watchdog/pull/1033>`__)
- [fsevents] Add missing ``event_filter`` keyword-argument to ``FSEventsObserver.schedule()`` (`#1049 <https://github.com/gorakhargosh/watchdog/pull/1049>`__)
- Thanks to our beloved contributors: @BoboTiG

4.0.1
~~~~~

2024-05-23 • `full history <https://github.com/gorakhargosh/watchdog/compare/v4.0.0...v4.0.1>`__

- [inotify] Fix missing ``event_filter`` for the full emitter (`#1032 <https://github.com/gorakhargosh/watchdog/pull/1032>`__)
- Thanks to our beloved contributors: @mraspaud, @BoboTiG

4.0.0
~~~~~

2023-xx-xx • `full history <https://github.com/gorakhargosh/watchdog/compare/v3.0.0...HEAD>`__
2024-02-06 • `full history <https://github.com/gorakhargosh/watchdog/compare/v3.0.0...v4.0.0>`__

- Drop support for Python 3.7.
- Add support for Python 3.12.
Expand Down
10 changes: 5 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
TOP_DIR_PATH = os.path.abspath("../../") # noqa
SRC_DIR_PATH = os.path.join(TOP_DIR_PATH, "src") # noqa
sys.path.insert(0, SRC_DIR_PATH) # noqa
TOP_DIR_PATH = os.path.abspath("../../")
SRC_DIR_PATH = os.path.join(TOP_DIR_PATH, "src")
sys.path.insert(0, SRC_DIR_PATH)

import watchdog.version # noqa
import watchdog.version # noqa: E402

PROJECT_NAME = "watchdog"
AUTHOR_NAME = "Yesudeep Mangalapilly and contributors"
COPYRIGHT = "2010-2023, " + AUTHOR_NAME
COPYRIGHT = f"2010-2024, {AUTHOR_NAME}"


# -- General configuration -----------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/global.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

.. |author_name| replace:: Yesudeep Mangalapilly
.. |author_email| replace:: yesudeep@gmail.com
.. |copyright| replace:: Copyright 2012-2023 Google, Inc & contributors.
.. |copyright| replace:: Copyright 2012-2024 Google, Inc & contributors.
.. |project_name| replace:: ``watchdog``
.. |project_version| replace:: 3.0.1
.. |project_version| replace:: 4.0.2

.. _issue tracker: https://github.com/gorakhargosh/watchdog/issues
.. _code repository: https://github.com/gorakhargosh/watchdog
Expand Down
44 changes: 21 additions & 23 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ to detect changes. Here is what we will do with the API:

1. Create an instance of the :class:`watchdog.observers.Observer` thread class.

2. Implement a subclass of :class:`watchdog.events.FileSystemEventHandler`
(or as in our case, we will use the built-in
:class:`watchdog.events.LoggingEventHandler`, which already does).
2. Implement a subclass of :class:`watchdog.events.FileSystemEventHandler`.

3. Schedule monitoring a few paths with the observer instance
attaching the event handler.
Expand All @@ -29,27 +27,27 @@ entire directory trees is ensured.
A Simple Example
----------------
The following example program will monitor the current directory recursively for
file system changes and simply log them to the console::
file system changes and simply print them to the console::

import sys
import logging
import time
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
path = sys.argv[1] if len(sys.argv) > 1 else '.'
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while observer.is_alive():
observer.join(1)
finally:
observer.stop()
observer.join()
from watchdog.events import FileSystemEventHandler


class MyEventHandler(FileSystemEventHandler):
def on_any_event(self, event):
print(event)


event_handler = MyEventHandler()
observer = Observer()
observer.schedule(event_handler, '.', recursive=True)
observer.start()
try:
while True:
time.sleep(1)
finally:
observer.stop()
observer.join()

To stop the program, press Control-C.
Loading

0 comments on commit de2712f

Please sign in to comment.