Lars Yencken committed fe449bb

Allows more flexible needs_update() dependencies, including module instances.

- Allows module instances, converting them to their source filename.
- Converts compiled python source files to the original source when available.

Comments (0)

Files changed (1)

 Models for the checksum app.
+from os import path
+import types
 from zlib import crc32
 from django.db import models
     def checksum(files):
         result = 0
-        for filename in files:
+        for module_or_filename in files:
+            # Replace module references with the file which defines them.
+            if type(module_or_filename) == types.ModuleType:
+                filename = module_or_filename.__file__
+            else:
+                filename = module_or_filename
+            # Replace compiled python files with their source code.
+            if (filename.endswith('.pyc') or filename.endswith('.pyo')) \
+                        and path.exists(filename[:-1]):
+                filename = filename[:-1]
             i_stream = open(filename, 'r')
             result = crc32(, result)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.