| 267 | time.sleep(checkinterval) |
| 268 | |
| 269 | def check(self, removepycfiles: bool = True) -> bool: |
| 270 | changed = False |
| 271 | newstat: dict[Path, os.stat_result] = {} |
| 272 | for rootdir in self.rootdirlist: |
| 273 | for path in visit_path(rootdir, filter=self.fil, recurse=self.rec): |
| 274 | oldstat = self.statcache.pop(path, None) |
| 275 | try: |
| 276 | curstat = path.stat() |
| 277 | except OSError: |
| 278 | if oldstat: |
| 279 | changed = True |
| 280 | else: |
| 281 | newstat[path] = curstat |
| 282 | if oldstat is not None: |
| 283 | if ( |
| 284 | oldstat.st_mtime != curstat.st_mtime |
| 285 | or oldstat.st_size != curstat.st_size |
| 286 | ): |
| 287 | changed = True |
| 288 | print("# MODIFIED", path) |
| 289 | if removepycfiles and path.suffix == ".py": |
| 290 | pycfile = path.with_suffix(".pyc") |
| 291 | if pycfile.is_file(): |
| 292 | os.unlink(pycfile) |
| 293 | |
| 294 | else: |
| 295 | changed = True |
| 296 | if self.statcache: |
| 297 | changed = True |
| 298 | self.statcache = newstat |
| 299 | return changed |