How to use the watchgod.Change.deleted function in watchgod

To help you get started, we’ve selected a few watchgod examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelcolvin / harrier / tests / test_dev.py View on Github external
async def awatch_alt(*args, **kwargs):
        yield {(Change.deleted, str(tmpdir.join('pages/other/whatever.png')))}
github samuelcolvin / watchgod / tests / test_watch.py View on Github external
def test_delete(tmpdir):
    mktree(tmpdir, tree)

    watcher = AllWatcher(str(tmpdir))

    sleep(0.01)
    tmpdir.join('foo/bar.txt').remove()

    assert watcher.check() == {(Change.deleted, str(tmpdir.join('foo/bar.txt')))}
github gleb-sevruk / pycrunch-engine / pycrunch / watcher / fs_watcher.py View on Github external
path = Path('.').absolute()
        print('watching this:...')
        print(path)
        async for changes in awatch(path, watcher_cls=PythonWatcher):
            for c in changes:
                change_type = c[0]

                force = False
                if change_type == Change.added:
                    force = True

                file = c[1]
                logger.info(f'File watcher alarm: file: `{file}` type `{change_type}` ')

                if force or self.should_watch(file):
                    if change_type == Change.deleted:
                        execution_pipeline.add_task(FileRemovedTask(file=file))
                        logger.info('Added file removal for pipeline ' + file)
                    else:
                        execution_pipeline.add_task(FileModifiedNotificationTask(file=file))
                        logger.info('Added file modification for pipeline ' + file)
                else:
                    logger.debug('non-significant file changed ' + file)

        logger.debug('END thread_proc')
github samuelcolvin / harrier / harrier / dev.py View on Github external
content_templates(SOM['pages'].values(), config)
        else:
            SOM['config'] = config
            if args.data:
                start = time()
                SOM['data'] = load_data(config)
                log_complete(start, 'data updated', 1)
                args.templates = True

            to_update = set()
            if args.pages:
                start = time()
                tmp_dir = config.get_tmp_dir()
                for change, path in args.pages:
                    rel_path = '/' + str(path.relative_to(config.pages_dir))
                    if change == Change.deleted:
                        page = SOM['pages'][rel_path]
                        outfile = get_outfile(page, config)
                        outfile.unlink()
                        if 'content_template' in page:
                            (tmp_dir / page['content_template']).unlink()
                        SOM['pages'].pop(rel_path)
                    else:
                        v = get_page_data(path, config=config)
                        if v:
                            v.pop('path_ref')
                            SOM['pages'][rel_path] = v
                            to_update.add(rel_path)
                log_complete(start, 'pages built', len(args.pages))
                args.templates = args.templates or any(change != Change.deleted for change, _ in args.pages)

            extra_pages = apply_page_generator(SOM, config)