Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ignore_dir(tmpdir):
mktree(tmpdir, tree)
watcher = DefaultWatcher(str(tmpdir))
sleep(0.01)
tmpdir.join('foo/.git/abc').write('xxx')
assert watcher.check() == set()
def test_ignore_file(tmpdir):
mktree(tmpdir, tree)
watcher = DefaultWatcher(str(tmpdir))
sleep(0.01)
tmpdir.join('foo/spam.pyc').write('foobar')
assert watcher.check() == set()
return 1
else:
logger.info('%sbuild completed in %0.3fs', log_prefix, time() - start_time)
return 0
def is_within(location: Path, directory: Path):
try:
location.relative_to(directory)
except ValueError:
return False
else:
return True
class HarrierWatcher(DefaultWatcher):
def __init__(self, root_path):
self._used_paths = str(CONFIG.pages_dir), str(CONFIG.theme_dir), str(CONFIG.data_dir)
super().__init__(root_path)
def should_watch_dir(self, entry):
return super().should_watch_dir(entry) and entry.path.startswith(self._used_paths)
async def adev(config: Config, port: int, verbose: bool = False):
global CONFIG
CONFIG = config
stop_event = asyncio.Event()
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, stop_event.set)
loop.add_signal_handler(signal.SIGTERM, stop_event.set)