Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
deleted = self.files.keys() - new_files.keys()
if deleted:
changes |= {(Change.deleted, entry) for entry in deleted}
self.files = new_files
return changes
class DefaultDirWatcher(AllWatcher):
ignored_dirs = {'.git', '__pycache__', 'site-packages', '.idea', 'node_modules'}
def should_watch_dir(self, entry):
return entry.name not in self.ignored_dirs
class DefaultWatcher(DefaultDirWatcher):
ignored_file_regexes = r'\.py[cod]$', r'\.___jb_...___$', r'\.sw.$', '~$'
def __init__(self, root_path):
self._ignored_file_regexes = tuple(re.compile(r) for r in self.ignored_file_regexes)
super().__init__(root_path)
def should_watch_file(self, entry):
return not any(r.search(entry.name) for r in self._ignored_file_regexes)
class PythonWatcher(DefaultDirWatcher):
def should_watch_file(self, entry):
return entry.name.endswith(('.py', '.pyx', '.pyd'))
class RegExpWatcher(AllWatcher):
def should_watch_dir(self, entry):
return entry.name not in self.ignored_dirs
class DefaultWatcher(DefaultDirWatcher):
ignored_file_regexes = r'\.py[cod]$', r'\.___jb_...___$', r'\.sw.$', '~$'
def __init__(self, root_path):
self._ignored_file_regexes = tuple(re.compile(r) for r in self.ignored_file_regexes)
super().__init__(root_path)
def should_watch_file(self, entry):
return not any(r.search(entry.name) for r in self._ignored_file_regexes)
class PythonWatcher(DefaultDirWatcher):
def should_watch_file(self, entry):
return entry.name.endswith(('.py', '.pyx', '.pyd'))
class RegExpWatcher(AllWatcher):
def __init__(self, root_path, re_files=None, re_dirs=None):
self.re_files = re.compile(re_files) if re_files is not None else re_files
self.re_dirs = re.compile(re_dirs) if re_dirs is not None else re_dirs
super().__init__(root_path)
def should_watch_file(self, entry):
return self.re_files.match(entry.path)
def should_watch_dir(self, entry):
return self.re_dirs.match(entry.path)