Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def awatch_alt(*args, **kwargs):
yield {(Change.deleted, str(tmpdir.join('pages/other/whatever.png')))}
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')))}
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')
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)