From 819302a7ebb759e09c50d9bcbcd2a447895bbabf Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Sun, 30 Nov 2008 00:43:03 +0000
Subject: [PATCH] Refactor functionality to get interesting files into a seperate function.
---
django/utils/autoreload.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 8d9d6f2..4dbc945 100644
a
|
b
|
RUN_RELOADER = True
|
48 | 48 | _mtimes = {} |
49 | 49 | _win = (sys.platform == "win32") |
50 | 50 | |
51 | | def code_changed(): |
52 | | global _mtimes, _win |
| 51 | def gen_filenames(): |
53 | 52 | for filename in filter(lambda v: v, map(lambda m: getattr(m, "__file__", None), sys.modules.values())): |
54 | 53 | if filename.endswith(".pyc") or filename.endswith(".pyo"): |
55 | 54 | filename = filename[:-1] |
56 | 55 | if not os.path.exists(filename): |
57 | 56 | continue # File might be in an egg, so it can't be reloaded. |
| 57 | yield filename |
| 58 | |
| 59 | def code_changed(): |
| 60 | global _mtimes, _win |
| 61 | for filename in gen_filenames(): |
58 | 62 | stat = os.stat(filename) |
59 | 63 | mtime = stat.st_mtime |
60 | 64 | if _win: |